mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Bump to v4.17.0.
This commit is contained in:
29
omit.js
29
omit.js
@@ -1,16 +1,22 @@
|
||||
define(['./_arrayMap', './_baseDifference', './_basePick', './_flatRest', './_getAllKeysIn', './_toKey'], function(arrayMap, baseDifference, basePick, flatRest, getAllKeysIn, toKey) {
|
||||
define(['./_baseClone', './_baseUnset', './_copyObject', './_flatRest', './_getAllKeysIn'], function(baseClone, baseUnset, copyObject, flatRest, getAllKeysIn) {
|
||||
|
||||
/** Used to compose bitmasks for cloning. */
|
||||
var CLONE_DEEP_FLAG = 1,
|
||||
CLONE_FLAT_FLAG = 2,
|
||||
CLONE_SYMBOLS_FLAG = 4;
|
||||
|
||||
/**
|
||||
* The opposite of `_.pick`; this method creates an object composed of the
|
||||
* own and inherited enumerable string keyed properties of `object` that are
|
||||
* not omitted.
|
||||
* own and inherited enumerable property paths of `object` that are not omitted.
|
||||
*
|
||||
* **Note:** This method is considerably slower than `_.pick`.
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The source object.
|
||||
* @param {...(string|string[])} [props] The property identifiers to omit.
|
||||
* @param {...(string|string[])} [paths] The property paths to omit.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
@@ -19,12 +25,19 @@ define(['./_arrayMap', './_baseDifference', './_basePick', './_flatRest', './_ge
|
||||
* _.omit(object, ['a', 'c']);
|
||||
* // => { 'b': '2' }
|
||||
*/
|
||||
var omit = flatRest(function(object, props) {
|
||||
var omit = flatRest(function(object, paths) {
|
||||
var result = {};
|
||||
if (object == null) {
|
||||
return {};
|
||||
return result;
|
||||
}
|
||||
props = arrayMap(props, toKey);
|
||||
return basePick(object, baseDifference(getAllKeysIn(object), props));
|
||||
copyObject(object, getAllKeysIn(object), result);
|
||||
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
|
||||
|
||||
var length = paths.length;
|
||||
while (length--) {
|
||||
baseUnset(result, paths[length]);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
return omit;
|
||||
|
||||
Reference in New Issue
Block a user