source: node_modules/ramda/es/omit.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 899 bytes
RevLine 
[d24f17c]1import _curry2 from "./internal/_curry2.js";
2/**
3 * Returns a partial copy of an object omitting the keys specified.
4 *
5 * @func
6 * @memberOf R
7 * @since v0.1.0
8 * @category Object
9 * @sig [String] -> {String: *} -> {String: *}
10 * @param {Array} names an array of String property names to omit from the new object
11 * @param {Object} obj The object to copy from
12 * @return {Object} A new object with properties from `names` not on it.
13 * @see R.pick
14 * @example
15 *
16 * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
17 */
18
19var omit =
20/*#__PURE__*/
21_curry2(function omit(names, obj) {
22 var result = {};
23 var index = {};
24 var idx = 0;
25 var len = names.length;
26
27 while (idx < len) {
28 index[names[idx]] = 1;
29 idx += 1;
30 }
31
32 for (var prop in obj) {
33 if (!index.hasOwnProperty(prop)) {
34 result[prop] = obj[prop];
35 }
36 }
37
38 return result;
39});
40
41export default omit;
Note: See TracBrowser for help on using the repository browser.