JSPM

auto-group-strings

1.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q26526F
  • License MIT

Small JS library to group array of strings by common substring

Package Exports

  • auto-group-strings

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (auto-group-strings) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

auto-group-strings

Small JS library to group array of strings by common substring

Node.js

npm install auto-group-strings

Browser

Use auto-group-strings.min.js file from dist/

Function Arguments:

  1. inputStrings, type: Array<string>

  2. options, type: Object (optional), properties:

    • delimiter (default: " ")
    • direction (default: "rtl")
      Its possible values are `"ltr"` for searching left to right or, `"rtl"` for right to left.
    • caseSensitive (default: false)

Return Type:

  • Array<Object> where
    • common property is a string
    • members property is an Array<number>

Usage

const autoGroupStrings = require("auto-group-strings");

const result = autoGroupStrings(
  [
    "hello code", // 0
    "apple and orange", // 1
    "for the happy code", // 2
    "i don't know", // 3
    "is it?", // 4
    "it's a happy code", // 5
  ],
  {
    delimiter: " ",
    direction: "rtl",
  },
);

console.log(result);
/*
[
  { common: 'code', members: [ 0, 2, 5 ] },
  { common: 'happy code', members: [ 2, 5 ] }
]
*/