landau / split-with

Returns an array of [takeWhile(pred, coll), dropWhile(pred, coll)]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

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

About

Returns an array of [takeWhile(pred, coll), dropWhile(pred, coll)]

License:ISC License


Languages

Language:JavaScript 100.0%