1 | import _curry2 from "./internal/_curry2.js";
|
2 | /**
|
3 | * Returns a partial copy of an object containing only the keys that satisfy
|
4 | * the supplied predicate.
|
5 | *
|
6 | * @func
|
7 | * @memberOf R
|
8 | * @since v0.8.0
|
9 | * @category Object
|
10 | * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v}
|
11 | * @param {Function} pred A predicate to determine whether or not a key
|
12 | * should be included on the output object.
|
13 | * @param {Object} obj The object to copy from
|
14 | * @return {Object} A new object with only properties that satisfy `pred`
|
15 | * on it.
|
16 | * @see R.pick, R.filter
|
17 | * @example
|
18 | *
|
19 | * const isUpperCase = (val, key) => key.toUpperCase() === key;
|
20 | * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
21 | */
|
22 |
|
23 | var pickBy =
|
24 | /*#__PURE__*/
|
25 | _curry2(function pickBy(test, obj) {
|
26 | var result = {};
|
27 |
|
28 | for (var prop in obj) {
|
29 | if (test(obj[prop], prop, obj)) {
|
30 | result[prop] = obj[prop];
|
31 | }
|
32 | }
|
33 |
|
34 | return result;
|
35 | });
|
36 |
|
37 | export default pickBy; |
\ | No newline at end of file |