1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 | /**
|
5 | * Returns a partial copy of an object containing only the keys specified. If
|
6 | * the key does not exist, the property is ignored.
|
7 | *
|
8 | * @func
|
9 | * @memberOf R
|
10 | * @since v0.1.0
|
11 | * @category Object
|
12 | * @sig [k] -> {k: v} -> {k: v}
|
13 | * @param {Array} names an array of String property names to copy onto a new object
|
14 | * @param {Object} obj The object to copy from
|
15 | * @return {Object} A new object with only properties from `names` on it.
|
16 | * @see R.omit, R.props
|
17 | * @example
|
18 | *
|
19 | * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
|
20 | * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}
|
21 | */
|
22 |
|
23 |
|
24 | var pick =
|
25 | /*#__PURE__*/
|
26 | _curry2(function pick(names, obj) {
|
27 | var result = {};
|
28 | var idx = 0;
|
29 |
|
30 | while (idx < names.length) {
|
31 | if (names[idx] in obj) {
|
32 | result[names[idx]] = obj[names[idx]];
|
33 | }
|
34 |
|
35 | idx += 1;
|
36 | }
|
37 |
|
38 | return result;
|
39 | });
|
40 |
|
41 | module.exports = pick; |
\ | No newline at end of file |