Package Exports
- auto-group-strings-array
- auto-group-strings-array/dist/index.js
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-array) 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-array
Small JS library to group array of strings by common substring
Node.js
npm install auto-group-strings-array
Browser
Use auto-group-strings.min.js
file from dist/
Function Arguments:
inputStrings (type:
Array<string>
)options, type:
Object
(optional), properties:- delimiter (type:
string
, default:" "
) - delimiterRegExp (type:
RegExp
, default:undefined
)- if delimiterRegExp is provided, delimiter (
string
) will only be used as a fallback when there is no match for delimiterRegExp
- if delimiterRegExp is provided, delimiter (
- direction (type:
string
, default:"rtl"
)
- Its possible values are `"ltr"` for searching left to right or, `"rtl"` for right to left. - caseSensitive (type:
boolean
, default:false
) - includeSingleElementMembers (type:
boolean
, default:false
)- this option includes every input string from the first argument as common and at least one element (index) in members array.
- delimiter (type:
Return Type:
Array<Object>
wherecommon
property is astring
members
property is anArray<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 ] }
]
*/
- For more examples, please check examples directory.