Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/madarche/array-segments
Finds element segments matches in an array
https://github.com/madarche/array-segments
Last synced: about 1 month ago
JSON representation
Finds element segments matches in an array
- Host: GitHub
- URL: https://github.com/madarche/array-segments
- Owner: madarche
- License: mit
- Created: 2017-08-08T07:34:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-31T20:02:08.000Z (about 7 years ago)
- Last Synced: 2024-12-17T03:25:42.048Z (about 1 month ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
array-segments
==============[![NPM version](http://img.shields.io/npm/v/array-segments.svg)](https://www.npmjs.org/package/array-segments)
Finds element segments matches in an array.
Usage
-----```javascript
const array_segments = require('array-segments');let res
res = array_segments.match(
['a', 'b', 'c', 'd', 'e', 'f', 'a', 'z', 'a', 'b'],
[
['c', 'd', 'e'],
['b', 'c', 'd', 'e'],
['a', 'z'],
['a', 'b'],
['a']
])console.log(res)
// [ { segment: [ 'c', 'd', 'e' ], indices: [ 2 ] },
// { segment: [ 'a', 'z' ], indices: [ 6 ] },
// { segment: [ 'a', 'b' ], indices: [ 0, 8 ] } ]// Case insensitive match
res = array_segments.match(
['a', 'b', 'c', 'D', 'E', 'f', 'a', 'z', 'a', 'b'],
[
['C', 'd', 'E'],
['b', 'c', 'd', 'e'],
['a', 'z'],
['a', 'b'],
['a']
],
{ignore_case: true})console.log(res)
// [ { segment: [ 'c', 'd', 'e' ], indices: [ 2 ] },
// { segment: [ 'a', 'z' ], indices: [ 6 ] },
// { segment: [ 'a', 'b' ], indices: [ 0, 8 ] } ]
```Contributions
-------------Pull Requests and contributions in general are welcome as long as they follow
the [Node aesthetic].[Node aesthetic]: http://substack.net/node_aesthetic