1.0.1 • Published 6 years ago

split-array-by-const v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

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

1.0.1

6 years ago

1.0.0

6 years ago