split-array-by-const
v1.0.1
Published
Split an array into multiple ones, using a custom value as the separator.
Downloads
2
Readme
split-array-by-const
Split an array into multiple ones, using a custom value as the separator.
API
This module expoers one function:
splitArrayByConst(a, c)
Returns an array of (potentially empty) arrays, each with
items found in a
before, between, and after each occurrences of c
.
Usage
from usage.js:
var split = require('split-array-by-const'), a;
a = [
'hello', 'world', null,
{ foo: 'bar' }, null,
[ 12, 34, null, 56 ], null,
null,
true, { qux: null }, null,
];
equal(split(a, null), [
[ 'hello', 'world' ],
[ { foo: 'bar' } ],
[ [ 12, 34, null, 56 ] ],
[],
[ true, { qux: null } ],
[],
]);
Known issues
- Needs more/better tests and docs.
License
ISC