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.3 KB
|
Line | |
---|
1 | var filter =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./filter.js");
|
---|
4 |
|
---|
5 | var juxt =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./juxt.js");
|
---|
8 |
|
---|
9 | var reject =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./reject.js");
|
---|
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 |
|
---|
38 | var partition =
|
---|
39 | /*#__PURE__*/
|
---|
40 | juxt([filter, reject]);
|
---|
41 | module.exports = partition; |
---|
Note:
See
TracBrowser
for help on using the repository browser.