vendor/assets/javascripts/lodash.core.js in lodash-rails-4.13.1 vs vendor/assets/javascripts/lodash.core.js in lodash-rails-4.14.1
- old
+ new
@@ -11,16 +11,16 @@
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the semantic version number. */
- var VERSION = '4.13.1';
+ var VERSION = '4.14.1';
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
- /** Used to compose bitmasks for wrapper metadata. */
+ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1,
PARTIAL_FLAG = 32;
/** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1,
@@ -55,28 +55,25 @@
'"': '"',
"'": ''',
'`': '`'
};
- /** Detect free variable `exports`. */
- var freeExports = typeof exports == 'object' && exports;
-
- /** Detect free variable `module`. */
- var freeModule = freeExports && typeof module == 'object' && module;
-
/** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(typeof global == 'object' && global);
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
- var freeSelf = checkGlobal(typeof self == 'object' && self);
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(typeof this == 'object' && this);
-
/** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || thisGlobal || Function('return this')();
+ var root = freeGlobal || freeSelf || Function('return this')();
+ /** Detect free variable `exports`. */
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+ /** Detect free variable `module`. */
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
/*--------------------------------------------------------------------------*/
/**
* Appends the elements of `values` to `array`.
*
@@ -112,10 +109,36 @@
}
return -1;
}
/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
+ * The base implementation of `_.propertyOf` without support for deep paths.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function basePropertyOf(object) {
+ return function(key) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
* The base implementation of `_.reduce` and `_.reduceRight`, without support
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
@@ -150,30 +173,17 @@
return object[key];
});
}
/**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
-
- /**
* Used by `_.escape` to convert characters to HTML entities.
*
* @private
* @param {string} chr The matched character to escape.
* @returns {string} Returns the escaped character.
*/
- function escapeHtmlChar(chr) {
- return htmlEscapes[chr];
- }
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
@@ -182,10 +192,24 @@
*/
function isHostObject() {
return false;
}
+ /**
+ * Creates a function that invokes `func` with its first argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+ }
+
/*--------------------------------------------------------------------------*/
/** Used for built-in method references. */
var arrayProto = Array.prototype,
objectProto = Object.prototype;
@@ -281,20 +305,20 @@
* `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
* `zipObject`, `zipObjectDeep`, and `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
- * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`,
- * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`,
- * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`,
- * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
- * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`,
- * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`,
- * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
- * `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
- * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`,
- * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
* `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
* `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
* `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
* `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
* `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
@@ -405,17 +429,17 @@
function baseCreate(proto) {
return isObject(proto) ? objectCreate(proto) : {};
}
/**
- * The base implementation of `_.delay` and `_.defer` which accepts an array
- * of `func` arguments.
+ * The base implementation of `_.delay` and `_.defer` which accepts `args`
+ * to provide to `func`.
*
* @private
* @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation.
- * @param {Object} args The arguments to provide to `func`.
+ * @param {Array} args The arguments to provide to `func`.
* @returns {number} Returns the timer id.
*/
function baseDelay(func, wait, args) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
@@ -571,11 +595,11 @@
return isFunction(object[key]);
});
}
/**
- * The base implementation of `_.gt` which doesn't coerce arguments to numbers.
+ * The base implementation of `_.gt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
@@ -584,10 +608,21 @@
function baseGt(value, other) {
return value > other;
}
/**
+ * The base implementation of `_.isDate` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ */
+ function baseIsDate(value) {
+ return isObjectLike(value) && objectToString.call(value) == dateTag;
+ }
+
+ /**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
@@ -642,17 +677,21 @@
var objIsObj = objTag == objectTag && !isHostObject(object),
othIsObj = othTag == objectTag && !isHostObject(other),
isSameTag = objTag == othTag;
stack || (stack = []);
- var stacked = find(stack, function(entry) {
- return entry[0] === object;
+ var objStack = find(stack, function(entry) {
+ return entry[0] == object;
});
- if (stacked && stacked[1]) {
- return stacked[1] == other;
+ var othStack = find(stack, function(entry) {
+ return entry[0] == other;
+ });
+ if (objStack && othStack) {
+ return objStack[1] == other;
}
stack.push([object, other]);
+ stack.push([other, object]);
if (isSameTag && !objIsObj) {
var result = (objIsArr)
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
stack.pop();
@@ -678,10 +717,21 @@
stack.pop();
return result;
}
/**
+ * The base implementation of `_.isRegExp` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ */
+ function baseIsRegExp(value) {
+ return isObject(value) && objectToString.call(value) == regexpTag;
+ }
+
+ /**
* The base implementation of `_.iteratee`.
*
* @private
* @param {*} [value=_.identity] The value to convert to an iteratee.
* @returns {Function} Returns the iteratee.
@@ -702,13 +752,11 @@
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
- function baseKeys(object) {
- return nativeKeys(Object(object));
- }
+ var baseKeys = overArg(nativeKeys, Object);
/**
* The base implementation of `_.keysIn` which doesn't skip the constructor
* property of prototypes or treat sparse arrays as dense.
*
@@ -725,11 +773,11 @@
}
return result;
}
/**
- * The base implementation of `_.lt` which doesn't coerce arguments to numbers.
+ * The base implementation of `_.lt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
@@ -802,19 +850,35 @@
return result;
}, {});
}
/**
- * The base implementation of `_.property` without support for deep paths.
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
*/
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
+ function baseRest(func, start) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = array;
+ return func.apply(this, otherArgs);
};
}
/**
* The base implementation of `_.slice` without an iteratee call guard.
@@ -951,13 +1015,13 @@
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
- : source[key];
+ : undefined;
- assignValue(object, key, newValue);
+ assignValue(object, key, newValue === undefined ? source[key] : newValue);
}
return object;
}
/**
@@ -966,11 +1030,11 @@
* @private
* @param {Function} assigner The function to assign values.
* @returns {Function} Returns the new assigner function.
*/
function createAssigner(assigner) {
- return rest(function(object, sources) {
+ return baseRest(function(object, sources) {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined;
customizer = (assigner.length > 3 && typeof customizer == 'function')
@@ -1047,11 +1111,11 @@
*
* @private
* @param {Function} Ctor The constructor to wrap.
* @returns {Function} Returns the new wrapped function.
*/
- function createCtorWrapper(Ctor) {
+ function createCtor(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors. See
// http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
@@ -1072,44 +1136,38 @@
* @returns {Function} Returns the new find function.
*/
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
var iterable = Object(collection);
- predicate = baseIteratee(predicate, 3);
if (!isArrayLike(collection)) {
- var props = keys(collection);
+ var iteratee = baseIteratee(predicate, 3);
+ collection = keys(collection);
+ predicate = function(key) { return iteratee(iterable[key], key, iterable); };
}
- var index = findIndexFunc(props || collection, function(value, key) {
- if (props) {
- key = value;
- value = iterable[key];
- }
- return predicate(value, key, iterable);
- }, fromIndex);
- return index > -1 ? collection[props ? props[index] : index] : undefined;
+ var index = findIndexFunc(collection, predicate, fromIndex);
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
};
}
/**
* Creates a function that wraps `func` to invoke it with the `this` binding
* of `thisArg` and `partials` prepended to the arguments it receives.
*
* @private
* @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
- * for more details.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} partials The arguments to prepend to those provided to
* the new function.
* @returns {Function} Returns the new wrapped function.
*/
- function createPartialWrapper(func, bitmask, thisArg, partials) {
+ function createPartial(func, bitmask, thisArg, partials) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
var isBind = bitmask & BIND_FLAG,
- Ctor = createCtorWrapper(func);
+ Ctor = createCtor(func);
function wrapper() {
var argsIndex = -1,
argsLength = arguments.length,
leftIndex = -1,
@@ -1210,22 +1268,18 @@
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
switch (tag) {
case boolTag:
case dateTag:
- // Coerce dates and booleans to numbers, dates to milliseconds and
- // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
- // not equal.
- return +object == +other;
+ case numberTag:
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
+ // Invalid dates are coerced to `NaN`.
+ return eq(+object, +other);
case errorTag:
return object.name == other.name && object.message == other.message;
- case numberTag:
- // Treat `NaN` vs. `NaN` as equal.
- return (object != +object) ? other != +other : object == +other;
-
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
// for more details.
@@ -1397,11 +1451,11 @@
* @static
* @memberOf _
* @since 1.1.0
* @category Array
* @param {Array} array The array to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
+ * @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
@@ -1733,11 +1787,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
+ * @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
* @example
@@ -1770,16 +1824,18 @@
/**
* Iterates over elements of `collection`, returning an array of all elements
* `predicate` returns truthy for. The predicate is invoked with three
* arguments: (value, index|key, collection).
*
+ * **Note:** Unlike `_.remove`, this method returns a new array.
+ *
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
+ * @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.reject
* @example
*
@@ -1815,11 +1871,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
+ * @param {Function} [predicate=_.identity]
* The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example
*
@@ -1897,12 +1953,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
* @example
*
* function square(n) {
* return n * n;
@@ -2005,12 +2060,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
* @example
*
@@ -2048,12 +2102,12 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [iteratees=[_.identity]] The iteratees to sort by.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
* var users = [
* { 'user': 'fred', 'age': 48 },
@@ -2099,11 +2153,11 @@
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.
* @example
*
* jQuery(element).on('click', _.before(5, addContactToList));
- * // => allows adding up to 4 contacts to the list
+ * // => Allows adding up to 4 contacts to the list.
*/
function before(n, func) {
var result;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
@@ -2138,13 +2192,13 @@
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new bound function.
* @example
*
- * var greet = function(greeting, punctuation) {
+ * function greet(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation;
- * };
+ * }
*
* var object = { 'user': 'fred' };
*
* var bound = _.bind(greet, object, 'hi');
* bound('!');
@@ -2153,12 +2207,12 @@
* // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'
*/
- var bind = rest(function(func, thisArg, partials) {
- return createPartialWrapper(func, BIND_FLAG | PARTIAL_FLAG, thisArg, partials);
+ var bind = baseRest(function(func, thisArg, partials) {
+ return createPartial(func, BIND_FLAG | PARTIAL_FLAG, thisArg, partials);
});
/**
* Defers invoking the `func` until the current call stack has cleared. Any
* additional arguments are provided to `func` when it's invoked.
@@ -2175,11 +2229,11 @@
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
* // => Logs 'deferred' after one or more milliseconds.
*/
- var defer = rest(function(func, args) {
+ var defer = baseRest(function(func, args) {
return baseDelay(func, 1, args);
});
/**
* Invokes `func` after `wait` milliseconds. Any additional arguments are
@@ -2198,11 +2252,11 @@
* _.delay(function(text) {
* console.log(text);
* }, 1000, 'later');
* // => Logs 'later' after one second.
*/
- var delay = rest(function(func, wait, args) {
+ var delay = baseRest(function(func, wait, args) {
return baseDelay(func, toNumber(wait) || 0, args);
});
/**
* Creates a function that negates the result of the predicate `func`. The
@@ -2227,11 +2281,12 @@
function negate(predicate) {
if (typeof predicate != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
- return !predicate.apply(this, arguments);
+ var args = arguments;
+ return !predicate.apply(this, args);
};
}
/**
* Creates a function that is restricted to invoking `func` once. Repeat calls
@@ -2247,65 +2302,16 @@
* @example
*
* var initialize = _.once(createApplication);
* initialize();
* initialize();
- * // `initialize` invokes `createApplication` once
+ * // => `createApplication` is invoked once
*/
function once(func) {
return before(2, func);
}
- /**
- * Creates a function that invokes `func` with the `this` binding of the
- * created function and arguments from `start` and beyond provided as
- * an array.
- *
- * **Note:** This method is based on the
- * [rest parameter](https://mdn.io/rest_parameters).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Function
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var say = _.rest(function(what, names) {
- * return what + ' ' + _.initial(names).join(', ') +
- * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
- * });
- *
- * say('hello', 'fred', 'barney', 'pebbles');
- * // => 'hello fred, barney, & pebbles'
- */
- function rest(func, start) {
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
-
- while (++index < length) {
- array[index] = args[start + index];
- }
- var otherArgs = Array(start + 1);
- index = -1;
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = array;
- return func.apply(this, otherArgs);
- };
- }
-
/*------------------------------------------------------------------------*/
/**
* Creates a shallow clone of `value`.
*
@@ -2351,12 +2357,12 @@
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
@@ -2381,11 +2387,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
@@ -2403,15 +2409,13 @@
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
- * @type {Function}
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
@@ -2490,12 +2494,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
* @example
*
* _.isBoolean(false);
* // => true
*
@@ -2513,23 +2516,20 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
* @example
*
* _.isDate(new Date);
* // => true
*
* _.isDate('Mon April 23 2012');
* // => false
*/
- function isDate(value) {
- return isObjectLike(value) && objectToString.call(value) == dateTag;
- }
+ var isDate = baseIsDate;
/**
* Checks if `value` is an empty object, collection, map, or set.
*
* Objects are considered empty if they have no own enumerable string keyed
@@ -2589,12 +2589,12 @@
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent,
* else `false`.
* @example
*
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
@@ -2641,12 +2641,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
@@ -2816,12 +2815,11 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a number, else `false`.
* @example
*
* _.isNumber(3);
* // => true
*
@@ -2845,34 +2843,30 @@
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
* @example
*
* _.isRegExp(/abc/);
* // => true
*
* _.isRegExp('/abc/');
* // => false
*/
- function isRegExp(value) {
- return isObject(value) && objectToString.call(value) == regexpTag;
- }
+ var isRegExp = baseIsRegExp;
/**
* Checks if `value` is classified as a `String` primitive or object.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a string, else `false`.
* @example
*
* _.isString('abc');
* // => true
*
@@ -3035,22 +3029,22 @@
* @returns {Object} Returns `object`.
* @see _.assignIn
* @example
*
* function Foo() {
- * this.c = 3;
+ * this.a = 1;
* }
*
* function Bar() {
- * this.e = 5;
+ * this.c = 3;
* }
*
- * Foo.prototype.d = 4;
- * Bar.prototype.f = 6;
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
*
- * _.assign({ 'a': 1 }, new Foo, new Bar);
- * // => { 'a': 1, 'c': 3, 'e': 5 }
+ * _.assign({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'c': 3 }
*/
var assign = createAssigner(function(object, source) {
copyObject(source, keys(source), object);
});
@@ -3070,22 +3064,22 @@
* @returns {Object} Returns `object`.
* @see _.assign
* @example
*
* function Foo() {
- * this.b = 2;
+ * this.a = 1;
* }
*
* function Bar() {
- * this.d = 4;
+ * this.c = 3;
* }
*
- * Foo.prototype.c = 3;
- * Bar.prototype.e = 5;
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
*
- * _.assignIn({ 'a': 1 }, new Foo, new Bar);
- * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
+ * _.assignIn({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
*/
var assignIn = createAssigner(function(object, source) {
copyObject(source, keysIn(source), object);
});
@@ -3177,14 +3171,14 @@
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.defaultsDeep
* @example
*
- * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
- * // => { 'user': 'barney', 'age': 36 }
+ * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
*/
- var defaults = rest(function(args) {
+ var defaults = baseRest(function(args) {
args.push(undefined, assignInDefaults);
return assignInWith.apply(undefined, args);
});
/**
@@ -3288,11 +3282,11 @@
* var object = { 'a': 1, 'b': '2', 'c': 3 };
*
* _.pick(object, ['a', 'c']);
* // => { 'a': 1, 'c': 3 }
*/
- var pick = rest(function(object, props) {
+ var pick = baseRest(function(object, props) {
return object == null ? {} : basePick(object, baseMap(baseFlatten(props, 1), toKey));
});
/**
* This method is like `_.get` except that if the resolved value is a
@@ -3405,21 +3399,21 @@
}
/*------------------------------------------------------------------------*/
/**
- * This method returns the first argument given to it.
+ * This method returns the first argument it receives.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
- * var object = { 'user': 'fred' };
+ * var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
*/
function identity(value) {
@@ -3471,30 +3465,30 @@
var iteratee = baseIteratee;
/**
* Creates a function that performs a partial deep comparison between a given
* object and `source`, returning `true` if the given object has equivalent
- * property values, else `false`. The created function is equivalent to
- * `_.isMatch` with a `source` partially applied.
+ * property values, else `false`.
*
- * **Note:** This method supports comparing the same values as `_.isEqual`.
+ * **Note:** The created function supports comparing the same values as
+ * `_.isEqual` is equivalent to `_.isMatch` with `source` partially applied.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Util
* @param {Object} source The object of property values to match.
* @returns {Function} Returns the new spec function.
* @example
*
- * var users = [
- * { 'user': 'barney', 'age': 36, 'active': true },
- * { 'user': 'fred', 'age': 40, 'active': false }
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
* ];
*
- * _.filter(users, _.matches({ 'age': 40, 'active': false }));
- * // => [{ 'user': 'fred', 'age': 40, 'active': false }]
+ * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
+ * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
*/
function matches(source) {
return baseMatches(assign({}, source));
}
@@ -3589,11 +3583,11 @@
}
return this;
}
/**
- * A method that returns `undefined`.
+ * This method returns `undefined`.
*
* @static
* @memberOf _
* @since 2.3.0
* @category Util
@@ -3799,25 +3793,24 @@
// Add chain sequence methods to the `lodash` wrapper.
lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
/*--------------------------------------------------------------------------*/
- // Expose Lodash on the free variable `window` or `self` when available so it's
- // globally accessible, even when bundled with Browserify, Webpack, etc. This
- // also prevents errors in cases where Lodash is loaded by a script tag in the
- // presence of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch
- // for more details. Use `_.noConflict` to remove Lodash from the global object.
- (freeSelf || {})._ = lodash;
-
- // Some AMD build optimizers like r.js check for condition patterns like the following:
+ // Some AMD build optimizers, like r.js, check for condition patterns like:
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
+ // Expose Lodash on the global object to prevent errors when Lodash is
+ // loaded by a script tag in the presence of an AMD loader.
+ // See http://requirejs.org/docs/errors.html#mismatch for more details.
+ // Use `_.noConflict` to remove Lodash from the global object.
+ root._ = lodash;
+
// Define as an anonymous module so, through path mapping, it can be
// referenced as the "underscore" module.
define(function() {
return lodash;
});
}
- // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
+ // Check for `exports` after `define` in case a build optimizer adds it.
else if (freeModule) {
// Export for Node.js.
(freeModule.exports = lodash)._ = lodash;
// Export for CommonJS support.
freeExports._ = lodash;