source: node_modules/ramda/es/partition.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d24f17c]1import filter from "./filter.js";
2import juxt from "./juxt.js";
3import reject from "./reject.js";
4/**
5 * Takes a predicate and a list or other `Filterable` object and returns the
6 * pair of filterable objects of the same type of elements which do and do not
7 * satisfy, the predicate, respectively. Filterable objects include plain objects or any object
8 * that has a filter method such as `Array`.
9 *
10 * @func
11 * @memberOf R
12 * @since v0.1.4
13 * @category List
14 * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a]
15 * @param {Function} pred A predicate to determine which side the element belongs to.
16 * @param {Array} filterable the list (or other filterable) to partition.
17 * @return {Array} An array, containing first the subset of elements that satisfy the
18 * predicate, and second the subset of elements that do not satisfy.
19 * @see R.filter, R.reject
20 * @example
21 *
22 * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']);
23 * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
24 *
25 * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
26 * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]
27 */
28
29var partition =
30/*#__PURE__*/
31juxt([filter, reject]);
32export default partition;
Note: See TracBrowser for help on using the repository browser.