Initial commit
[yaffs-website] / node_modules / object.omit / index.js
1 /*!
2  * object.omit <https://github.com/jonschlinkert/object.omit>
3  *
4  * Copyright (c) 2014-2015, Jon Schlinkert.
5  * Licensed under the MIT License.
6  */
7
8 'use strict';
9
10 var isObject = require('is-extendable');
11 var forOwn = require('for-own');
12
13 module.exports = function omit(obj, keys) {
14   if (!isObject(obj)) return {};
15
16   keys = [].concat.apply([], [].slice.call(arguments, 1));
17   var last = keys[keys.length - 1];
18   var res = {}, fn;
19
20   if (typeof last === 'function') {
21     fn = keys.pop();
22   }
23
24   var isFunction = typeof fn === 'function';
25   if (!keys.length && !isFunction) {
26     return obj;
27   }
28
29   forOwn(obj, function(value, key) {
30     if (keys.indexOf(key) === -1) {
31
32       if (!isFunction) {
33         res[key] = value;
34       } else if (fn(value, key, obj)) {
35         res[key] = value;
36       }
37     }
38   });
39   return res;
40 };