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