split-with
v3.0.2
Published
Returns an array of [takeWhile(coll, pred), dropWhile(coll, pred)]
Downloads
12
Maintainers
Readme
split-with
Returns an array of [takeWhile(coll, pred), dropWhile(coll, pred)]
function splitWith(coll, pred, ctx) { }
Install
npm i -S split-with
Usage
var assert = require('assert');
var splitWith = require('split-with');
var is = require('is-predicate');
function gtEq3(val) {
return is.greaterEq(3, val);
}
var arr = [1, 2, 3, 4, 5];
var expected = [[1, 2, 3], [4, 5]];
assert.deepEqual(splitWith(arr, gtEq3), expected); // true