UNPKG

1.28 kBJavaScriptView Raw
1var filter =
2/*#__PURE__*/
3require("./filter");
4
5var juxt =
6/*#__PURE__*/
7require("./juxt");
8
9var reject =
10/*#__PURE__*/
11require("./reject");
12/**
13 * Takes a predicate and a list or other `Filterable` object and returns the
14 * pair of filterable objects of the same type of elements which do and do not
15 * satisfy, the predicate, respectively. Filterable objects include plain objects or any object
16 * that has a filter method such as `Array`.
17 *
18 * @func
19 * @memberOf R
20 * @since v0.1.4
21 * @category List
22 * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a]
23 * @param {Function} pred A predicate to determine which side the element belongs to.
24 * @param {Array} filterable the list (or other filterable) to partition.
25 * @return {Array} An array, containing first the subset of elements that satisfy the
26 * predicate, and second the subset of elements that do not satisfy.
27 * @see R.filter, R.reject
28 * @example
29 *
30 * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']);
31 * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
32 *
33 * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
34 * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]
35 */
36
37
38var partition =
39/*#__PURE__*/
40juxt([filter, reject]);
41module.exports = partition;
\No newline at end of file