Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

a-partition

vikramcse25MIT1.0.1

Splits an array into two parts if given predicate satisfied

split, array, satisfied, predicate, condition, two, halfs

readme

a-partition

Splits an array into two parts if given predicate satisfied

Install

$ npm install --save a-partition

Example

var arrayPredicate = require('a-partition');

console.log(arrayPredicate([0, 1, 2, 3, 4, 5], function (value) {
  return value % 2 === 0;
}));

// -> [ [ 0, 2, 4 ], [ 1, 3, 5 ] ]

console.log(arrayPredicate([1, 2, 3, 4]));

// -> throw new Error('predicate value required');

require('a-partition')(list, callback)

Arguments:

  • list: list be the single array
  • callback: callback be the predicate that will be executed on each element of array

Returns: Returns an array having two array first contains elements which satisfies the predicate and other which don't

License

© 2016 Vikram Jadhav. MIT License