splitwith
v0.0.2
Published
Returns an array of [_.takeWhile(arr, pred), _.dropWhile(arr, pred)](use lodash)
Downloads
4
Maintainers
Readme
splitWith
Returns an array of [takeWhile(arr, pred), dropWhile(arr, pred)](use lodash)
Install
$ npm install --save splitwith
Usage
const splitWith = require('splitwith')
splitWith([1, 2, 3, 4, 5, 6], (x) => (x < 3)) // [[1, 2], [3, 4, 5, 6]]
// array-like objects
splitWith('abcdef', (x) => (x < 'c')) // [['a', 'b'], ['c', 'd', 'e', 'f']]
API
splitWith(arr, pred)
arr
Type: array
or array-like objects
pred
Type: function
Usage is same as https://lodash.com/docs#takeWhile
License
MIT © JIANG Di