1.0.1 • Published 8 years ago

a-partition v1.0.1

Weekly downloads
10
License
MIT
Repository
github
Last release
8 years ago

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