-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
37 lines (29 loc) · 747 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*!
* object.omit <https://github.com/jonschlinkert/object.omit>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
var isObject = require('is-extendable');
module.exports = function omit(obj, props, fn) {
if (!isObject(obj)) return {};
if (typeof props === 'function') {
fn = props;
props = [];
}
if (typeof props === 'string') {
props = [props];
}
var isFunction = typeof fn === 'function';
var keys = Object.keys(obj);
var res = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var val = obj[key];
if (!props || (props.indexOf(key) === -1 && (!isFunction || fn(val, key, obj)))) {
res[key] = val;
}
}
return res;
};