UNPKG

961 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4/**
5 * Similar to `pick` except that this one includes a `key: undefined` pair for
6 * properties that don't exist.
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.pick
17 * @example
18 *
19 * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
20 * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined}
21 */
22
23
24var pickAll =
25/*#__PURE__*/
26_curry2(function pickAll(names, obj) {
27 var result = {};
28 var idx = 0;
29 var len = names.length;
30
31 while (idx < len) {
32 var name = names[idx];
33 result[name] = obj[name];
34 idx += 1;
35 }
36
37 return result;
38});
39
40module.exports = pickAll;
\No newline at end of file