source: imaps-frontend/node_modules/lodash-es/omit.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import arrayMap from './_arrayMap.js';
2import baseClone from './_baseClone.js';
3import baseUnset from './_baseUnset.js';
4import castPath from './_castPath.js';
5import copyObject from './_copyObject.js';
6import customOmitClone from './_customOmitClone.js';
7import flatRest from './_flatRest.js';
8import getAllKeysIn from './_getAllKeysIn.js';
9
10/** Used to compose bitmasks for cloning. */
11var CLONE_DEEP_FLAG = 1,
12 CLONE_FLAT_FLAG = 2,
13 CLONE_SYMBOLS_FLAG = 4;
14
15/**
16 * The opposite of `_.pick`; this method creates an object composed of the
17 * own and inherited enumerable property paths of `object` that are not omitted.
18 *
19 * **Note:** This method is considerably slower than `_.pick`.
20 *
21 * @static
22 * @since 0.1.0
23 * @memberOf _
24 * @category Object
25 * @param {Object} object The source object.
26 * @param {...(string|string[])} [paths] The property paths to omit.
27 * @returns {Object} Returns the new object.
28 * @example
29 *
30 * var object = { 'a': 1, 'b': '2', 'c': 3 };
31 *
32 * _.omit(object, ['a', 'c']);
33 * // => { 'b': '2' }
34 */
35var 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
57export default omit;
Note: See TracBrowser for help on using the repository browser.