123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- var arrayMap = require('./_arrayMap'),
- baseClone = require('./_baseClone'),
- baseUnset = require('./_baseUnset'),
- castPath = require('./_castPath'),
- copyObject = require('./_copyObject'),
- customOmitClone = require('./_customOmitClone'),
- flatRest = require('./_flatRest'),
- getAllKeysIn = require('./_getAllKeysIn');
- var CLONE_DEEP_FLAG = 1,
- CLONE_FLAT_FLAG = 2,
- CLONE_SYMBOLS_FLAG = 4;
- var omit = flatRest(function(object, paths) {
- var result = {};
- if (object == null) {
- return result;
- }
- var isDeep = false;
- paths = arrayMap(paths, function(path) {
- path = castPath(path, object);
- isDeep || (isDeep = path.length > 1);
- return path;
- });
- copyObject(object, getAllKeysIn(object), result);
- if (isDeep) {
- result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
- }
- var length = paths.length;
- while (length--) {
- baseUnset(result, paths[length]);
- }
- return result;
- });
- module.exports = omit;
|