1 | var arrayMap = require('./_arrayMap'),
|
2 | baseClone = require('./_baseClone'),
|
3 | baseUnset = require('./_baseUnset'),
|
4 | castPath = require('./_castPath'),
|
5 | copyObject = require('./_copyObject'),
|
6 | customOmitClone = require('./_customOmitClone'),
|
7 | flatRest = require('./_flatRest'),
|
8 | getAllKeysIn = require('./_getAllKeysIn');
|
9 |
|
10 |
|
11 | var CLONE_DEEP_FLAG = 1,
|
12 | CLONE_FLAT_FLAG = 2,
|
13 | CLONE_SYMBOLS_FLAG = 4;
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | var omit = flatRest(function(object, paths) {
|
36 | var result = {};
|
37 | if (object == null) {
|
38 | return result;
|
39 | }
|
40 | var isDeep = false;
|
41 | paths = arrayMap(paths, function(path) {
|
42 | path = castPath(path, object);
|
43 | isDeep || (isDeep = path.length > 1);
|
44 | return path;
|
45 | });
|
46 | copyObject(object, getAllKeysIn(object), result);
|
47 | if (isDeep) {
|
48 | result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
|
49 | }
|
50 | var length = paths.length;
|
51 | while (length--) {
|
52 | baseUnset(result, paths[length]);
|
53 | }
|
54 | return result;
|
55 | });
|
56 |
|
57 | module.exports = omit;
|