diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index ef02e644a..75fd29c01 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -141,7 +141,7 @@ /*--------------------------------------------------------------------------*/ /** - * A base implementation of `_.indexOf` without support for binary searches + * The base implementation of `_.indexOf` without support for binary searches * or `fromIndex` constraints. * * @private @@ -493,6 +493,7 @@ propertyIsEnumerable = objectProto.propertyIsEnumerable, setImmediate = context.setImmediate, setTimeout = context.setTimeout, + splice = arrayRef.splice, toString = objectProto.toString, unshift = arrayRef.unshift; @@ -923,7 +924,7 @@ /*--------------------------------------------------------------------------*/ /** - * A base implementation of `_.clone` without argument juggling or support + * The base implementation of `_.clone` without argument juggling or support * for `thisArg` binding. * * @private @@ -1013,7 +1014,42 @@ } /** - * A base implementation of `_.flatten` without support for `callback` + * The base implementation of `_.createCallback` without support for creating + * "_.pluck" or "_.where" style callbacks. + * + * @private + * @param {Mixed} [func=identity] The value to convert to a callback. + * @param {Mixed} [thisArg] The `this` binding of the created callback. + * @param {Number} [argCount] The number of arguments the callback accepts. + * @returns {Function} Returns a callback function. + */ + function baseCreateCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + // exit early if there is no `thisArg` + if (typeof thisArg == 'undefined') { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 2: return function(a, b) { + return func.call(thisArg, a, b); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + } + return bind(func, thisArg); + } + + /** + * The base implementation of `_.flatten` without support for `callback` * shorthands or `thisArg` binding. * * @private @@ -1041,7 +1077,7 @@ } /** - * A base implementation of `_.isEqual`, without support for `thisArg` binding, + * The base implementation of `_.isEqual`, without support for `thisArg` binding, * that allows partial "_.where" style comparisons. * * @private @@ -1210,7 +1246,7 @@ } /** - * A base implementation of `_.merge` without argument juggling or support + * The base implementation of `_.merge` without argument juggling or support * for `thisArg` binding. * * @private @@ -1275,7 +1311,7 @@ } /** - * A base implementation of `_.uniq` without support for `callback` shorthands + * The base implementation of `_.uniq` without support for `callback` shorthands * or `thisArg` binding. * * @private @@ -1446,9 +1482,9 @@ // create the function factory var factory = Function( - 'errorClass, errorProto, hasOwnProperty, indicatorObject, isArguments, ' + - 'isArray, isString, keys, lodash, objectProto, objectTypes, nonEnumProps, ' + - 'stringClass, stringProto, toString', + 'baseCreateCallback, errorClass, errorProto, hasOwnProperty, ' + + 'indicatorObject, isArguments, isArray, isString, keys, objectProto, ' + + 'objectTypes, nonEnumProps, stringClass, stringProto, toString', 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' ); @@ -1456,9 +1492,9 @@ // return the compiled function return factory( - errorClass, errorProto, hasOwnProperty, indicatorObject, isArguments, - isArray, isString, data.keys, lodash, objectProto, objectTypes, nonEnumProps, - stringClass, stringProto, toString + baseCreateCallback, errorClass, errorProto, hasOwnProperty, + indicatorObject, isArguments, isArray, isString, data.keys, objectProto, + objectTypes, nonEnumProps, stringClass, stringProto, toString ); } @@ -1629,7 +1665,7 @@ * @private * @type Function * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. + * @returns {Array} Returns an array of property names. */ var shimKeys = createIterator({ 'args': 'object', @@ -1645,7 +1681,7 @@ * @memberOf _ * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. + * @returns {Array} Returns an array of property names. * @example * * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); @@ -1665,7 +1701,7 @@ /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ var eachIteratorOptions = { 'args': 'collection, callback, thisArg', - 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg, 3)", + 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)", 'array': "typeof length == 'number'", 'keys': keys, 'loop': 'if (callback(iterable[index], index, collection) === false) return result' @@ -1736,7 +1772,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object. Subsequent sources will overwrite property assignments of previous - * sources. If a `callback` function is passed, it will be executed to produce + * sources. If a `callback` function is provided, it will be executed to produce * the assigned values. The `callback` is bound to `thisArg` and invoked with * two arguments; (objectValue, sourceValue). * @@ -1768,7 +1804,7 @@ defaultsIteratorOptions.top.replace(';', ';\n' + "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" + - ' var callback = lodash.createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + + ' var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" + ' callback = args[--argsLength];\n' + '}' @@ -1779,7 +1815,7 @@ /** * Creates a clone of `value`. If `deep` is `true`, nested objects will also * be cloned, otherwise they will be assigned by reference. If a `callback` - * function is passed, it will be executed to produce the cloned values. If + * function is provided, it will be executed to produce the cloned values. If * `callback` returns `undefined`, cloning will be handled by the method instead. * The `callback` is bound to `thisArg` and invoked with one argument; (value). * @@ -1824,11 +1860,11 @@ callback = deep; deep = false; } - return baseClone(value, deep, typeof callback == 'function' && lodash.createCallback(callback, thisArg, 1)); + return baseClone(value, deep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); } /** - * Creates a deep clone of `value`. If a `callback` function is passed, + * Creates a deep clone of `value`. If a `callback` function is provided, * it will be executed to produce the cloned values. If `callback` returns * `undefined`, cloning will be handled by the method instead. The `callback` * is bound to `thisArg` and invoked with one argument; (value). @@ -1869,7 +1905,7 @@ * // => false */ function cloneDeep(value, callback, thisArg) { - return baseClone(value, true, typeof callback == 'function' && lodash.createCallback(callback, thisArg, 1)); + return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); } /** @@ -1903,8 +1939,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * iteration. If a property name or object is provided, it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the key of the found element, else `undefined`. * @example @@ -1935,8 +1971,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * iteration. If a property name or object is provided, it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the key of the found element, else `undefined`. * @example @@ -2026,7 +2062,7 @@ }); var length = pairs.length; - callback = lodash.createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); while (++index < length) { if (callback(pairs[index], pairs[++index], object) === false) { break; @@ -2080,7 +2116,7 @@ var props = keys(object), length = props.length; - callback = lodash.createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); while (length--) { var key = props[length]; if (callback(object[key], key, object) === false) { @@ -2099,7 +2135,7 @@ * @alias methods * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names that have function values. + * @returns {Array} Returns an array of property names that have function values. * @example * * _.functions(_); @@ -2253,7 +2289,7 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent to each other. If `callback` is passed, it will be executed to + * equivalent to each other. If `callback` is provided, it will be executed to * compare values. If `callback` returns `undefined`, comparisons will be handled * by the method instead. The `callback` is bound to `thisArg` and invoked with * two arguments; (a, b). @@ -2290,7 +2326,7 @@ * // => true */ function isEqual(a, b, callback, thisArg) { - return baseIsEqual(a, b, typeof callback == 'function' && lodash.createCallback(callback, thisArg, 2)); + return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2)); } /** @@ -2537,7 +2573,7 @@ * Recursively merges own enumerable properties of the source object(s), that * don't resolve to `undefined`, into the destination object. Subsequent sources * will overwrite property assignments of previous sources. If a `callback` function - * is passed, it will be executed to produce the merged values of the destination + * is provided, it will be executed to produce the merged values of the destination * and source properties. If `callback` returns `undefined`, merging will be * handled by the method instead. The `callback` is bound to `thisArg` and * invoked with two arguments; (objectValue, sourceValue). @@ -2597,7 +2633,7 @@ length = args.length; } if (length > 3 && typeof args[length - 2] == 'function') { - var callback = lodash.createCallback(args[--length - 1], args[length--], 2); + var callback = baseCreateCallback(args[--length - 1], args[length--], 2); } else if (length > 2 && typeof args[length - 1] == 'function') { callback = args[--length]; } @@ -2617,7 +2653,7 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a `callback` function is passed, it will be executed + * property names. If a `callback` function is provided, it will be executed * for each property in the `object`, omitting the properties `callback` * returns truthy for. The `callback` is bound to `thisArg` and invoked * with three arguments; (value, key, object). @@ -2691,7 +2727,7 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property - * names. If `callback` is passed, it will be executed for each property in the + * names. If `callback` is provided, it will be executed for each property in the * `object`, picking the properties `callback` returns truthy for. The `callback` * is bound to `thisArg` and invoked with three arguments; (value, key, object). * @@ -2771,7 +2807,7 @@ */ function transform(object, callback, accumulator, thisArg) { var isArr = isArray(object); - callback = lodash.createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); if (accumulator == null) { if (isArr) { @@ -2796,7 +2832,7 @@ * @memberOf _ * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property values. + * @returns {Array} Returns an array of property values. * @example * * _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -2908,10 +2944,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2919,9 +2955,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -2944,10 +2980,10 @@ * `collection`. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2956,9 +2992,9 @@ * @alias all * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if all elements pass the callback check, * else `false`. @@ -3006,10 +3042,10 @@ * the `callback` returns truthy for. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3018,9 +3054,9 @@ * @alias select * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that passed the callback check. * @example @@ -3070,10 +3106,10 @@ * `callback` returns truthy for. The `callback` is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3082,9 +3118,9 @@ * @alias detect, findWhere * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -3141,9 +3177,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -3230,7 +3266,7 @@ } else if (support.unindexedChars && isString(collection)) { iterable = collection.split(''); } - callback = lodash.createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; callback(iterable[index], index, collection); @@ -3245,10 +3281,10 @@ * the key. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false` * @@ -3256,9 +3292,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -3284,10 +3320,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3295,9 +3331,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -3360,10 +3396,10 @@ * through the `callback`. The `callback` is bound to `thisArg` and invoked with * three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3372,9 +3408,9 @@ * @alias collect * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of the results of each `callback` execution. * @example @@ -3413,15 +3449,15 @@ } /** - * Retrieves the maximum value of an `array`. If `callback` is passed, + * Retrieves the maximum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3429,9 +3465,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the maximum value. * @example @@ -3482,15 +3518,15 @@ } /** - * Retrieves the minimum value of an `array`. If `callback` is passed, + * Retrieves the minimum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3498,9 +3534,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the minimum value. * @example @@ -3604,7 +3640,7 @@ */ function reduce(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); if (isArray(collection)) { var index = -1, @@ -3647,7 +3683,7 @@ */ function reduceRight(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); forEachRight(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) @@ -3660,10 +3696,10 @@ * The opposite of `_.filter`, this method returns the elements of a * `collection` that `callback` does **not** return truthy for. * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3671,9 +3707,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that did **not** pass the * callback check. @@ -3702,6 +3738,65 @@ }); } + /** + * Removes all elements from the `collection` that thw `callback` returns truthy + * for and returns an array of removed elements. The `callback` is bound to + * `thisArg` and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback`, the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback`, the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|String} collection The collection to modify. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4, 5, 6]; + * var evens = _.remove(array, function(num) { return num % 2 == 0; }); + * + * console.log(array); + * // => [1, 3, 5] + * + * console.log(evens); + * // => [2, 4, 6] + */ + function remove(collection, callback, thisArg) { + var result = []; + callback = lodash.createCallback(callback, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + result.push(value); + splice.call(collection, index--, 1); + length--; + } + } + } else { + baseEach(collection, function(value, key, collection) { + if (callback(value, key, collection)) { + result.push(value); + delete collection[key]; + } + }); + } + return result; + } + /** * Creates an array of shuffled `array` values, using a version of the * Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -3760,10 +3855,10 @@ * does not iterate over the entire `collection`. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3772,9 +3867,9 @@ * @alias any * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if any element passes the callback check, * else `false`. @@ -3824,10 +3919,10 @@ * equal elements. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3835,9 +3930,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -4007,9 +4102,9 @@ * @memberOf _ * @category Arrays * @param {Array} array The array to search. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the index of the found element, else `-1`. * @example @@ -4040,9 +4135,9 @@ * @memberOf _ * @category Arrays * @param {Array} array The array to search. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the index of the found element, else `-1`. * @example @@ -4066,16 +4161,16 @@ } /** - * Gets the first element of the `array`. If a number `n` is passed, the first - * `n` elements of the `array` are returned. If a `callback` function is passed, + * Gets the first element of the `array`. If a number `n` is provided, the first + * `n` elements of the `array` are returned. If a `callback` function is provided, * elements at the beginning of the array are returned as long as the `callback` * returns truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4086,7 +4181,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the first element(s) of `array`. @@ -4146,14 +4241,14 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` * is truthy, `array` will only be flattened a single level. If `callback` - * is passed, each element of `array` is passed through a `callback` before + * is provided, each element of `array` is provided through a `callback` before * flattening. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4162,9 +4257,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {Boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -4233,16 +4328,16 @@ } /** - * Gets all but the last element of `array`. If a number `n` is passed, the + * Gets all but the last element of `array`. If a number `n` is provided, the * last `n` elements are excluded from the result. If a `callback` function - * is passed, elements at the end of the array are excluded from the result + * is provided, elements at the end of the array are excluded from the result * as long as the `callback` returns truthy. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4252,7 +4347,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -4367,17 +4462,17 @@ } /** - * Gets the last element of the `array`. If a number `n` is passed, the + * Gets the last element of the `array`. If a number `n` is provided, the * last `n` elements of the `array` are returned. If a `callback` function - * is passed, elements at the end of the array are returned as long as the + * is provided, elements at the end of the array are returned as long as the * `callback` returns truthy. The `callback` is bound to `thisArg` and * invoked with three arguments;(value, index, array). * * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4387,7 +4482,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the last element(s) of `array`. @@ -4477,6 +4572,42 @@ return -1; } + /** + * Removes all passed values from the given array using strict equality for + * comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to modify. + * @param {Mixed} [value1, value2, ...] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3, 1, 2, 3]; + * _.pull(array, 2, 3); + * console.log(array); + * // => [1, 1] + */ + function pull(array) { + var args = arguments, + argsIndex = 0, + argsLength = args.length, + length = array ? array.length : 0; + + while (++argsIndex < argsLength) { + var index = -1, + value = args[argsIndex]; + while (++index < length) { + if (array[index] === value) { + splice.call(array, index--, 1); + length--; + } + } + } + return array; + } + /** * Creates an array of numbers (positive and/or negative) progressing from * `start` up to but not including `end`. If `start` is less than `stop` a @@ -4529,16 +4660,16 @@ /** * The opposite of `_.initial`, this method gets all but the first value of - * `array`. If a number `n` is passed, the first `n` values are excluded from - * the result. If a `callback` function is passed, elements at the beginning + * `array`. If a number `n` is provided, the first `n` values are excluded from + * the result. If a `callback` function is provided, elements at the beginning * of the array are excluded from the result as long as the `callback` returns * truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4549,7 +4680,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -4604,14 +4735,14 @@ /** * Uses a binary search to determine the smallest index at which the `value` * should be inserted into `array` in order to maintain the sort order of the - * sorted `array`. If `callback` is passed, it will be executed for `value` and - * each element in `array` to compute their sort ranking. The `callback` is - * bound to `thisArg` and invoked with one argument; (value). + * sorted `array`. If `callback` is provided, it will be executed for `value` + * and each element in `array` to compute their sort ranking. The `callback` + * is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4620,9 +4751,9 @@ * @category Arrays * @param {Array} array The array to inspect. * @param {Mixed} value The value to evaluate. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Number} Returns the index at which the value should be inserted * into `array`. @@ -4687,14 +4818,15 @@ /** * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` - * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through the `callback` before uniqueness is computed. - * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). + * for `isSorted` will run a faster algorithm. If `callback` is provided, each + * element of `array` is provided through the `callback` before uniqueness is + * computed. The `callback` is bound to `thisArg` and invoked with three arguments; + * (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4704,9 +4836,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -4999,8 +5131,6 @@ * If `func` is an object, the created callback will return `true` for elements * that contain the equivalent object properties, otherwise it will return `false`. * - * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. - * * @static * @memberOf _ * @category Functions @@ -5025,76 +5155,42 @@ * * _.filter(stooges, 'age__gt45'); * // => [{ 'name': 'larry', 'age': 50 }] - * - * // create mixins with support for "_.pluck" and "_.where" callback shorthands - * _.mixin({ - * 'toLookup': function(collection, callback, thisArg) { - * callback = _.createCallback(callback, thisArg); - * return _.reduce(collection, function(result, value, index, collection) { - * return (result[callback(value, index, collection)] = value, result); - * }, {}); - * } - * }); - * - * _.toLookup(stooges, 'name'); - * // => { 'moe': { 'name': 'moe', 'age': 40 }, 'larry': { 'name': 'larry', 'age': 50 } } */ function createCallback(func, thisArg, argCount) { - if (func == null) { - return identity; - } var type = typeof func; - if (type != 'function') { - // handle "_.pluck" style callback shorthands - if (type != 'object') { - return function(object) { - return object[func]; - }; - } - var props = keys(func), - key = props[0], - a = func[key]; - - // handle "_.where" style callback shorthands - if (props.length == 1 && a === a && !isObject(a)) { - // fast path the common case of passing an object with a single - // property containing a primitive value - return function(object) { - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); - }; - } + if (func == null || type == 'function') { + return baseCreateCallback(func, thisArg, argCount); + } + // handle "_.pluck" style callback shorthands + if (type != 'object') { return function(object) { - var length = props.length, - result = false; + return object[func]; + }; + } + var props = keys(func), + key = props[0], + a = func[key]; - while (length--) { - if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { - break; - } + // handle "_.where" style callback shorthands + if (props.length == 1 && a === a && !isObject(a)) { + // fast path the common case of passing an object with a single + // property containing a primitive value + return function(object) { + var b = object[key]; + return a === b && (a !== 0 || (1 / a == 1 / b)); + }; + } + return function(object) { + var length = props.length, + result = false; + + while (length--) { + if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { + break; } - return result; - }; - } - // exit early if there is no `thisArg` - if (typeof thisArg == 'undefined') { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 2: return function(a, b) { - return func.call(thisArg, a, b); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - } - return bind(func, thisArg); + } + return result; + }; } /** @@ -5525,15 +5621,18 @@ * // => 'Moe' */ function mixin(object, source) { + var ctor = object, + isFunc = !source || isFunction(ctor); + if (!source) { + ctor = lodashWrapper; source = object; object = lodash; } - var isFunc = isFunction(object); forEach(functions(source), function(methodName) { var func = object[methodName] = source[methodName]; if (isFunc) { - object.prototype[methodName] = function() { + ctor.prototype[methodName] = function() { var value = this.__wrapped__, args = [value]; @@ -5541,7 +5640,7 @@ var result = func.apply(object, args); return (value && typeof value == 'object' && value === result) ? this - : new lodashWrapper(result); + : new ctor(result); }; } }); @@ -5590,7 +5689,8 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is passed, a number between `0` and the given number will be returned. + * argument is provided, a number between `0` and the given number will be + * returned. * * @static * @memberOf _ @@ -5854,7 +5954,7 @@ * @param {Number} n The number of times to execute the callback. * @param {Function} callback The function called per iteration. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of the results of each `callback` execution. + * @returns {Array} Returns an array of the results of each `callback` execution. * @example * * var diceRolls = _.times(3, _.partial(_.random, 1, 6)); @@ -5871,7 +5971,7 @@ var index = -1, result = Array(n); - callback = lodash.createCallback(callback, thisArg, 1); + callback = baseCreateCallback(callback, thisArg, 1); while (++index < n) { result[index] = callback(index); } @@ -5898,7 +5998,7 @@ } /** - * Generates a unique ID. If `prefix` is passed, the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided, the ID will be appended to it. * * @static * @memberOf _ @@ -6074,8 +6174,10 @@ lodash.partialRight = partialRight; lodash.pick = pick; lodash.pluck = pluck; + lodash.pull = pull; lodash.range = range; lodash.reject = reject; + lodash.remove = remove; lodash.rest = rest; lodash.shuffle = shuffle; lodash.sortBy = sortBy; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 79a68b54c..bbdcf6e37 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -3,51 +3,52 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=O&&i===t,v=u||s?c():l;if(s){var h=o(v);h?(i=e,v=h):(s=b,v=u?v:(p(v),l))}for(;++ai(v,y))&&((u||s)&&v.push(y),l.push(h))}return s?(p(v.b),g(v)):u&&p(v),l}function ut(n){return function(t,e,r){var u={};return e=_.createCallback(e,r,3),xt(t,function(t,r,a){r=ne(e(t,r,a)),n(u,t,r,a)}),u}}function at(n,t,e,r,u,a){var o=a&&!u; -if(!yt(n)&&!o)throw new te;if(u||a||r.length||!(Fe.fastBind||_e&&e.length))i=function(){var a=arguments,f=u?this:t;return o&&(n=t[c]),(e.length||r.length)&&(be.apply(a,e),ve.apply(a,r)),this instanceof i?(f=it(n.prototype),a=n.apply(f,a),mt(a)?a:f):n.apply(f,a)};else{a=[n,t],ve.apply(a,e);var i=_e.call.apply(_e,a)}if(o){var c=t;t=n}return i}function ot(){var n=f();n.h=q,n.b=n.c=n.g=n.i="",n.e="s",n.j=m;for(var t,e=0;t=arguments[e];e++)for(var r in t)n[r]=t[r];e=n.a,n.d=/^[^,]+/.exec(e)[0],t=Vt,e="return function("+e+"){",r="var m,s="+n.d+",D="+n.e+";if(!s)return D;"+n.i+";",n.b?(r+="var t=s.length;m=-1;if("+n.b+"){",Fe.unindexedChars&&(r+="if(r(s)){s=s.split('')}"),r+="while(++mk;k++)r+="m='"+n.h[k]+"';if((!(q&&w[m])&&l.call(s,m))",n.j||(r+="||(!w[m]&&s[m]!==z[m])"),r+="){"+n.g+"}"; -r+="}"}return(n.b||Fe.nonEnumArgs)&&(r+="}"),r+=n.c+";return D",t=t("i,j,l,n,o,p,r,u,v,z,A,x,H,I,K",e+r+"}"),g(n),t(J,re,ge,C,pt,Re,bt,n.f,_,ue,X,Ne,V,ae,de)}function it(n){return mt(n)?je(n):{}}function ct(n){return Ke[n]}function ft(){var n=(n=_.indexOf)===Nt?t:n;return n}function lt(n){var t,e;return!n||de.call(n)!=G||(t=n.constructor,yt(t)&&!(t instanceof t))||!Fe.argsClass&&pt(n)||!Fe.nodeClass&&l(n)?b:Fe.ownLast?(Ve(n,function(n,t,r){return e=ge.call(r,t),b}),e!==false):(Ve(n,function(n,t){e=t -}),e===y||ge.call(n,e))}function st(n){return We[n]}function pt(n){return n&&typeof n=="object"?de.call(n)==L:b}function gt(n,t,e){var r=ze(n),u=r.length;for(t=_.createCallback(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function vt(n){var t=[];return Ve(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function ht(n){for(var t=-1,e=ze(n),r=e.length,u={};++te?Oe(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(bt(n)?n.indexOf(t,e):u(n,t,e)):Me(n,function(n){return++ra&&(a=i) -}}else t=!t&&bt(n)?u:_.createCallback(t,e,3),Me(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function At(n,t,e,r){var u=3>arguments.length;if(t=_.createCallback(t,r,4),Re(n)){var a=-1,o=n.length;for(u&&(e=n[++a]);++aarguments.length;return t=_.createCallback(t,r,4),Ot(n,function(n,r,a){e=u?(u=b,n):t(e,n,r,a)}),e}function Dt(n,t,e){var r;if(t=_.createCallback(t,e,3),Re(n)){e=-1;for(var u=n.length;++e=O&&u===t;if(f){var l=o(i);l?(u=e,i=l):f=b}for(;++ru(i,l)&&c.push(l);return f&&g(i),c}function Pt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var a=-1;for(t=_.createCallback(t,e,3);++ar?Oe(0,u+r):r||0}else if(r)return r=Rt(n,e),n[r]===e?r:-1; -return n?t(n,e,r):-1}function Ft(n,t,e){if(typeof t!="number"&&t!=d){var r=0,u=-1,a=n?n.length:0;for(t=_.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tf&&(i=n.apply(c,o));else{var e=new Ut;!p&&!h&&(l=e);var r=s-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:_}},je||(it=function(n){if(mt(n)){s.prototype=n;var t=new s;s.prototype=d}return t||{}}),Fe.argsClass||(pt=function(n){return n&&typeof n=="object"?ge.call(n,"callee"):b});var Re=we||function(n){return n&&typeof n=="object"?de.call(n)==T:b},$e=ot({a:"y",e:"[]",i:"if(!(A[typeof y]))return D",g:"D.push(m)"}),ze=xe?function(n){return mt(n)?Fe.enumPrototypes&&typeof n=="function"||Fe.nonEnumArgs&&n.length&&pt(n)?$e(n):xe(n):[] -}:$e,qe={a:"f,d,J",i:"d=d&&typeof J=='undefined'?d:v.createCallback(d,J,3)",b:"typeof t=='number'",u:ze,g:"if(d(s[m],m,f)===false)return D"},Le={a:"y,G,k",i:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},We=ht(Ke),Je=Zt("("+ze(We).join("|")+")","g"),He=Zt("["+ze(Ke).join("")+"]","g"),Me=ot(qe),Ge=ot(Le,{i:Le.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=v.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),g:"D[m]=d?d(D[m],s[m]):s[m]"}),Ue=ot(Le),Ve=ot(qe,Te,{j:b}),Qe=ot(qe,Te); -yt(/x/)&&(yt=function(n){return typeof n=="function"&&de.call(n)==H});var Xe=pe?function(n){if(!n||de.call(n)!=G||!Fe.argsClass&&pt(n))return b;var t=n.valueOf,e=typeof t=="function"&&(e=pe(t))&&pe(e);return e?n==e||pe(n)==e:lt(n)}:lt,Ye=ut(function(n,t,e){ge.call(n,e)?n[e]++:n[e]=1}),Ze=ut(function(n,t,e){(ge.call(n,e)?n[e]:n[e]=[]).push(t)}),nr=ut(function(n,t,e){n[e]=t}),tr=Et;Be&&nt&&typeof ye=="function"&&(Kt=Lt(ye,r));var er=8==Se(S+"08")?Se:function(n,t){return Se(bt(n)?n.replace(F,""):n,t||0) -};return _.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},_.assign=Ge,_.at=function(n){var t=-1,e=Y(arguments,m,b,1),r=e.length,u=Mt(r);for(Fe.unindexedChars&&bt(n)&&(n=n.split(""));++t=O&&o(a?r[a]:h)}n:for(;++f(m?e(m,y):l(h,y))){for(a=u,(m||h).push(y);--a;)if(m=i[a],0>(m?e(m,y):l(r[a],y)))continue n;v.push(y)}}for(;u--;)(m=i[u])&&g(m);return p(i),p(h),v},_.invert=ht,_.invoke=function(n,t){var e=Ie.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Mt(typeof a=="number"?a:0);return xt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},_.keys=ze,_.map=Et,_.max=St,_.memoize=function(n,t){function e(){var r=e.cache,u=x+(t?t.apply(this,arguments):arguments[0]); -return ge.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},_.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},_.once=function(n){var t,e;return function(){return t?e:(t=m,e=n.apply(this,arguments),n=d,e)}},_.pairs=function(n){for(var t=-1,e=ze(n),r=e.length,u=Mt(r);++te?Oe(0,r+e):Ee(e,r-1))+1);r--;)if(n[r]===t)return r; -return-1},_.mixin=Jt,_.noConflict=function(){return r._=oe,this},_.parseInt=er,_.random=function(n,t){n==d&&t==d&&(t=1),n=+n||0,t==d?(t=n,n=0):t=+t||0;var e=Ae();return n%1||t%1?n+Ee(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+se(e*(t-n+1))},_.reduce=At,_.reduceRight=It,_.result=function(n,t){var e=n?n[t]:y;return yt(e)?n[t]():e},_.runInContext=h,_.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ze(n).length},_.some=Dt,_.sortedIndex=Rt,_.template=function(n,t,e){var r=_.templateSettings; -n||(n=""),e=Ue({},e,r);var u,a=Ue({},e.imports,r.imports),r=ze(a),a=_t(a),o=0,c=e.interpolate||R,f="__p+='",c=Zt((e.escape||R).source+"|"+c.source+"|"+(c===N?B:R).source+"|"+(e.evaluate||R).source+"|$","g");n.replace(c,function(t,e,r,a,c,l){return r||(r=a),f+=n.slice(o,l).replace($,i),e&&(f+="'+__e("+e+")+'"),c&&(u=m,f+="';"+c+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),o=l+t.length,t}),f+="';\n",c=e=e.variable,c||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(A,""):f).replace(I,"$1").replace(D,"$1;"),f="function("+e+"){"+(c?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; -try{var l=Vt(r,"return "+f).apply(y,a)}catch(s){throw s.source=f,s}return t?l(t):(l.source=f,l)},_.unescape=function(n){return n==d?"":ne(n).replace(Je,st)},_.uniqueId=function(n){var t=++w;return ne(n==d?"":n)+t},_.all=wt,_.any=Dt,_.detect=kt,_.findWhere=kt,_.foldl=At,_.foldr=It,_.include=jt,_.inject=At,Qe(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ve.apply(t,arguments),t=n.apply(_,t),e?new j(t,e):t})}),_.first=Pt,_.last=function(n,t,e){if(n){var r=0,u=n.length; -if(typeof t!="number"&&t!=d){var a=u;for(t=_.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,r==d||e)return n[u-1];return v(n,Oe(0,u-r))}},_.take=Pt,_.head=Pt,Qe(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e);return!r&&(t==d||e&&typeof t!="function")?u:new j(u,r)})}),_.VERSION="1.3.1",_.prototype.chain=function(){return this.__chain__=m,this},_.prototype.toString=function(){return ne(this.__wrapped__)},_.prototype.value=Ht,_.prototype.valueOf=Ht,Me(["join","pop","shift"],function(n){var t=ee[n]; -_.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new j(e,n):e}}),Me(["push","reverse","sort","unshift"],function(n){var t=ee[n];_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Me(["concat","slice","splice"],function(n){var t=ee[n];_.prototype[n]=function(){return new j(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Fe.spliceObjects||Me(["pop","shift","splice"],function(n){var t=ee[n],e="splice"==n;_.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments); -return 0===r.length&&delete r[0],n||e?new j(u,n):u}}),_}var y,m=!0,d=null,b=!1,_=[],j=[],w=0,C={},x=+new Date+"",O=75,E=40,S=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",A=/\b__p\+='';/g,I=/\b(__p\+=)''\+/g,D=/(__e\(.*?\)|\b__t\))\+'';/g,B=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,P=/\w*$/,N=/<%=([\s\S]+?)%>/g,F=RegExp("^["+S+"]*0+(?=.$)"),R=/($^)/,$=/['\n\r\t\u2028\u2029\\]/g,z="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),q="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),L="[object Arguments]",T="[object Array]",K="[object Boolean]",W="[object Date]",J="[object Error]",H="[object Function]",M="[object Number]",G="[object Object]",U="[object RegExp]",V="[object String]",Q={}; -Q[H]=b,Q[L]=Q[T]=Q[K]=Q[W]=Q[M]=Q[G]=Q[U]=Q[V]=m;var X={"boolean":b,"function":m,object:m,number:b,string:b,undefined:b},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof exports]&&exports,nt=X[typeof module]&&module&&module.exports==Z&&module,tt=X[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(n=tt);var et=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=et, define(function(){return et})):Z&&!Z.nodeType?nt?(nt.exports=et)._=et:Z._=et:n._=et +;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=E&&i===t,v=u||p?f():l; +if(p){var h=a(v);h?(i=e,v=h):(p=b,v=u?v:(s(v),l))}for(;++oi(v,y))&&((u||p)&&v.push(y),l.push(h))}return p?(s(v.b),g(v)):u&&s(v),l}function ot(n){return function(t,e,r){var u={};return e=_.createCallback(e,r,3),Et(t,function(t,r,o){r=te(e(t,r,o)),n(u,t,r,o)}),u}}function at(n,t,e,r,u,o){var a=o&&!u;if(!mt(n)&&!a)throw new ee;if(u||o||r.length||!($e.fastBind||we&&e.length))i=function(){var o=arguments,c=u?this:t;return a&&(n=t[f]),(e.length||r.length)&&(je.apply(o,e),he.apply(o,r)),this instanceof i?(c=ft(n.prototype),o=n.apply(c,o),dt(o)?o:c):n.apply(c,o) +};else{o=[n,t],he.apply(o,e);var i=we.call.apply(we,o)}if(a){var f=t;t=n}return i}function it(){var n=c();n.h=L,n.b=n.c=n.g=n.i="",n.e="t",n.j=m;for(var t,e=0;t=arguments[e];e++)for(var r in t)n[r]=t[r];e=n.a,n.d=/^[^,]+/.exec(e)[0],t=Qt,e="return function("+e+"){",r="var n,t="+n.d+",E="+n.e+";if(!t)return E;"+n.i+";",n.b?(r+="var u=t.length;n=-1;if("+n.b+"){",$e.unindexedChars&&(r+="if(s(t)){t=t.split('')}"),r+="while(++nk;k++)r+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+n.g+"}"; +r+="}"}return(n.b||$e.nonEnumArgs)&&(r+="}"),r+=n.c+";return E",t=t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",e+r+"}"),g(n),t(Y,G,ue,ve,x,gt,ze,_t,n.f,oe,X,De,V,ae,_e)}function ft(n){return dt(n)?ke(n):{}}function ct(n){return Ge[n]}function lt(){var n=(n=_.indexOf)===Rt?t:n;return n}function pt(n){var t,e;return!n||_e.call(n)!=H||(t=n.constructor,mt(t)&&!(t instanceof t))||!$e.argsClass&>(n)||!$e.nodeClass&&l(n)?b:$e.ownLast?(Xe(n,function(n,t,r){return e=ve.call(r,t),b}),e!==false):(Xe(n,function(n,t){e=t +}),e===y||ve.call(n,e))}function st(n){return Je[n]}function gt(n){return n&&typeof n=="object"?_e.call(n)==T:b}function vt(n,t,e){var r=Te(n),u=r.length;for(t=Y(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function ht(n){var t=[];return Xe(n,function(n,e){mt(n)&&t.push(e)}),t.sort()}function yt(n){for(var t=-1,e=Te(n),r=e.length,u={};++te?Se(0,o+e):e)||0,o&&typeof o=="number"?a=-1<(_t(n)?n.indexOf(t,e):u(n,t,e)):Ue(n,function(n){return++ro&&(o=i)}}else t=!t&&_t(n)?u:_.createCallback(t,e,3),Ue(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,o=n) +});return o}function It(n,t,e,r){var u=3>arguments.length;if(t=Y(t,r,4),ze(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=Y(t,r,4),Ot(n,function(n,r,o){e=u?(u=b,n):t(e,n,r,o)}),e}function Pt(n,t,e){var r;if(t=_.createCallback(t,e,3),ze(n)){e=-1;for(var u=n.length;++e=E&&u===t; +if(c){var l=a(i);l?(u=e,i=l):c=b}for(;++ru(i,l)&&f.push(l);return c&&g(i),f}function Ft(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var o=-1;for(t=_.createCallback(t,e,3);++or?Se(0,u+r):r||0}else if(r)return r=$t(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Dt(n,t,e){if(typeof t!="number"&&t!=d){var r=0,u=-1,o=n?n.length:0; +for(t=_.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tc&&(i=n.apply(f,a)); +else{var e=new Vt;!s&&!h&&(l=e);var r=p-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:_}},ke||(ft=function(n){if(dt(n)){p.prototype=n;var t=new p;p.prototype=d}return t||{}}),$e.argsClass||(gt=function(n){return n&&typeof n=="object"?ve.call(n,"callee"):b});var ze=xe||function(n){return n&&typeof n=="object"?_e.call(n)==q:b},Le=it({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Te=Oe?function(n){return dt(n)?$e.enumPrototypes&&typeof n=="function"||$e.nonEnumArgs&&n.length&>(n)?Le(n):Oe(n):[] +}:Le,qe={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:Te,g:"if(e(t[n],n,g)===false)return E"},Ke={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Je=yt(Ge),Me=ne("("+Te(Je).join("|")+")","g"),He=ne("["+Te(Ge).join("")+"]","g"),Ue=it(qe),Ve=it(Ke,{i:Ke.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),Qe=it(Ke),Xe=it(qe,We,{j:b}),Ye=it(qe,We); +mt(/x/)&&(mt=function(n){return typeof n=="function"&&_e.call(n)==J});var Ze=ge?function(n){if(!n||_e.call(n)!=H||!$e.argsClass&>(n))return b;var t=n.valueOf,e=typeof t=="function"&&(e=ge(t))&&ge(e);return e?n==e||ge(n)==e:pt(n)}:pt,nr=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1}),tr=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),er=ot(function(n,t,e){n[e]=t}),rr=St;Fe&&nt&&typeof me=="function"&&(Wt=qt(me,r));var ur=8==Ie(S+"08")?Ie:function(n,t){return Ie(_t(n)?n.replace(R,""):n,t||0) +};return _.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},_.assign=Ve,_.at=function(n){var t=-1,e=Z(arguments,m,b,1),r=e.length,u=Ht(r);for($e.unindexedChars&&_t(n)&&(n=n.split(""));++t=E&&a(o?r[o]:h)}n:for(;++c(m?e(m,y):l(h,y))){for(o=u,(m||h).push(y);--o;)if(m=i[o],0>(m?e(m,y):l(r[o],y)))continue n; +v.push(y)}}for(;u--;)(m=i[u])&&g(m);return s(i),s(h),v},_.invert=yt,_.invoke=function(n,t){var e=Pe.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0);return Et(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},_.keys=Te,_.map=St,_.max=At,_.memoize=function(n,t){function e(){var r=e.cache,u=C+(t?t.apply(this,arguments):arguments[0]);return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},_.merge=function(n){var t=arguments,e=2;if(!dt(n))return n; +if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},_.once=function(n){var t,e;return function(){return t?e:(t=m,e=n.apply(this,arguments),n=d,e)}},_.pairs=function(n){for(var t=-1,e=Te(n),r=e.length,u=Ht(r);++te?Se(0,r+e):Ae(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},_.mixin=Jt,_.noConflict=function(){return r._=ie,this},_.parseInt=ur,_.random=function(n,t){n==d&&t==d&&(t=1),n=+n||0,t==d?(t=n,n=0):t=+t||0;var e=Be();return n%1||t%1?n+Ae(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+se(e*(t-n+1))},_.reduce=It,_.reduceRight=Bt,_.result=function(n,t){var e=n?n[t]:y; +return mt(e)?n[t]():e},_.runInContext=h,_.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Te(n).length},_.some=Pt,_.sortedIndex=$t,_.template=function(n,t,e){var r=_.templateSettings;n||(n=""),e=Qe({},e,r);var u,o=Qe({},e.imports,r.imports),r=Te(o),o=jt(o),a=0,f=e.interpolate||D,c="__p+='",f=ne((e.escape||D).source+"|"+f.source+"|"+(f===F?P:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(f,function(t,e,r,o,f,l){return r||(r=o),c+=n.slice(a,l).replace($,i),e&&(c+="'+__e("+e+")+'"),f&&(u=m,c+="';"+f+";__p+='"),r&&(c+="'+((__t=("+r+"))==null?'':__t)+'"),a=l+t.length,t +}),c+="';\n",f=e=e.variable,f||(e="obj",c="with("+e+"){"+c+"}"),c=(u?c.replace(A,""):c).replace(I,"$1").replace(B,"$1;"),c="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Qt(r,"return "+c).apply(y,o)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},_.unescape=function(n){return n==d?"":te(n).replace(Me,st)},_.uniqueId=function(n){var t=++w;return te(n==d?"":n)+t +},_.all=kt,_.any=Pt,_.detect=Ct,_.findWhere=Ct,_.foldl=It,_.foldr=Bt,_.include=wt,_.inject=It,Ye(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return he.apply(t,arguments),t=n.apply(_,t),e?new j(t,e):t})}),_.first=Ft,_.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var o=u;for(t=_.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,r==d||e)return n[u-1];return v(n,Se(0,u-r))}},_.take=Ft,_.head=Ft,Ye(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e); +return!r&&(t==d||e&&typeof t!="function")?u:new j(u,r)})}),_.VERSION="1.3.1",_.prototype.chain=function(){return this.__chain__=m,this},_.prototype.toString=function(){return te(this.__wrapped__)},_.prototype.value=Mt,_.prototype.valueOf=Mt,Ue(["join","pop","shift"],function(n){var t=re[n];_.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new j(e,n):e}}),Ue(["push","reverse","sort","unshift"],function(n){var t=re[n];_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}}),Ue(["concat","slice","splice"],function(n){var t=re[n];_.prototype[n]=function(){return new j(t.apply(this.__wrapped__,arguments),this.__chain__)}}),$e.spliceObjects||Ue(["pop","shift","splice"],function(n){var t=re[n],e="splice"==n;_.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new j(u,n):u}}),_}var y,m=!0,d=null,b=!1,_=[],j=[],w=0,x={},C=+new Date+"",E=75,O=40,S=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",A=/\b__p\+='';/g,I=/\b(__p\+=)''\+/g,B=/(__e\(.*?\)|\b__t\))\+'';/g,P=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,N=/\w*$/,F=/<%=([\s\S]+?)%>/g,R=RegExp("^["+S+"]*0+(?=.$)"),D=/($^)/,$=/['\n\r\t\u2028\u2029\\]/g,z="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),L="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),T="[object Arguments]",q="[object Array]",K="[object Boolean]",W="[object Date]",G="[object Error]",J="[object Function]",M="[object Number]",H="[object Object]",U="[object RegExp]",V="[object String]",Q={}; +Q[J]=b,Q[T]=Q[q]=Q[K]=Q[W]=Q[M]=Q[H]=Q[U]=Q[V]=m;var X={"boolean":b,"function":m,object:m,number:b,string:b,undefined:b},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof exports]&&exports,nt=X[typeof module]&&module&&module.exports==Z&&module,tt=X[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(n=tt);var et=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=et, define(function(){return et})):Z&&!Z.nodeType?nt?(nt.exports=et)._=et:Z._=et:n._=et }(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 0b6b5f1e4..79ed1f5c9 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -134,7 +134,7 @@ /*--------------------------------------------------------------------------*/ /** - * A base implementation of `_.indexOf` without support for binary searches + * The base implementation of `_.indexOf` without support for binary searches * or `fromIndex` constraints. * * @private @@ -461,6 +461,7 @@ push = arrayRef.push, setImmediate = context.setImmediate, setTimeout = context.setTimeout, + splice = arrayRef.splice, toString = objectProto.toString, unshift = arrayRef.unshift; @@ -657,7 +658,7 @@ /*--------------------------------------------------------------------------*/ /** - * A base implementation of `_.clone` without argument juggling or support + * The base implementation of `_.clone` without argument juggling or support * for `thisArg` binding. * * @private @@ -747,7 +748,52 @@ } /** - * A base implementation of `_.flatten` without support for `callback` + * The base implementation of `_.createCallback` without support for creating + * "_.pluck" or "_.where" style callbacks. + * + * @private + * @param {Mixed} [func=identity] The value to convert to a callback. + * @param {Mixed} [thisArg] The `this` binding of the created callback. + * @param {Number} [argCount] The number of arguments the callback accepts. + * @returns {Function} Returns a callback function. + */ + function baseCreateCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + // exit early if there is no `thisArg` + if (typeof thisArg == 'undefined') { + return func; + } + var bindData = !func.name || func.__bindData__; + if (typeof bindData == 'undefined') { + // checks if `func` references the `this` keyword and stores the result + bindData = !reThis || reThis.test(fnToString.call(func)); + setBindData(func, bindData); + } + // exit early if there are no `this` references or `func` is bound + if (bindData !== true && !(bindData && bindData[4])) { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 2: return function(a, b) { + return func.call(thisArg, a, b); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + } + return bind(func, thisArg); + } + + /** + * The base implementation of `_.flatten` without support for `callback` * shorthands or `thisArg` binding. * * @private @@ -775,7 +821,7 @@ } /** - * A base implementation of `_.isEqual`, without support for `thisArg` binding, + * The base implementation of `_.isEqual`, without support for `thisArg` binding, * that allows partial "_.where" style comparisons. * * @private @@ -944,7 +990,7 @@ } /** - * A base implementation of `_.merge` without argument juggling or support + * The base implementation of `_.merge` without argument juggling or support * for `thisArg` binding. * * @private @@ -1009,7 +1055,7 @@ } /** - * A base implementation of `_.uniq` without support for `callback` shorthands + * The base implementation of `_.uniq` without support for `callback` shorthands * or `thisArg` binding. * * @private @@ -1296,7 +1342,7 @@ * @private * @type Function * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. + * @returns {Array} Returns an array of property names. */ var shimKeys = function(object) { var index, iterable = object, result = []; @@ -1317,7 +1363,7 @@ * @memberOf _ * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. + * @returns {Array} Returns an array of property names. * @example * * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); @@ -1358,7 +1404,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object. Subsequent sources will overwrite property assignments of previous - * sources. If a `callback` function is passed, it will be executed to produce + * sources. If a `callback` function is provided, it will be executed to produce * the assigned values. The `callback` is bound to `thisArg` and invoked with * two arguments; (objectValue, sourceValue). * @@ -1392,7 +1438,7 @@ argsIndex = 0, argsLength = typeof guard == 'number' ? 2 : args.length; if (argsLength > 3 && typeof args[argsLength - 2] == 'function') { - var callback = lodash.createCallback(args[--argsLength - 1], args[argsLength--], 2); + var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2); } else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') { callback = args[--argsLength]; } @@ -1415,7 +1461,7 @@ /** * Creates a clone of `value`. If `deep` is `true`, nested objects will also * be cloned, otherwise they will be assigned by reference. If a `callback` - * function is passed, it will be executed to produce the cloned values. If + * function is provided, it will be executed to produce the cloned values. If * `callback` returns `undefined`, cloning will be handled by the method instead. * The `callback` is bound to `thisArg` and invoked with one argument; (value). * @@ -1460,11 +1506,11 @@ callback = deep; deep = false; } - return baseClone(value, deep, typeof callback == 'function' && lodash.createCallback(callback, thisArg, 1)); + return baseClone(value, deep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); } /** - * Creates a deep clone of `value`. If a `callback` function is passed, + * Creates a deep clone of `value`. If a `callback` function is provided, * it will be executed to produce the cloned values. If `callback` returns * `undefined`, cloning will be handled by the method instead. The `callback` * is bound to `thisArg` and invoked with one argument; (value). @@ -1505,7 +1551,7 @@ * // => false */ function cloneDeep(value, callback, thisArg) { - return baseClone(value, true, typeof callback == 'function' && lodash.createCallback(callback, thisArg, 1)); + return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); } /** @@ -1559,8 +1605,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * iteration. If a property name or object is provided, it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the key of the found element, else `undefined`. * @example @@ -1591,8 +1637,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * iteration. If a property name or object is provided, it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the key of the found element, else `undefined`. * @example @@ -1647,7 +1693,7 @@ var index, iterable = collection, result = iterable; if (!iterable) return result; if (!objectTypes[typeof iterable]) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg, 3); + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); for (index in iterable) { if (callback(iterable[index], index, collection) === false) return result; } @@ -1689,7 +1735,7 @@ }); var length = pairs.length; - callback = lodash.createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); while (++index < length) { if (callback(pairs[index], pairs[++index], object) === false) { break; @@ -1723,7 +1769,7 @@ var index, iterable = collection, result = iterable; if (!iterable) return result; if (!objectTypes[typeof iterable]) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg, 3); + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); var ownIndex = -1, ownProps = objectTypes[typeof iterable] && keys(iterable), length = ownProps ? ownProps.length : 0; @@ -1757,7 +1803,7 @@ var props = keys(object), length = props.length; - callback = lodash.createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); while (length--) { var key = props[length]; if (callback(object[key], key, object) === false) { @@ -1776,7 +1822,7 @@ * @alias methods * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names that have function values. + * @returns {Array} Returns an array of property names that have function values. * @example * * _.functions(_); @@ -1929,7 +1975,7 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent to each other. If `callback` is passed, it will be executed to + * equivalent to each other. If `callback` is provided, it will be executed to * compare values. If `callback` returns `undefined`, comparisons will be handled * by the method instead. The `callback` is bound to `thisArg` and invoked with * two arguments; (a, b). @@ -1966,7 +2012,7 @@ * // => true */ function isEqual(a, b, callback, thisArg) { - return baseIsEqual(a, b, typeof callback == 'function' && lodash.createCallback(callback, thisArg, 2)); + return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2)); } /** @@ -2207,7 +2253,7 @@ * Recursively merges own enumerable properties of the source object(s), that * don't resolve to `undefined`, into the destination object. Subsequent sources * will overwrite property assignments of previous sources. If a `callback` function - * is passed, it will be executed to produce the merged values of the destination + * is provided, it will be executed to produce the merged values of the destination * and source properties. If `callback` returns `undefined`, merging will be * handled by the method instead. The `callback` is bound to `thisArg` and * invoked with two arguments; (objectValue, sourceValue). @@ -2267,7 +2313,7 @@ length = args.length; } if (length > 3 && typeof args[length - 2] == 'function') { - var callback = lodash.createCallback(args[--length - 1], args[length--], 2); + var callback = baseCreateCallback(args[--length - 1], args[length--], 2); } else if (length > 2 && typeof args[length - 1] == 'function') { callback = args[--length]; } @@ -2287,7 +2333,7 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a `callback` function is passed, it will be executed + * property names. If a `callback` function is provided, it will be executed * for each property in the `object`, omitting the properties `callback` * returns truthy for. The `callback` is bound to `thisArg` and invoked * with three arguments; (value, key, object). @@ -2361,7 +2407,7 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property - * names. If `callback` is passed, it will be executed for each property in the + * names. If `callback` is provided, it will be executed for each property in the * `object`, picking the properties `callback` returns truthy for. The `callback` * is bound to `thisArg` and invoked with three arguments; (value, key, object). * @@ -2441,7 +2487,7 @@ */ function transform(object, callback, accumulator, thisArg) { var isArr = isArray(object); - callback = lodash.createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); if (accumulator == null) { if (isArr) { @@ -2466,7 +2512,7 @@ * @memberOf _ * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property values. + * @returns {Array} Returns an array of property values. * @example * * _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -2575,10 +2621,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2586,9 +2632,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -2611,10 +2657,10 @@ * `collection`. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2623,9 +2669,9 @@ * @alias all * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if all elements pass the callback check, * else `false`. @@ -2673,10 +2719,10 @@ * the `callback` returns truthy for. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2685,9 +2731,9 @@ * @alias select * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that passed the callback check. * @example @@ -2737,10 +2783,10 @@ * `callback` returns truthy for. The `callback` is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2749,9 +2795,9 @@ * @alias detect, findWhere * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -2808,9 +2854,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -2858,7 +2904,7 @@ var index = -1, length = collection ? collection.length : 0; - callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg, 3); + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); if (typeof length == 'number') { while (++index < length) { if (callback(collection[index], index, collection) === false) { @@ -2895,10 +2941,8 @@ if (typeof length != 'number') { var props = keys(collection); length = props.length; - } else if (support.unindexedChars && isString(collection)) { - iterable = collection.split(''); } - callback = lodash.createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; callback(iterable[index], index, collection); @@ -2913,10 +2957,10 @@ * the key. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false` * @@ -2924,9 +2968,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -2952,10 +2996,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2963,9 +3007,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -3028,10 +3072,10 @@ * through the `callback`. The `callback` is bound to `thisArg` and invoked with * three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3040,9 +3084,9 @@ * @alias collect * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of the results of each `callback` execution. * @example @@ -3082,15 +3126,15 @@ } /** - * Retrieves the maximum value of an `array`. If `callback` is passed, + * Retrieves the maximum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3098,9 +3142,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the maximum value. * @example @@ -3151,15 +3195,15 @@ } /** - * Retrieves the minimum value of an `array`. If `callback` is passed, + * Retrieves the minimum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3167,9 +3211,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the minimum value. * @example @@ -3285,7 +3329,7 @@ function reduce(collection, callback, accumulator, thisArg) { if (!collection) return accumulator; var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); var index = -1, length = collection.length; @@ -3328,7 +3372,7 @@ */ function reduceRight(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); forEachRight(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) @@ -3341,10 +3385,10 @@ * The opposite of `_.filter`, this method returns the elements of a * `collection` that `callback` does **not** return truthy for. * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3352,9 +3396,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that did **not** pass the * callback check. @@ -3383,6 +3427,65 @@ }); } + /** + * Removes all elements from the `collection` that thw `callback` returns truthy + * for and returns an array of removed elements. The `callback` is bound to + * `thisArg` and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback`, the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback`, the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|String} collection The collection to modify. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4, 5, 6]; + * var evens = _.remove(array, function(num) { return num % 2 == 0; }); + * + * console.log(array); + * // => [1, 3, 5] + * + * console.log(evens); + * // => [2, 4, 6] + */ + function remove(collection, callback, thisArg) { + var result = []; + callback = lodash.createCallback(callback, thisArg, 3); + + var index = -1, + length = collection ? collection.length : 0; + + if (typeof length == 'number') { + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + result.push(value); + splice.call(collection, index--, 1); + length--; + } + } + } else { + forOwn(collection, function(value, key, collection) { + if (callback(value, key, collection)) { + result.push(value); + delete collection[key]; + } + }); + } + return result; + } + /** * Creates an array of shuffled `array` values, using a version of the * Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -3441,10 +3544,10 @@ * does not iterate over the entire `collection`. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3453,9 +3556,9 @@ * @alias any * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if any element passes the callback check, * else `false`. @@ -3505,10 +3608,10 @@ * equal elements. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3516,9 +3619,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -3686,9 +3789,9 @@ * @memberOf _ * @category Arrays * @param {Array} array The array to search. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the index of the found element, else `-1`. * @example @@ -3719,9 +3822,9 @@ * @memberOf _ * @category Arrays * @param {Array} array The array to search. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the index of the found element, else `-1`. * @example @@ -3745,16 +3848,16 @@ } /** - * Gets the first element of the `array`. If a number `n` is passed, the first - * `n` elements of the `array` are returned. If a `callback` function is passed, + * Gets the first element of the `array`. If a number `n` is provided, the first + * `n` elements of the `array` are returned. If a `callback` function is provided, * elements at the beginning of the array are returned as long as the `callback` * returns truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3765,7 +3868,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the first element(s) of `array`. @@ -3825,14 +3928,14 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` * is truthy, `array` will only be flattened a single level. If `callback` - * is passed, each element of `array` is passed through a `callback` before + * is provided, each element of `array` is provided through a `callback` before * flattening. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3841,9 +3944,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {Boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -3912,16 +4015,16 @@ } /** - * Gets all but the last element of `array`. If a number `n` is passed, the + * Gets all but the last element of `array`. If a number `n` is provided, the * last `n` elements are excluded from the result. If a `callback` function - * is passed, elements at the end of the array are excluded from the result + * is provided, elements at the end of the array are excluded from the result * as long as the `callback` returns truthy. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3931,7 +4034,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -4046,17 +4149,17 @@ } /** - * Gets the last element of the `array`. If a number `n` is passed, the + * Gets the last element of the `array`. If a number `n` is provided, the * last `n` elements of the `array` are returned. If a `callback` function - * is passed, elements at the end of the array are returned as long as the + * is provided, elements at the end of the array are returned as long as the * `callback` returns truthy. The `callback` is bound to `thisArg` and * invoked with three arguments;(value, index, array). * * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4066,7 +4169,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the last element(s) of `array`. @@ -4156,6 +4259,42 @@ return -1; } + /** + * Removes all passed values from the given array using strict equality for + * comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to modify. + * @param {Mixed} [value1, value2, ...] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3, 1, 2, 3]; + * _.pull(array, 2, 3); + * console.log(array); + * // => [1, 1] + */ + function pull(array) { + var args = arguments, + argsIndex = 0, + argsLength = args.length, + length = array ? array.length : 0; + + while (++argsIndex < argsLength) { + var index = -1, + value = args[argsIndex]; + while (++index < length) { + if (array[index] === value) { + splice.call(array, index--, 1); + length--; + } + } + } + return array; + } + /** * Creates an array of numbers (positive and/or negative) progressing from * `start` up to but not including `end`. If `start` is less than `stop` a @@ -4208,16 +4347,16 @@ /** * The opposite of `_.initial`, this method gets all but the first value of - * `array`. If a number `n` is passed, the first `n` values are excluded from - * the result. If a `callback` function is passed, elements at the beginning + * `array`. If a number `n` is provided, the first `n` values are excluded from + * the result. If a `callback` function is provided, elements at the beginning * of the array are excluded from the result as long as the `callback` returns * truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4228,7 +4367,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -4283,14 +4422,14 @@ /** * Uses a binary search to determine the smallest index at which the `value` * should be inserted into `array` in order to maintain the sort order of the - * sorted `array`. If `callback` is passed, it will be executed for `value` and - * each element in `array` to compute their sort ranking. The `callback` is - * bound to `thisArg` and invoked with one argument; (value). + * sorted `array`. If `callback` is provided, it will be executed for `value` + * and each element in `array` to compute their sort ranking. The `callback` + * is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4299,9 +4438,9 @@ * @category Arrays * @param {Array} array The array to inspect. * @param {Mixed} value The value to evaluate. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Number} Returns the index at which the value should be inserted * into `array`. @@ -4366,14 +4505,15 @@ /** * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` - * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through the `callback` before uniqueness is computed. - * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). + * for `isSorted` will run a faster algorithm. If `callback` is provided, each + * element of `array` is provided through the `callback` before uniqueness is + * computed. The `callback` is bound to `thisArg` and invoked with three arguments; + * (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4383,9 +4523,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -4678,8 +4818,6 @@ * If `func` is an object, the created callback will return `true` for elements * that contain the equivalent object properties, otherwise it will return `false`. * - * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. - * * @static * @memberOf _ * @category Functions @@ -4704,86 +4842,42 @@ * * _.filter(stooges, 'age__gt45'); * // => [{ 'name': 'larry', 'age': 50 }] - * - * // create mixins with support for "_.pluck" and "_.where" callback shorthands - * _.mixin({ - * 'toLookup': function(collection, callback, thisArg) { - * callback = _.createCallback(callback, thisArg); - * return _.reduce(collection, function(result, value, index, collection) { - * return (result[callback(value, index, collection)] = value, result); - * }, {}); - * } - * }); - * - * _.toLookup(stooges, 'name'); - * // => { 'moe': { 'name': 'moe', 'age': 40 }, 'larry': { 'name': 'larry', 'age': 50 } } */ function createCallback(func, thisArg, argCount) { - if (func == null) { - return identity; - } var type = typeof func; - if (type != 'function') { - // handle "_.pluck" style callback shorthands - if (type != 'object') { - return function(object) { - return object[func]; - }; - } - var props = keys(func), - key = props[0], - a = func[key]; - - // handle "_.where" style callback shorthands - if (props.length == 1 && a === a && !isObject(a)) { - // fast path the common case of passing an object with a single - // property containing a primitive value - return function(object) { - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); - }; - } + if (func == null || type == 'function') { + return baseCreateCallback(func, thisArg, argCount); + } + // handle "_.pluck" style callback shorthands + if (type != 'object') { return function(object) { - var length = props.length, - result = false; + return object[func]; + }; + } + var props = keys(func), + key = props[0], + a = func[key]; - while (length--) { - if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { - break; - } + // handle "_.where" style callback shorthands + if (props.length == 1 && a === a && !isObject(a)) { + // fast path the common case of passing an object with a single + // property containing a primitive value + return function(object) { + var b = object[key]; + return a === b && (a !== 0 || (1 / a == 1 / b)); + }; + } + return function(object) { + var length = props.length, + result = false; + + while (length--) { + if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { + break; } - return result; - }; - } - // exit early if there is no `thisArg` - if (typeof thisArg == 'undefined') { - return func; - } - var bindData = !func.name || func.__bindData__; - if (typeof bindData == 'undefined') { - // checks if `func` references the `this` keyword and stores the result - bindData = !reThis || reThis.test(fnToString.call(func)); - setBindData(func, bindData); - } - // exit early if there are no `this` references or `func` is bound - if (bindData !== true && !(bindData && bindData[4])) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 2: return function(a, b) { - return func.call(thisArg, a, b); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - } - return bind(func, thisArg); + } + return result; + }; } /** @@ -5214,15 +5308,18 @@ * // => 'Moe' */ function mixin(object, source) { + var ctor = object, + isFunc = !source || isFunction(ctor); + if (!source) { + ctor = lodashWrapper; source = object; object = lodash; } - var isFunc = isFunction(object); forEach(functions(source), function(methodName) { var func = object[methodName] = source[methodName]; if (isFunc) { - object.prototype[methodName] = function() { + ctor.prototype[methodName] = function() { var value = this.__wrapped__, args = [value]; @@ -5230,7 +5327,7 @@ var result = func.apply(object, args); return (value && typeof value == 'object' && value === result) ? this - : new lodashWrapper(result); + : new ctor(result); }; } }); @@ -5279,7 +5376,8 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is passed, a number between `0` and the given number will be returned. + * argument is provided, a number between `0` and the given number will be + * returned. * * @static * @memberOf _ @@ -5543,7 +5641,7 @@ * @param {Number} n The number of times to execute the callback. * @param {Function} callback The function called per iteration. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of the results of each `callback` execution. + * @returns {Array} Returns an array of the results of each `callback` execution. * @example * * var diceRolls = _.times(3, _.partial(_.random, 1, 6)); @@ -5560,7 +5658,7 @@ var index = -1, result = Array(n); - callback = lodash.createCallback(callback, thisArg, 1); + callback = baseCreateCallback(callback, thisArg, 1); while (++index < n) { result[index] = callback(index); } @@ -5587,7 +5685,7 @@ } /** - * Generates a unique ID. If `prefix` is passed, the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided, the ID will be appended to it. * * @static * @memberOf _ @@ -5763,8 +5861,10 @@ lodash.partialRight = partialRight; lodash.pick = pick; lodash.pluck = pluck; + lodash.pull = pull; lodash.range = range; lodash.reject = reject; + lodash.remove = remove; lodash.rest = rest; lodash.shuffle = shuffle; lodash.sortBy = sortBy; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 5947dc014..0770e50aa 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,47 +3,48 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=C&&i===t,g=u||v?f():l;if(v){var h=o(g);h?(i=e,g=h):(v=_,g=u?g:(p(g),l))}for(;++ai(g,y))&&((u||v)&&g.push(y),l.push(h))}return v?(p(g.b),s(g)):u&&p(g),l}function ot(n){return function(t,e,r){var u={};return e=Z.createCallback(e,r,3),xt(t,function(t,r,a){r=te(e(t,r,a)),n(u,t,r,a)}),u}}function it(n,t,e,r,u,a){var o=a&&!u;if(!yt(n)&&!o)throw new ee;var i=n.__bindData__;if(i)return ge.apply(i[2],e),ge.apply(i[3],r),!u&&i[4]&&(i[1]=t,i[4]=_,i[5]=a),it.apply(b,i); -if(u||a||r.length||!(Be.fastBind||me&&e.length))f=function(){var a=arguments,i=u?this:t;return o&&(n=t[c]),(e.length||r.length)&&(_e.apply(a,e),ge.apply(a,r)),this instanceof f?(i=bt(n.prototype)?de(n.prototype):{},a=n.apply(i,a),bt(a)?a:i):n.apply(i,a)};else{i=[n,t],ge.apply(i,e);var f=me.call.apply(me,i)}if(i=Se.call(arguments),o){var c=t;t=n}return $e(f,i),f}function ft(n){return Te[n]}function ct(){var n=(n=Z.indexOf)===Dt?t:n;return n}function lt(n){var t,e;return n&&be.call(n)==L&&(t=n.constructor,!yt(t)||t instanceof t)?(j(n,function(n,t){e=t -}),e===h||ve.call(n,e)):_}function pt(n){return qe[n]}function st(n){return n&&typeof n=="object"?be.call(n)==T:_}function vt(n,t,e){var r=Fe(n),u=r.length;for(t=Z.createCallback(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function gt(n){var t=[];return j(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function ht(n){for(var t=-1,e=Fe(n),r=e.length,u={};++te?xe(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(mt(n)?n.indexOf(t,e):u(n,t,e)):d(n,function(n){return++ra&&(a=i)}}else t=!t&&mt(n)?u:Z.createCallback(t,e,3),xt(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function St(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Gt(r);++earguments.length;t=Z.createCallback(t,r,4);var a=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++a]);++aarguments.length; -return t=Z.createCallback(t,r,4),Ot(n,function(n,r,a){e=u?(u=_,n):t(e,n,r,a)}),e}function Rt(n,t,e){var r;t=Z.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=C&&u===t;if(c){var l=o(i);l?(u=e,i=l):c=_}for(;++ru(i,l)&&f.push(l);return c&&s(i),f}function $t(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=b){var a=-1; -for(t=Z.createCallback(t,e,3);++ar?xe(0,u+r):r||0}else if(r)return r=Tt(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Ft(n,t,e){if(typeof t!="number"&&t!=b){var r=0,u=-1,a=n?n.length:0;for(t=Z.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tc&&(i=n.apply(f,o));else{var e=new Jt;!s&&!h&&(l=e);var r=p-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var $e=ce?function(n,t){var e=c();e.value=t,ce(n,"__bindData__",e),s(e)}:l,De=ke,Fe=je?function(n){return bt(n)?je(n):[]}:X,Te={"&":"&","<":"<",">":">",'"':""","'":"'"},qe=ht(Te),ze=ne("("+Fe(qe).join("|")+")","g"),We=ne("["+Fe(Te).join("")+"]","g"),Pe=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1 -}),Ke=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),Le=ot(function(n,t,e){n[e]=t});Ne&&Q&&typeof he=="function"&&(Lt=Pt(he,r));var Me=8==Ee(x+"08")?Ee:function(n,t){return Ee(mt(n)?n.replace(R,""):n,t||0)};return Z.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=J,Z.at=function(n){for(var t=-1,e=et(arguments,y,_,1),r=e.length,u=Gt(r);++t=C&&o(a?r[a]:h)}n:for(;++c(b?e(b,y):l(h,y))){for(a=u,(b||h).push(y);--a;)if(b=i[a],0>(b?e(b,y):l(r[a],y)))continue n; -g.push(y)}}for(;u--;)(b=i[u])&&s(b);return p(i),p(h),g},Z.invert=ht,Z.invoke=function(n,t){var e=Se.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Gt(typeof a=="number"?a:0);return xt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},Z.keys=Fe,Z.map=Et,Z.max=It,Z.memoize=function(n,t){function e(){var r=e.cache,u=w+(t?t.apply(this,arguments):arguments[0]);return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},Z.merge=function(n){var t=arguments,e=2;if(!bt(n))return n; -if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},Z.once=function(n){var t,e;return function(){return t?e:(t=y,e=n.apply(this,arguments),n=b,e)}},Z.pairs=function(n){for(var t=-1,e=Fe(n),r=e.length,u=Gt(r);++te?xe(0,r+e):Oe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Z.mixin=Ut,Z.noConflict=function(){return r._=ae,this},Z.parseInt=Me,Z.random=function(n,t){n==b&&t==b&&(t=1),n=+n||0,t==b?(t=n,n=0):t=+t||0;var e=Ie();return n%1||t%1?n+Oe(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+le(e*(t-n+1))},Z.reduce=At,Z.reduceRight=Nt,Z.result=function(n,t){var e=n?n[t]:h; -return yt(e)?n[t]():e},Z.runInContext=g,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Fe(n).length},Z.some=Rt,Z.sortedIndex=Tt,Z.template=function(n,t,e){var r=Z.templateSettings;n||(n=""),e=H({},e,r);var u,a=H({},e.imports,r.imports),r=Fe(a),a=dt(a),o=0,f=e.interpolate||B,c="__p+='",f=ne((e.escape||B).source+"|"+f.source+"|"+(f===N?S:B).source+"|"+(e.evaluate||B).source+"|$","g");n.replace(f,function(t,e,r,a,f,l){return r||(r=a),c+=n.slice(o,l).replace(D,i),e&&(c+="'+__e("+e+")+'"),f&&(u=y,c+="';"+f+";__p+='"),r&&(c+="'+((__t=("+r+"))==null?'':__t)+'"),o=l+t.length,t -}),c+="';\n",f=e=e.variable,f||(e="obj",c="with("+e+"){"+c+"}"),c=(u?c.replace(O,""):c).replace(E,"$1").replace(I,"$1;"),c="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Qt(r,"return "+c).apply(h,a)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},Z.unescape=function(n){return n==b?"":te(n).replace(ze,pt)},Z.uniqueId=function(n){var t=++k;return te(n==b?"":n)+t -},Z.all=wt,Z.any=Rt,Z.detect=jt,Z.findWhere=jt,Z.foldl=At,Z.foldr=Nt,Z.include=kt,Z.inject=At,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ge.apply(t,arguments),t=n.apply(Z,t),e?new nt(t,e):t})}),Z.first=$t,Z.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=b){var a=u;for(t=Z.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,r==b||e)return n[u-1];return v(n,xe(0,u-r))}},Z.take=$t,Z.head=$t,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e); -return!r&&(t==b||e&&typeof t!="function")?u:new nt(u,r)})}),Z.VERSION="1.3.1",Z.prototype.chain=function(){return this.__chain__=y,this},Z.prototype.toString=function(){return te(this.__wrapped__)},Z.prototype.value=Vt,Z.prototype.valueOf=Vt,xt(["join","pop","shift"],function(n){var t=re[n];Z.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),xt(["push","reverse","sort","unshift"],function(n){var t=re[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this -}}),xt(["concat","slice","splice"],function(n){var t=re[n];Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var h,y=!0,b=null,_=!1,m=[],d=[],k=0,w=+new Date+"",C=75,j=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",O=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,I=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,R=RegExp("^["+x+"]*0+(?=.$)"),B=/($^)/,$=($=/\bthis\b/)&&$.test(g)&&$,D=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),T="[object Arguments]",q="[object Array]",z="[object Boolean]",W="[object Date]",P="[object Function]",K="[object Number]",L="[object Object]",M="[object RegExp]",U="[object String]",V={}; -V[P]=_,V[T]=V[q]=V[z]=V[W]=V[K]=V[L]=V[M]=V[U]=y;var G={"boolean":_,"function":y,object:y,number:_,string:_,undefined:_},H={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},J=G[typeof exports]&&exports,Q=G[typeof module]&&module&&module.exports==J&&module,X=G[typeof global]&&global;!X||X.global!==X&&X.window!==X||(n=X);var Y=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=Y, define(function(){return Y})):J&&!J.nodeType?Q?(Q.exports=Y)._=Y:J._=Y:n._=Y +;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=k&&i===t,g=u||v?f():l;if(v){var h=o(g);h?(i=e,g=h):(v=m,g=u?g:(p(g),l)) +}for(;++ai(g,y))&&((u||v)&&g.push(y),l.push(h))}return v?(p(g.b),s(g)):u&&p(g),l}function it(n){return function(t,e,r){var u={};return e=Z.createCallback(e,r,3),Ot(t,function(t,r,a){r=ee(e(t,r,a)),n(u,t,r,a)}),u}}function ft(n,t,e,r,u,a){var o=a&&!u;if(!_t(n)&&!o)throw new re;var i=n.__bindData__;if(i)return he.apply(i[2],e),he.apply(i[3],r),!u&&i[4]&&(i[1]=t,i[4]=m,i[5]=a),ft.apply(_,i);if(u||a||r.length||!(De.fastBind||we&&e.length))f=function(){var a=arguments,i=u?this:t; +return o&&(n=t[c]),(e.length||r.length)&&(de.apply(a,e),he.apply(a,r)),this instanceof f?(i=mt(n.prototype)?je(n.prototype):{},a=n.apply(i,a),mt(a)?a:i):n.apply(i,a)};else{i=[n,t],he.apply(i,e);var f=we.call.apply(we,i)}if(i=Ne.call(arguments),o){var c=t;t=n}return Fe(f,i),f}function ct(n){return qe[n]}function lt(){var n=(n=Z.indexOf)===Ft?t:n;return n}function pt(n){var t,e;return n&&be.call(n)==L&&(t=n.constructor,!_t(t)||t instanceof t)?(x(n,function(n,t){e=t}),e===h||ge.call(n,e)):m}function st(n){return We[n] +}function vt(n){return n&&typeof n=="object"?be.call(n)==T:m}function gt(n,t,e){var r=ze(n),u=r.length;for(t=et(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function ht(n){var t=[];return x(n,function(n,e){_t(n)&&t.push(e)}),t.sort()}function yt(n){for(var t=-1,e=ze(n),r=e.length,u={};++te?Ee(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(dt(n)?n.indexOf(t,e):u(n,t,e)):d(n,function(n){return++ra&&(a=i)}}else t=!t&&dt(n)?u:Z.createCallback(t,e,3),Ot(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n) +});return a}function At(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ht(r);++earguments.length;t=et(t,r,4);var a=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++a]);++aarguments.length;return t=et(t,r,4),Et(n,function(n,r,a){e=u?(u=m,n):t(e,n,r,a)}),e}function Bt(n,t,e){var r;t=Z.createCallback(t,e,3),e=-1; +var u=n?n.length:0;if(typeof u=="number")for(;++e=k&&u===t;if(c){var l=o(i);l?(u=e,i=l):c=m}for(;++ru(i,l)&&f.push(l);return c&&s(i),f}function Dt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=_){var a=-1;for(t=Z.createCallback(t,e,3);++ar?Ee(0,u+r):r||0}else if(r)return r=zt(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Tt(n,t,e){if(typeof t!="number"&&t!=_){var r=0,u=-1,a=n?n.length:0;for(t=Z.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tc&&(i=n.apply(f,o));else{var e=new Qt;!s&&!h&&(l=e);var r=p-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var Fe=le?function(n,t){var e=c();e.value=t,le(n,"__bindData__",e),s(e)}:l,Te=ke,ze=Oe?function(n){return mt(n)?Oe(n):[]}:X,qe={"&":"&","<":"<",">":">",'"':""","'":"'"},We=yt(qe),Pe=te("("+ze(We).join("|")+")","g"),Ke=te("["+ze(qe).join("")+"]","g"),Le=it(function(n,t,e){ge.call(n,e)?n[e]++:n[e]=1 +}),Me=it(function(n,t,e){(ge.call(n,e)?n[e]:n[e]=[]).push(t)}),Ue=it(function(n,t,e){n[e]=t});Be&&Q&&typeof ye=="function"&&(Mt=Kt(ye,r));var Ve=8==Se(C+"08")?Se:function(n,t){return Se(dt(n)?n.replace(R,""):n,t||0)};return Z.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=J,Z.at=function(n){for(var t=-1,e=rt(arguments,y,m,1),r=e.length,u=Ht(r);++t=k&&o(a?r[a]:h)}n:for(;++c(_?e(_,y):l(h,y))){for(a=u,(_||h).push(y);--a;)if(_=i[a],0>(_?e(_,y):l(r[a],y)))continue n;g.push(y)}}for(;u--;)(_=i[u])&&s(_);return p(i),p(h),g},Z.invert=yt,Z.invoke=function(n,t){var e=Ne.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ht(typeof a=="number"?a:0);return Ot(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},Z.keys=ze,Z.map=It,Z.max=St,Z.memoize=function(n,t){function e(){var r=e.cache,u=j+(t?t.apply(this,arguments):arguments[0]); +return ge.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},Z.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},Z.once=function(n){var t,e;return function(){return t?e:(t=y,e=n.apply(this,arguments),n=_,e)}},Z.pairs=function(n){for(var t=-1,e=ze(n),r=e.length,u=Ht(r);++te?Ee(0,r+e):Ie(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Z.mixin=Vt,Z.noConflict=function(){return r._=oe,this},Z.parseInt=Ve,Z.random=function(n,t){n==_&&t==_&&(t=1),n=+n||0,t==_?(t=n,n=0):t=+t||0; +var e=Ae();return n%1||t%1?n+Ie(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+pe(e*(t-n+1))},Z.reduce=Nt,Z.reduceRight=Rt,Z.result=function(n,t){var e=n?n[t]:h;return _t(e)?n[t]():e},Z.runInContext=g,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ze(n).length},Z.some=Bt,Z.sortedIndex=zt,Z.template=function(n,t,e){var r=Z.templateSettings;n||(n=""),e=H({},e,r);var u,a=H({},e.imports,r.imports),r=ze(a),a=wt(a),o=0,f=e.interpolate||B,c="__p+='",f=te((e.escape||B).source+"|"+f.source+"|"+(f===N?S:B).source+"|"+(e.evaluate||B).source+"|$","g"); +n.replace(f,function(t,e,r,a,f,l){return r||(r=a),c+=n.slice(o,l).replace(D,i),e&&(c+="'+__e("+e+")+'"),f&&(u=y,c+="';"+f+";__p+='"),r&&(c+="'+((__t=("+r+"))==null?'':__t)+'"),o=l+t.length,t}),c+="';\n",f=e=e.variable,f||(e="obj",c="with("+e+"){"+c+"}"),c=(u?c.replace(O,""):c).replace(E,"$1").replace(I,"$1;"),c="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Xt(r,"return "+c).apply(h,a) +}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},Z.unescape=function(n){return n==_?"":ee(n).replace(Pe,st)},Z.uniqueId=function(n){var t=++w;return ee(n==_?"":n)+t},Z.all=kt,Z.any=Bt,Z.detect=Ct,Z.findWhere=Ct,Z.foldl=Nt,Z.foldr=Rt,Z.include=jt,Z.inject=Nt,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return he.apply(t,arguments),t=n.apply(Z,t),e?new nt(t,e):t})}),Z.first=Dt,Z.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=_){var a=u; +for(t=Z.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,r==_||e)return n[u-1];return v(n,Ee(0,u-r))}},Z.take=Dt,Z.head=Dt,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e);return!r&&(t==_||e&&typeof t!="function")?u:new nt(u,r)})}),Z.VERSION="1.3.1",Z.prototype.chain=function(){return this.__chain__=y,this},Z.prototype.toString=function(){return ee(this.__wrapped__)},Z.prototype.value=Gt,Z.prototype.valueOf=Gt,Ot(["join","pop","shift"],function(n){var t=ue[n]; +Z.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),Ot(["push","reverse","sort","unshift"],function(n){var t=ue[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ot(["concat","slice","splice"],function(n){var t=ue[n];Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var h,y=!0,_=null,m=!1,b=[],d=[],w=0,j=+new Date+"",k=75,x=40,C=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",O=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,I=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,R=RegExp("^["+C+"]*0+(?=.$)"),B=/($^)/,$=($=/\bthis\b/)&&$.test(g)&&$,D=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),T="[object Arguments]",z="[object Array]",q="[object Boolean]",W="[object Date]",P="[object Function]",K="[object Number]",L="[object Object]",M="[object RegExp]",U="[object String]",V={}; +V[P]=m,V[T]=V[z]=V[q]=V[W]=V[K]=V[L]=V[M]=V[U]=y;var G={"boolean":m,"function":y,object:y,number:m,string:m,undefined:m},H={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},J=G[typeof exports]&&exports,Q=G[typeof module]&&module&&module.exports==J&&module,X=G[typeof global]&&global;!X||X.global!==X&&X.window!==X||(n=X);var Y=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=Y, define(function(){return Y})):J&&!J.nodeType?Q?(Q.exports=Y)._=Y:J._=Y:n._=Y }(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index e65ad75d2..b0559e7a2 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -77,7 +77,7 @@ /*--------------------------------------------------------------------------*/ /** - * A base implementation of `_.indexOf` without support for binary searches + * The base implementation of `_.indexOf` without support for binary searches * or `fromIndex` constraints. * * @private @@ -360,7 +360,42 @@ /*--------------------------------------------------------------------------*/ /** - * A base implementation of `_.flatten` without support for `callback` + * The base implementation of `_.createCallback` without support for creating + * "_.pluck" or "_.where" style callbacks. + * + * @private + * @param {Mixed} [func=identity] The value to convert to a callback. + * @param {Mixed} [thisArg] The `this` binding of the created callback. + * @param {Number} [argCount] The number of arguments the callback accepts. + * @returns {Function} Returns a callback function. + */ + function baseCreateCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + // exit early if there is no `thisArg` + if (typeof thisArg == 'undefined') { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 2: return function(a, b) { + return func.call(thisArg, a, b); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + } + return bind(func, thisArg); + } + + /** + * The base implementation of `_.flatten` without support for `callback` * shorthands or `thisArg` binding. * * @private @@ -388,7 +423,7 @@ } /** - * A base implementation of `_.isEqual`, without support for `thisArg` binding, + * The base implementation of `_.isEqual`, without support for `thisArg` binding, * that allows partial "_.where" style comparisons. * * @private @@ -437,7 +472,7 @@ } var isArr = className == arrayClass; if (!isArr) { - if (a instanceof lodash || b instanceof lodash) { + if (hasOwnProperty.call(a, '__wrapped__ ') || b instanceof lodash) { return baseIsEqual(a.__wrapped__ || a, b.__wrapped__ || b, stackA, stackB); } if (className != objectClass) { @@ -499,7 +534,7 @@ } /** - * A base implementation of `_.uniq` without support for `callback` shorthands + * The base implementation of `_.uniq` without support for `callback` shorthands * or `thisArg` binding. * * @private @@ -729,7 +764,7 @@ * @private * @type Function * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. + * @returns {Array} Returns an array of property names. */ var shimKeys = function(object) { var index, iterable = object, result = []; @@ -750,7 +785,7 @@ * @memberOf _ * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names. + * @returns {Array} Returns an array of property names. * @example * * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); @@ -792,7 +827,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object. Subsequent sources will overwrite property assignments of previous - * sources. If a `callback` function is passed, it will be executed to produce + * sources. If a `callback` function is provided, it will be executed to produce * the assigned values. The `callback` is bound to `thisArg` and invoked with * two arguments; (objectValue, sourceValue). * @@ -837,7 +872,7 @@ /** * Creates a clone of `value`. If `deep` is `true`, nested objects will also * be cloned, otherwise they will be assigned by reference. If a `callback` - * function is passed, it will be executed to produce the cloned values. If + * function is provided, it will be executed to produce the cloned values. If * `callback` returns `undefined`, cloning will be handled by the method instead. * The `callback` is bound to `thisArg` and invoked with one argument; (value). * @@ -998,7 +1033,7 @@ * @alias methods * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property names that have function values. + * @returns {Array} Returns an array of property names that have function values. * @example * * _.functions(_); @@ -1148,7 +1183,7 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent to each other. If `callback` is passed, it will be executed to + * equivalent to each other. If `callback` is provided, it will be executed to * compare values. If `callback` returns `undefined`, comparisons will be handled * by the method instead. The `callback` is bound to `thisArg` and invoked with * two arguments; (a, b). @@ -1395,7 +1430,7 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a `callback` function is passed, it will be executed + * property names. If a `callback` function is provided, it will be executed * for each property in the `object`, omitting the properties `callback` * returns truthy for. The `callback` is bound to `thisArg` and invoked * with three arguments; (value, key, object). @@ -1461,7 +1496,7 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property - * names. If `callback` is passed, it will be executed for each property in the + * names. If `callback` is provided, it will be executed for each property in the * `object`, picking the properties `callback` returns truthy for. The `callback` * is bound to `thisArg` and invoked with three arguments; (value, key, object). * @@ -1506,7 +1541,7 @@ * @memberOf _ * @category Objects * @param {Object} object The object to inspect. - * @returns {Array} Returns a new array of property values. + * @returns {Array} Returns an array of property values. * @example * * _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -1574,10 +1609,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -1585,9 +1620,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -1610,10 +1645,10 @@ * `collection`. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -1622,9 +1657,9 @@ * @alias all * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if all elements pass the callback check, * else `false`. @@ -1672,10 +1707,10 @@ * the `callback` returns truthy for. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -1684,9 +1719,9 @@ * @alias select * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that passed the callback check. * @example @@ -1736,10 +1771,10 @@ * `callback` returns truthy for. The `callback` is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -1748,9 +1783,9 @@ * @alias detect, findWhere * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -1852,7 +1887,7 @@ var index = -1, length = collection ? collection.length : 0; - callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg, 3); + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); if (typeof length == 'number') { while (++index < length) { if (callback(collection[index], index, collection) === indicatorObject) { @@ -1888,10 +1923,8 @@ if (typeof length != 'number') { var props = keys(collection); length = props.length; - } else if (support.unindexedChars && isString(collection)) { - iterable = collection.split(''); } - callback = createCallback(callback, thisArg, 3); + callback = baseCreateCallback(callback, thisArg, 3); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; callback(iterable[index], index, collection); @@ -1906,10 +1939,10 @@ * the key. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false` * @@ -1917,9 +1950,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -1978,10 +2011,10 @@ * through the `callback`. The `callback` is bound to `thisArg` and invoked with * three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -1990,9 +2023,9 @@ * @alias collect * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of the results of each `callback` execution. * @example @@ -2032,15 +2065,15 @@ } /** - * Retrieves the maximum value of an `array`. If `callback` is passed, + * Retrieves the maximum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2048,9 +2081,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the maximum value. * @example @@ -2099,15 +2132,15 @@ } /** - * Retrieves the minimum value of an `array`. If `callback` is passed, + * Retrieves the minimum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2115,9 +2148,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the minimum value. * @example @@ -2231,7 +2264,7 @@ function reduce(collection, callback, accumulator, thisArg) { if (!collection) return accumulator; var noaccum = arguments.length < 3; - callback = createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); var index = -1, length = collection.length; @@ -2274,7 +2307,7 @@ */ function reduceRight(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; - callback = createCallback(callback, thisArg, 4); + callback = baseCreateCallback(callback, thisArg, 4); forEachRight(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) @@ -2287,10 +2320,10 @@ * The opposite of `_.filter`, this method returns the elements of a * `collection` that `callback` does **not** return truthy for. * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2298,9 +2331,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that did **not** pass the * callback check. @@ -2387,10 +2420,10 @@ * does not iterate over the entire `collection`. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2399,9 +2432,9 @@ * @alias any * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if any element passes the callback check, * else `false`. @@ -2451,10 +2484,10 @@ * equal elements. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2462,9 +2495,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -2617,16 +2650,16 @@ } /** - * Gets the first element of the `array`. If a number `n` is passed, the first - * `n` elements of the `array` are returned. If a `callback` function is passed, + * Gets the first element of the `array`. If a number `n` is provided, the first + * `n` elements of the `array` are returned. If a `callback` function is provided, * elements at the beginning of the array are returned as long as the `callback` * returns truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2637,7 +2670,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the first element(s) of `array`. @@ -2697,14 +2730,14 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` * is truthy, `array` will only be flattened a single level. If `callback` - * is passed, each element of `array` is passed through a `callback` before + * is provided, each element of `array` is provided through a `callback` before * flattening. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2713,9 +2746,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {Boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -2775,16 +2808,16 @@ } /** - * Gets all but the last element of `array`. If a number `n` is passed, the + * Gets all but the last element of `array`. If a number `n` is provided, the * last `n` elements are excluded from the result. If a `callback` function - * is passed, elements at the end of the array are excluded from the result + * is provided, elements at the end of the array are excluded from the result * as long as the `callback` returns truthy. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2794,7 +2827,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -2888,17 +2921,17 @@ } /** - * Gets the last element of the `array`. If a number `n` is passed, the + * Gets the last element of the `array`. If a number `n` is provided, the * last `n` elements of the `array` are returned. If a `callback` function - * is passed, elements at the end of the array are returned as long as the + * is provided, elements at the end of the array are returned as long as the * `callback` returns truthy. The `callback` is bound to `thisArg` and * invoked with three arguments;(value, index, array). * * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -2908,7 +2941,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the last element(s) of `array`. @@ -3050,16 +3083,16 @@ /** * The opposite of `_.initial`, this method gets all but the first value of - * `array`. If a number `n` is passed, the first `n` values are excluded from - * the result. If a `callback` function is passed, elements at the beginning + * `array`. If a number `n` is provided, the first `n` values are excluded from + * the result. If a `callback` function is provided, elements at the beginning * of the array are excluded from the result as long as the `callback` returns * truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3070,7 +3103,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -3125,14 +3158,14 @@ /** * Uses a binary search to determine the smallest index at which the `value` * should be inserted into `array` in order to maintain the sort order of the - * sorted `array`. If `callback` is passed, it will be executed for `value` and - * each element in `array` to compute their sort ranking. The `callback` is - * bound to `thisArg` and invoked with one argument; (value). + * sorted `array`. If `callback` is provided, it will be executed for `value` + * and each element in `array` to compute their sort ranking. The `callback` + * is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3141,9 +3174,9 @@ * @category Arrays * @param {Array} array The array to inspect. * @param {Mixed} value The value to evaluate. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Number} Returns the index at which the value should be inserted * into `array`. @@ -3208,14 +3241,15 @@ /** * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` - * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through the `callback` before uniqueness is computed. - * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). + * for `isSorted` will run a faster algorithm. If `callback` is provided, each + * element of `array` is provided through the `callback` before uniqueness is + * computed. The `callback` is bound to `thisArg` and invoked with three arguments; + * (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3225,9 +3259,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -3481,8 +3515,6 @@ * If `func` is an object, the created callback will return `true` for elements * that contain the equivalent object properties, otherwise it will return `false`. * - * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. - * * @static * @memberOf _ * @category Functions @@ -3507,64 +3539,30 @@ * * _.filter(stooges, 'age__gt45'); * // => [{ 'name': 'larry', 'age': 50 }] - * - * // create mixins with support for "_.pluck" and "_.where" callback shorthands - * _.mixin({ - * 'toLookup': function(collection, callback, thisArg) { - * callback = _.createCallback(callback, thisArg); - * return _.reduce(collection, function(result, value, index, collection) { - * return (result[callback(value, index, collection)] = value, result); - * }, {}); - * } - * }); - * - * _.toLookup(stooges, 'name'); - * // => { 'moe': { 'name': 'moe', 'age': 40 }, 'larry': { 'name': 'larry', 'age': 50 } } */ function createCallback(func, thisArg, argCount) { - if (func == null) { - return identity; - } var type = typeof func; - if (type != 'function') { - // handle "_.pluck" style callback shorthands - if (type != 'object') { - return function(object) { - return object[func]; - }; - } - var props = keys(func); + if (func == null || type == 'function') { + return baseCreateCallback(func, thisArg, argCount); + } + // handle "_.pluck" style callback shorthands + if (type != 'object') { return function(object) { - var length = props.length, - result = false; + return object[func]; + }; + } + var props = keys(func); + return function(object) { + var length = props.length, + result = false; - while (length--) { - if (!(result = object[props[length]] === func[props[length]])) { - break; - } + while (length--) { + if (!(result = object[props[length]] === func[props[length]])) { + break; } - return result; - }; - } - // exit early if there is no `thisArg` - if (typeof thisArg == 'undefined') { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 2: return function(a, b) { - return func.call(thisArg, a, b); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - } - return bind(func, thisArg); + } + return result; + }; } /** @@ -3991,7 +3989,8 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is passed, a number between `0` and the given number will be returned. + * argument is provided, a number between `0` and the given number will be + * returned. * * @static * @memberOf _ @@ -4207,7 +4206,7 @@ * @param {Number} n The number of times to execute the callback. * @param {Function} callback The function called per iteration. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of the results of each `callback` execution. + * @returns {Array} Returns an array of the results of each `callback` execution. * @example * * var diceRolls = _.times(3, _.partial(_.random, 1, 6)); @@ -4249,7 +4248,7 @@ } /** - * Generates a unique ID. If `prefix` is passed, the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided, the ID will be appended to it. * * @static * @memberOf _ @@ -4345,22 +4344,6 @@ return this; } - /** - * Produces the `toString` result of the wrapped value. - * - * @name toString - * @memberOf _ - * @category Chaining - * @returns {String} Returns the string result. - * @example - * - * _([1, 2, 3]).toString(); - * // => '1,2,3' - */ - function wrapperToString() { - return String(this.__wrapped__); - } - /** * Extracts the wrapped value. * @@ -4504,6 +4487,9 @@ /*--------------------------------------------------------------------------*/ + // add functions to `lodash.prototype` + mixin(lodash); + /** * The semantic version number. * @@ -4513,9 +4499,6 @@ */ lodash.VERSION = '1.3.1'; - // add functions to `lodash.prototype` - mixin(lodash); - // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; lodash.prototype.value = wrapperValueOf; diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 3766dc614..812dd4abd 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,34 +3,34 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` */ -;!function(n){function t(n,t){var r;if(n&&mt[typeof n])for(r in n)if(St.call(n,r)&&t(n[r],r,n)===it)break}function r(n,t){var r;if(n&&mt[typeof n])for(r in n)if(t(n[r],r,n)===it)break}function e(n){var t,r=[];if(!n||!mt[typeof n])return r;for(t in n)St.call(n,t)&&r.push(t);return r}function u(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(nu(a,c))&&(r&&a.push(c),o.push(f))}return o}function v(n){return function(t,r,e){var u={};return r=Q(r,e,3),D(t,function(t,e,i){e=r(t,e,i)+"",n(u,t,e,i)}),u}}function g(n,t,r,e){var u=[];if(!O(n))throw new TypeError; -if(e||u.length||!(Vt.fastBind||kt&&r.length))o=function(){var i=arguments,a=e?this:t;return(r.length||u.length)&&(Rt.apply(i,r),Ft.apply(i,u)),this instanceof o?(a=h(n.prototype),i=n.apply(a,i),E(i)?i:a):n.apply(a,i)};else{var i=[n,t];Ft.apply(i,r);var o=kt.call.apply(kt,i)}return o}function h(n){return E(n)?Bt(n):{}}function y(n){return Jt[n]}function m(){var n=(n=f.indexOf)===G?u:n;return n}function _(n){return Kt[n]}function d(n){return n&&typeof n=="object"?Nt.call(n)==ct:et}function b(n){if(!n)return n; -for(var t=1,r=arguments.length;te&&(e=r,u=n) -});else for(;++iu&&(u=r);return u}function I(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=Q(r,u,4);var o=-1,a=n.length;if(typeof a=="number")for(i&&(e=n[++o]);++oarguments.length;return t=Q(t,e,4),q(n,function(n,e,i){r=u?(u=et,n):t(r,n,e,i)}),r}function C(n,r,e){var u; -r=Q(r,e,3),e=-1;var i=n?n.length:0;if(typeof i=="number")for(;++er(u,o)&&i.push(o)}return i}function V(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=rt){var i=-1;for(t=Q(t,r,3);++ir?It(0,e+r):r||0}else if(r)return r=J(n,t),n[r]===t?r:-1;return n?u(n,t,r):-1}function H(n,t,r){if(typeof t!="number"&&t!=rt){var e=0,u=-1,i=n?n.length:0;for(t=Q(t,r,3);++u>>1,r(n[e])c&&(a=n.apply(f,o));else{var r=new Date; -!s&&!h&&(l=r);var e=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Bt||(h=function(n){if(E(n)){a.prototype=n;var t=new a;a.prototype=rt}return t||{}}),d(arguments)||(d=function(n){return n&&typeof n=="object"?St.call(n,"callee"):et});var Gt=Dt||function(n){return n&&typeof n=="object"?Nt.call(n)==lt:et},Ht=$t?function(n){return E(n)?$t(n):[] -}:e,Jt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Kt=x(Jt),Lt=RegExp("("+Ht(Kt).join("|")+")","g"),Qt=RegExp("["+Ht(Jt).join("")+"]","g");O(/x/)&&(O=function(n){return typeof n=="function"&&"[object Function]"==Nt.call(n)});var Xt=v(function(n,t,r){St.call(n,r)?n[r]++:n[r]=1}),Yt=v(function(n,t,r){(St.call(n,r)?n[r]:n[r]=[]).push(t)});f.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},f.bind=L,f.bindAll=function(n){for(var t=1u(o,a)){for(var f=r;--f;)if(0>u(t[f],a))continue n;o.push(a)}}return o},f.invert=x,f.invoke=function(n,t){var r=Ct.call(arguments,2),e=-1,u=typeof t=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); -return D(n,function(n){o[++e]=(u?t:n[t]).apply(n,r)}),o},f.keys=Ht,f.map=M,f.max=$,f.memoize=function(n,t){var r={};return function(){var e=ot+(t?t.apply(this,arguments):arguments[0]);return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},f.min=function(n,t,r){var e=1/0,u=e,i=-1,o=n?n.length:0;if(t||typeof o!="number")t=Q(t,r,3),D(n,function(n,r,i){r=t(n,r,i),rt(e,r)&&(u[r]=n) -}),u},f.once=function(n){var t,r;return function(){return t?r:(t=tt,r=n.apply(this,arguments),n=rt,r)}},f.pairs=function(n){for(var t=-1,r=Ht(n),e=r.length,u=Array(e);++tt?0:t);++nr?It(0,e+r):Wt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},f.mixin=Z,f.noConflict=function(){return n._=At,this},f.random=function(n,t){n==rt&&t==rt&&(t=1),n=+n||0,t==rt?(t=n,n=0):t=+t||0;var r=zt();return n%1||t%1?n+Wt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+Tt(r*(t-n+1))},f.reduce=W,f.reduceRight=z,f.result=function(n,t){var r=n?n[t]:nt; -return O(r)?n[t]():r},f.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ht(n).length},f.some=C,f.sortedIndex=J,f.template=function(n,t,r){var e=f.templateSettings;n||(n=""),r=j({},r,e);var u=0,i="__p+='",e=r.variable;n.replace(RegExp((r.escape||at).source+"|"+(r.interpolate||at).source+"|"+(r.evaluate||at).source+"|$","g"),function(t,r,e,a,f){return i+=n.slice(u,f).replace(ft,o),r&&(i+="'+_.escape("+r+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),u=f+t.length,t -}),i+="';\n",e||(e="obj",i="with("+e+"||{}){"+i+"}"),i="function("+e+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var a=Function("_","return "+i)(f)}catch(c){throw c.source=i,c}return t?a(t):(a.source=i,a)},f.unescape=function(n){return n==rt?"":(n+"").replace(Lt,_)},f.uniqueId=function(n){var t=++ut+"";return n?n+t:t},f.all=R,f.any=C,f.detect=B,f.findWhere=function(n,t){return P(n,t,tt)},f.foldl=W,f.foldr=z,f.include=N,f.inject=W,f.first=V,f.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&t!=rt){var i=u;for(t=Q(t,r,3);i--&&t(n[i],i,n);)e++}else if(e=t,e==rt||r)return n[u-1];return Ct.call(n,It(0,u-e))}},f.take=V,f.head=V,f.VERSION="1.3.1",Z(f),f.prototype.chain=function(){return this.__chain__=tt,this},f.prototype.value=function(){return this.__wrapped__},D("pop push reverse shift sort splice unshift".split(" "),function(n){var t=wt[n];f.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!Vt.spliceObjects&&0===n.length&&delete n[0],this -}}),D(["concat","join","slice"],function(n){var t=wt[n];f.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new c(n),n.__chain__=tt),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=f, define(function(){return f})):dt&&!dt.nodeType?bt?(bt.exports=f)._=f:dt._=f:n._=f}(this); \ No newline at end of file +;!function(n){function t(n,t){var r;if(n&&_t[typeof n])for(r in n)if(Ft.call(n,r)&&t(n[r],r,n)===ot)break}function r(n,t){var r;if(n&&_t[typeof n])for(r in n)if(t(n[r],r,n)===ot)break}function e(n){var t,r=[];if(!n||!_t[typeof n])return r;for(t in n)Ft.call(n,t)&&r.push(t);return r}function u(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(nu(a,c))&&(r&&a.push(c),o.push(f))}return o}function g(n){return function(t,r,e){var u={};return r=X(r,e,3),q(t,function(t,e,i){e=r(t,e,i)+"",n(u,t,e,i)}),u}}function h(n,t,r,e){var u=[];if(!E(n))throw new TypeError;if(e||u.length||!(Gt.fastBind||Bt&&r.length))o=function(){var i=arguments,a=e?this:t;return(r.length||u.length)&&(kt.apply(i,r),Nt.apply(i,u)),this instanceof o?(a=y(n.prototype),i=n.apply(a,i),T(i)?i:a):n.apply(a,i)};else{var i=[n,t];Nt.apply(i,r);var o=Bt.call.apply(Bt,i) +}return o}function y(n){return T(n)?Dt(n):{}}function m(n){return Kt[n]}function _(){var n=(n=f.indexOf)===H?u:n;return n}function d(n){return Lt[n]}function b(n){return n&&typeof n=="object"?Rt.call(n)==lt:ut}function j(n){if(!n)return n;for(var t=1,r=arguments.length;te&&(e=r,u=n)});else for(;++iu&&(u=r);return u}function W(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=l(r,u,4);var o=-1,a=n.length;if(typeof a=="number")for(i&&(e=n[++o]);++oarguments.length;return t=l(t,e,4),M(n,function(n,e,i){r=u?(u=ut,n):t(r,n,e,i)}),r}function P(n,r,e){var u;r=X(r,e,3),e=-1;var i=n?n.length:0;if(typeof i=="number")for(;++er(u,o)&&i.push(o) +}return i}function G(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=et){var i=-1;for(t=X(t,r,3);++ir?Wt(0,e+r):r||0}else if(r)return r=K(n,t),n[r]===t?r:-1;return n?u(n,t,r):-1}function J(n,t,r){if(typeof t!="number"&&t!=et){var e=0,u=-1,i=n?n.length:0;for(t=X(t,r,3);++u>>1,r(n[e])c&&(a=n.apply(f,o));else{var r=new Date;!s&&!h&&(l=r);var e=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Dt||(y=function(n){if(T(n)){a.prototype=n;var t=new a;a.prototype=et}return t||{}}),b(arguments)||(b=function(n){return n&&typeof n=="object"?Ft.call(n,"callee"):ut});var Ht=qt||function(n){return n&&typeof n=="object"?Rt.call(n)==pt:ut},Jt=It?function(n){return T(n)?It(n):[] +}:e,Kt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Lt=A(Kt),Qt=RegExp("("+Jt(Lt).join("|")+")","g"),Xt=RegExp("["+Jt(Kt).join("")+"]","g");E(/x/)&&(E=function(n){return typeof n=="function"&&"[object Function]"==Rt.call(n)});var Yt=g(function(n,t,r){Ft.call(n,r)?n[r]++:n[r]=1}),Zt=g(function(n,t,r){(Ft.call(n,r)?n[r]:n[r]=[]).push(t)});f.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},f.bind=Q,f.bindAll=function(n){for(var t=1u(o,a)){for(var f=r;--f;)if(0>u(t[f],a))continue n;o.push(a)}}return o},f.invert=A,f.invoke=function(n,t){var r=Pt.call(arguments,2),e=-1,u=typeof t=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); +return q(n,function(n){o[++e]=(u?t:n[t]).apply(n,r)}),o},f.keys=Jt,f.map=$,f.max=I,f.memoize=function(n,t){var r={};return function(){var e=at+(t?t.apply(this,arguments):arguments[0]);return Ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},f.min=function(n,t,r){var e=1/0,u=e,i=-1,o=n?n.length:0;if(t||typeof o!="number")t=X(t,r,3),q(n,function(n,r,i){r=t(n,r,i),rt(e,r)&&(u[r]=n) +}),u},f.once=function(n){var t,r;return function(){return t?r:(t=rt,r=n.apply(this,arguments),n=et,r)}},f.pairs=function(n){for(var t=-1,r=Jt(n),e=r.length,u=Array(e);++tt?0:t);++nr?Wt(0,e+r):zt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},f.mixin=nt,f.noConflict=function(){return n._=Ot,this},f.random=function(n,t){n==et&&t==et&&(t=1),n=+n||0,t==et?(t=n,n=0):t=+t||0;var r=Ct();return n%1||t%1?n+zt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+St(r*(t-n+1))},f.reduce=z,f.reduceRight=C,f.result=function(n,t){var r=n?n[t]:tt; +return E(r)?n[t]():r},f.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Jt(n).length},f.some=P,f.sortedIndex=K,f.template=function(n,t,r){var e=f.templateSettings;n||(n=""),r=w({},r,e);var u=0,i="__p+='",e=r.variable;n.replace(RegExp((r.escape||ft).source+"|"+(r.interpolate||ft).source+"|"+(r.evaluate||ft).source+"|$","g"),function(t,r,e,a,f){return i+=n.slice(u,f).replace(ct,o),r&&(i+="'+_.escape("+r+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),u=f+t.length,t +}),i+="';\n",e||(e="obj",i="with("+e+"||{}){"+i+"}"),i="function("+e+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var a=Function("_","return "+i)(f)}catch(c){throw c.source=i,c}return t?a(t):(a.source=i,a)},f.unescape=function(n){return n==et?"":(n+"").replace(Qt,d)},f.uniqueId=function(n){var t=++it+"";return n?n+t:t},f.all=k,f.any=P,f.detect=D,f.findWhere=function(n,t){return U(n,t,rt)},f.foldl=z,f.foldr=C,f.include=R,f.inject=z,f.first=G,f.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t!="number"&&t!=et){var i=u;for(t=X(t,r,3);i--&&t(n[i],i,n);)e++}else if(e=t,e==et||r)return n[u-1];return Pt.call(n,Wt(0,u-e))}},f.take=G,f.head=G,nt(f),f.VERSION="1.3.1",f.prototype.chain=function(){return this.__chain__=rt,this},f.prototype.value=function(){return this.__wrapped__},q("pop push reverse shift sort splice unshift".split(" "),function(n){var t=xt[n];f.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!Gt.spliceObjects&&0===n.length&&delete n[0],this +}}),q(["concat","join","slice"],function(n){var t=xt[n];f.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new c(n),n.__chain__=rt),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=f, define(function(){return f})):bt&&!bt.nodeType?jt?(jt.exports=f)._=f:bt._=f:n._=f}(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 32e8af8f9..162f5467e 100644 --- a/doc/README.md +++ b/doc/README.md @@ -20,6 +20,7 @@ * [`_.last`](#_lastarray--callbackn-thisarg) * [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1) * [`_.object`](#_zipobjectkeys--values) +* [`_.pull`](#_pullarray--value1-value2-) * [`_.range`](#_rangestart0-end--step1) * [`_.rest`](#_restarray--callbackn1-thisarg) * [`_.sortedIndex`](#_sortedindexarray-value--callbackidentity-thisarg) @@ -83,6 +84,7 @@ * [`_.reduce`](#_reducecollection--callbackidentity-accumulator-thisarg) * [`_.reduceRight`](#_reducerightcollection--callbackidentity-accumulator-thisarg) * [`_.reject`](#_rejectcollection--callbackidentity-thisarg) +* [`_.remove`](#_removecollection--callbackidentity-thisarg) * [`_.select`](#_filtercollection--callbackidentity-thisarg) * [`_.shuffle`](#_shufflecollection) * [`_.size`](#_sizecollection) @@ -227,7 +229,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3981 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4086 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -251,7 +253,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4010 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4115 "View in source") [Ⓣ][1] Creates an array excluding all values of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -276,13 +278,13 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4165 "View in source") [Ⓣ][1] This method is like `_.find`, except that it returns the index of the element that passes the callback check, instead of the element itself. #### Arguments 1. `array` *(Array)*: The array to search. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -304,13 +306,13 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.findLastIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4093 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4198 "View in source") [Ⓣ][1] This method is like `_.findIndex`, except that it iterates over elements of a `collection` from right to left. #### Arguments 1. `array` *(Array)*: The array to search. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -332,20 +334,20 @@ _.findLastIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4268 "View in source") [Ⓣ][1] -Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, elements at the beginning of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. +Gets the first element of the `array`. If a number `n` is provided, the first `n` elements of the `array` are returned. If a `callback` function is provided, elements at the beginning of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *head, take* #### Arguments 1. `array` *(Array)*: The array to query. -2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -392,18 +394,18 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4225 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4330 "View in source") [Ⓣ][1] -Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, `array` will only be flattened a single level. If `callback` is passed, each element of `array` is passed through a `callback` before flattening. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. +Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, `array` will only be flattened a single level. If `callback` is provided, each element of `array` is provided through a `callback` before flattening. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to flatten. 2. `[isShallow=false]` *(Boolean)*: A flag to restrict flattening to a single level. -3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -435,7 +437,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4367 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. @@ -467,17 +469,17 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4329 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4434 "View in source") [Ⓣ][1] -Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. +Gets all but the last element of `array`. If a number `n` is provided, the last `n` elements are excluded from the result. If a `callback` function is provided, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -524,7 +526,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4362 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4467 "View in source") [Ⓣ][1] Creates an array of unique values present in all passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -548,17 +550,17 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4464 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4569 "View in source") [Ⓣ][1] -Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array). +Gets the last element of the `array`. If a number `n` is provided, the last `n` elements of the `array` are returned. If a `callback` function is provided, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array). - If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to query. -2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -605,7 +607,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4505 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4610 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -631,10 +633,37 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); + + +### `_.pull(array [, value1, value2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4640 "View in source") [Ⓣ][1] + +Removes all passed values from the given array using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `array` *(Array)*: The array to modify. +2. `[value1, value2, ...]` *(Mixed)*: The values to remove. + +#### Returns +*(Array)*: Returns `array`. + +#### Example +```js +var array = [1, 2, 3, 1, 2, 3]; +_.pull(array, 2, 3); +console.log(array); +// => [1, 1] +``` + +* * * + + + + ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4547 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4688 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. If `start` is less than `stop` a zero-length range is created unless a negative `step` is specified. @@ -672,20 +701,20 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4626 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4767 "View in source") [Ⓣ][1] -The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. +The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is provided, the first `n` values are excluded from the result. If a `callback` function is provided, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *drop, tail* #### Arguments 1. `array` *(Array)*: The array to query. -2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -732,18 +761,18 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4690 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4831 "View in source") [Ⓣ][1] -Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. +Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is provided, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `value` *(Mixed)*: The value to evaluate. -3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -781,7 +810,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4721 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4862 "View in source") [Ⓣ][1] Creates an array of unique values, in order, of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -805,13 +834,13 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4910 "View in source") [Ⓣ][1] -Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through the `callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. +Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is provided, each element of `array` is provided through the `callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *unique* @@ -819,7 +848,7 @@ If an object is passed for `callback`, the created "_.where" style callback will #### Arguments 1. `array` *(Array)*: The array to process. 2. `[isSorted=false]` *(Boolean)*: A flag to indicate that the `array` is already sorted. -3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -852,7 +881,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4796 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4938 "View in source") [Ⓣ][1] Creates an array excluding all passed values using strict equality for comparisons, i.e. `===`. @@ -877,7 +906,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4958 "View in source") [Ⓣ][1] Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. @@ -904,7 +933,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4988 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -939,7 +968,7 @@ _.zipObject(['moe', 'larry'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L612 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L613 "View in source") [Ⓣ][1] Creates a `lodash` object, which wraps the given `value`, to enable method chaining. @@ -992,7 +1021,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6093 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps the given `value`. @@ -1025,7 +1054,7 @@ var youngest = _.chain(stooges) ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6120 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -1055,7 +1084,7 @@ _([1, 2, 3, 4]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6040 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6140 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -1079,7 +1108,7 @@ var sum = _([1, 2, 3]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6057 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6157 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1100,7 +1129,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6074 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6174 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1131,7 +1160,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2878 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2924 "View in source") [Ⓣ][1] Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -1159,7 +1188,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2966 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1197,17 +1226,17 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2976 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3022 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1233,20 +1262,20 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3021 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *all* #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1279,20 +1308,20 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3082 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3128 "View in source") [Ⓣ][1] Iterates over elements of a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *select* #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1325,20 +1354,20 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "View in source") [Ⓣ][1] Iterates over elements of a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *detect, findWhere* #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1374,13 +1403,13 @@ _.find(food, 'organic'); ### `_.findLast(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3194 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3240 "View in source") [Ⓣ][1] This method is like `_.find`, except that it iterates over elements of a `collection` from right to left. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1402,7 +1431,7 @@ _.findLast([1, 2, 3, 4], function(num) { ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3228 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3274 "View in source") [Ⓣ][1] Iterates over elements of a `collection`, executing the `callback` for each element. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1434,7 +1463,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); ### `_.forEachRight(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [Ⓣ][1] This method is like `_.forEach`, except that it iterates over elements of a `collection` from right to left. @@ -1463,17 +1492,17 @@ _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3360 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of the `collection` through the `callback`. The corresponding value of each key is an array of the elements responsible for generating the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false` +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false` #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1500,17 +1529,17 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.indexBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3357 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3403 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of the `collection` through the given `callback`. The corresponding value of each key is the last element responsible for generating the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1541,7 +1570,7 @@ _.indexBy(stooges, function(key) { this.fromCharCode(key.code); }, String); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3383 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3429 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1570,20 +1599,20 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3435 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3481 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *collect* #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1615,17 +1644,17 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3492 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3538 "View in source") [Ⓣ][1] -Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. +Retrieves the maximum value of an `array`. If `callback` is provided, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1657,17 +1686,17 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3561 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3607 "View in source") [Ⓣ][1] -Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. +Retrieves the minimum value of an `array`. If `callback` is provided, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1699,7 +1728,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3611 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3657 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1729,7 +1758,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3643 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3689 "View in source") [Ⓣ][1] Reduces a `collection` to a value which is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1767,7 +1796,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3686 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3732 "View in source") [Ⓣ][1] This method is like `_.reduce`, except that it iterates over elements of a `collection` from right to left. @@ -1798,17 +1827,17 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3736 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3782 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1838,10 +1867,46 @@ _.reject(food, { 'type': 'fruit' }); + + +### `_.remove(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3821 "View in source") [Ⓣ][1] + +Removes all elements from the `collection` that thw `callback` returns truthy for and returns an array of removed elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to modify. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of removed elements. + +#### Example +```js +var array = [1, 2, 3, 4, 5, 6]; +var evens = _.remove(array, function(num) { return num % 2 == 0; }); + +console.log(array); +// => [1, 3, 5] + +console.log(evens); +// => [2, 4, 6] +``` + +* * * + + + + ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3757 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3862 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1865,7 +1930,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3790 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3895 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1895,20 +1960,20 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3942 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Aliases *any* #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1941,17 +2006,17 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3998 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. -If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. +If a property name is provided for `callback`, the created "_.pluck" style callback will return the property value of the given element. -If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. +If an object is provided for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -1978,7 +2043,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4034 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -2002,7 +2067,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3963 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4068 "View in source") [Ⓣ][1] Performs a deep comparison of each element in a `collection` to the given `properties` object, returning an array of all elements that have equivalent property values. @@ -2042,7 +2107,7 @@ _.where(stooges, { 'quotes': ['Poifect!'] }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5025 "View in source") [Ⓣ][1] Creates a function this is restricted to executing `func`, with the `this` binding and arguments of the created function, only after it is called `n` times. @@ -2070,7 +2135,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4913 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5055 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -2101,7 +2166,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5083 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @@ -2132,7 +2197,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5129 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -2173,7 +2238,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5021 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5163 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -2211,12 +2276,10 @@ welcome('curly'); ### `_.createCallback([func=identity, thisArg, argCount])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5207 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name, the created callback will return the property value for a given element. If `func` is an object, the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. -Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. - #### Arguments 1. `[func=identity]` *(Mixed)*: The value to convert to a callback. 2. `[thisArg]` *(Mixed)*: The `this` binding of the created callback. @@ -2242,19 +2305,6 @@ _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) { _.filter(stooges, 'age__gt45'); // => [{ 'name': 'larry', 'age': 50 }] - -// create mixins with support for "_.pluck" and "_.where" callback shorthands -_.mixin({ - 'toLookup': function(collection, callback, thisArg) { - callback = _.createCallback(callback, thisArg); - return _.reduce(collection, function(result, value, index, collection) { - return (result[callback(value, index, collection)] = value, result); - }, {}); - } -}); - -_.toLookup(stooges, 'name'); -// => { 'moe': { 'name': 'moe', 'age': 40 }, 'larry': { 'name': 'larry', 'age': 50 } } ``` * * * @@ -2265,7 +2315,7 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5187 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5283 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2306,7 +2356,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, { ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5380 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -2331,7 +2381,7 @@ _.defer(function() { console.log('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5310 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5406 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2358,7 +2408,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5335 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5431 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. The result cache is exposed as the `cache` property on the memoized function. @@ -2384,7 +2434,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5365 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5461 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2410,7 +2460,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5400 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5496 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. @@ -2437,7 +2487,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5431 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5527 "View in source") [Ⓣ][1] This method is like `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2474,7 +2524,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5562 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2508,7 +2558,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5507 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5603 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2544,9 +2594,9 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1850 "View in source") [Ⓣ][1] -Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. +Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is provided, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. #### Aliases *extend* @@ -2582,9 +2632,9 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1857 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1903 "View in source") [Ⓣ][1] -Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. +Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is provided, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. #### Arguments 1. `value` *(Mixed)*: The value to clone. @@ -2629,9 +2679,9 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1955 "View in source") [Ⓣ][1] -Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. +Creates a deep clone of `value`. If a `callback` function is provided, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. Note: This method is loosely based on the structured clone algorithm. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm. @@ -2675,7 +2725,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -2701,13 +2751,13 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2001 "View in source") [Ⓣ][1] This method is like `_.findIndex`, except that it returns the key of the element that passes the callback check, instead of the element itself. #### Arguments 1. `object` *(Object)*: The object to search. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -2729,13 +2779,13 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.findLastKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2033 "View in source") [Ⓣ][1] This method is like `_.findKey`, except that it iterates over elements of a `collection` in the opposite order. #### Arguments 1. `object` *(Object)*: The object to search. -2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is provided, it will be used to create a "_.pluck" or "_.where" style callback, respectively. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns @@ -2757,7 +2807,7 @@ _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2028 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2074 "View in source") [Ⓣ][1] Iterates over own and inherited enumerable properties of a given `object`, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2793,7 +2843,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forInRight(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2058 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2104 "View in source") [Ⓣ][1] This method is like `_.forIn`, except that it iterates over elements of a `collection` in the opposite order. @@ -2829,7 +2879,7 @@ _.forInRight(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2097 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2143 "View in source") [Ⓣ][1] Iterates over own enumerable properties of a given `object`, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2857,7 +2907,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.forOwnRight(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2163 "View in source") [Ⓣ][1] This method is like `_.forOwn`, except that it iterates over elements of a `collection` in the opposite order. @@ -2885,7 +2935,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2192 "View in source") [Ⓣ][1] Creates a sorted array of property names of all enumerable properties, own and inherited, of `object` that have function values. @@ -2896,7 +2946,7 @@ Creates a sorted array of property names of all enumerable properties, own and i 1. `object` *(Object)*: The object to inspect. #### Returns -*(Array)*: Returns a new array of property names that have function values. +*(Array)*: Returns an array of property names that have function values. #### Example ```js @@ -2912,7 +2962,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2217 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2937,7 +2987,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2188 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2234 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2961,7 +3011,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1632 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1678 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2988,7 +3038,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1659 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1705 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -3015,7 +3065,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2260 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -3039,7 +3089,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2231 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2277 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -3063,7 +3113,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2248 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2294 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -3087,7 +3137,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2319 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -3117,9 +3167,9 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2330 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2376 "View in source") [Ⓣ][1] -Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. +Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is provided, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. #### Arguments 1. `a` *(Mixed)*: The value to compare. @@ -3162,7 +3212,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2362 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2408 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -3200,7 +3250,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2379 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2425 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -3224,7 +3274,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2488 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -3259,7 +3309,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2464 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2510 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -3286,7 +3336,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2483 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2529 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3312,7 +3362,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2455 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -3342,7 +3392,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2511 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2557 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -3377,7 +3427,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2582 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3401,7 +3451,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2553 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2599 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3425,7 +3475,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2570 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2616 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3449,7 +3499,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1692 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1738 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -3457,7 +3507,7 @@ Creates an array composed of the own enumerable property names of `object`. 1. `object` *(Object)*: The object to inspect. #### Returns -*(Array)*: Returns a new array of property names. +*(Array)*: Returns an array of property names. #### Example ```js @@ -3473,9 +3523,9 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2625 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2671 "View in source") [Ⓣ][1] -Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. +Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is provided, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. #### Arguments 1. `object` *(Object)*: The destination object. @@ -3529,9 +3579,9 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2681 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2727 "View in source") [Ⓣ][1] -Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. +Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is provided, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. #### Arguments 1. `object` *(Object)*: The source object. @@ -3560,7 +3610,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2716 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2762 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3584,9 +3634,9 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2755 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2801 "View in source") [Ⓣ][1] -Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. +Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is provided, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. #### Arguments 1. `object` *(Object)*: The source object. @@ -3615,7 +3665,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2810 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] An alternative to `_.reduce`, this method transforms an `object` to a new `accumulator` object which is the result of running each of its elements through the `callback`, with each `callback` execution potentially mutating the `accumulator` object. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3652,7 +3702,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2889 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3660,7 +3710,7 @@ Creates an array composed of the own enumerable property values of `object`. 1. `object` *(Object)*: The object to inspect. #### Returns -*(Array)*: Returns a new array of property values. +*(Array)*: Returns an array of property values. #### Example ```js @@ -3683,7 +3733,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5627 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3707,7 +3757,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5645 "View in source") [Ⓣ][1] This method returns the first argument passed to it. @@ -3732,7 +3782,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5575 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5671 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3762,7 +3812,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5610 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5709 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3782,7 +3832,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value [, radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5733 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0`, a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3809,9 +3859,9 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5757 "View in source") [Ⓣ][1] -Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. +Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided, a number between `0` and the given number will be returned. #### Arguments 1. `[min=0]` *(Number)*: The minimum possible value. @@ -3837,7 +3887,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5701 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5801 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey, then `undefined` is returned. @@ -3890,7 +3940,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5892 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3978,7 +4028,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6017 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3988,7 +4038,7 @@ Executes the `callback` function `n` times, returning an array of the results of 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns -*(Array)*: Returns a new array of the results of each `callback` execution. +*(Array)*: Returns an array of the results of each `callback` execution. #### Example ```js @@ -4010,7 +4060,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5944 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6044 "View in source") [Ⓣ][1] The inverse of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -4034,9 +4084,9 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6064 "View in source") [Ⓣ][1] -Generates a unique ID. If `prefix` is passed, the ID will be appended to it. +Generates a unique ID. If `prefix` is provided, the ID will be appended to it. #### Arguments 1. `[prefix]` *(String)*: The value to prefix the ID with. @@ -4068,7 +4118,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L823 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L824 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -4087,7 +4137,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6266 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6368 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -4099,7 +4149,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L641 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L642 "View in source") [Ⓣ][1] *(Object)*: An object used to flag environments features. @@ -4111,7 +4161,7 @@ A reference to the `lodash` function. ### `_.support.argsClass` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L666 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L667 "View in source") [Ⓣ][1] *(Boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*. @@ -4123,7 +4173,7 @@ A reference to the `lodash` function. ### `_.support.argsObject` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L659 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` objects are `Object` objects *(all but Narwhal and Opera < `10.5`)*. @@ -4135,7 +4185,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L675 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L676 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `name` or `message` properties of `Error.prototype` are enumerable by default. *(IE < `9`, Safari < `5.1`)* @@ -4147,7 +4197,7 @@ A reference to the `lodash` function. ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L688 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L689 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `prototype` properties are enumerable by default. @@ -4161,7 +4211,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.fastBind` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L696 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L697 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Function#bind` exists and is inferred to be fast *(all but V8)*. @@ -4173,7 +4223,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumArgs` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L713 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L714 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*. @@ -4185,7 +4235,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L725 "View in source") [Ⓣ][1] *(Boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -4199,7 +4249,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.ownLast` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L704 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L705 "View in source") [Ⓣ][1] *(Boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*. @@ -4211,7 +4261,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L739 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -4225,7 +4275,7 @@ Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` a ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L749 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L750 "View in source") [Ⓣ][1] *(Boolean)*: Detect lack of support for accessing string characters by index. @@ -4239,7 +4289,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L775 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L776 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -4251,7 +4301,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L783 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L784 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -4263,7 +4313,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L791 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L792 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -4275,7 +4325,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L799 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L800 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -4287,7 +4337,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L807 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L808 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -4299,7 +4349,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L815 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L816 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.js b/lodash.js index d8c999d9d..d437a6125 100644 --- a/lodash.js +++ b/lodash.js @@ -1820,7 +1820,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object. Subsequent sources will overwrite property assignments of previous - * sources. If a `callback` function is passed, it will be executed to produce + * sources. If a `callback` function is provided, it will be executed to produce * the assigned values. The `callback` is bound to `thisArg` and invoked with * two arguments; (objectValue, sourceValue). * @@ -1863,7 +1863,7 @@ /** * Creates a clone of `value`. If `deep` is `true`, nested objects will also * be cloned, otherwise they will be assigned by reference. If a `callback` - * function is passed, it will be executed to produce the cloned values. If + * function is provided, it will be executed to produce the cloned values. If * `callback` returns `undefined`, cloning will be handled by the method instead. * The `callback` is bound to `thisArg` and invoked with one argument; (value). * @@ -1912,7 +1912,7 @@ } /** - * Creates a deep clone of `value`. If a `callback` function is passed, + * Creates a deep clone of `value`. If a `callback` function is provided, * it will be executed to produce the cloned values. If `callback` returns * `undefined`, cloning will be handled by the method instead. The `callback` * is bound to `thisArg` and invoked with one argument; (value). @@ -1987,8 +1987,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * iteration. If a property name or object is provided, it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the key of the found element, else `undefined`. * @example @@ -2019,8 +2019,8 @@ * @category Objects * @param {Object} object The object to search. * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * iteration. If a property name or object is provided, it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the key of the found element, else `undefined`. * @example @@ -2337,7 +2337,7 @@ /** * Performs a deep comparison between two values to determine if they are - * equivalent to each other. If `callback` is passed, it will be executed to + * equivalent to each other. If `callback` is provided, it will be executed to * compare values. If `callback` returns `undefined`, comparisons will be handled * by the method instead. The `callback` is bound to `thisArg` and invoked with * two arguments; (a, b). @@ -2621,7 +2621,7 @@ * Recursively merges own enumerable properties of the source object(s), that * don't resolve to `undefined`, into the destination object. Subsequent sources * will overwrite property assignments of previous sources. If a `callback` function - * is passed, it will be executed to produce the merged values of the destination + * is provided, it will be executed to produce the merged values of the destination * and source properties. If `callback` returns `undefined`, merging will be * handled by the method instead. The `callback` is bound to `thisArg` and * invoked with two arguments; (objectValue, sourceValue). @@ -2701,7 +2701,7 @@ /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of - * property names. If a `callback` function is passed, it will be executed + * property names. If a `callback` function is provided, it will be executed * for each property in the `object`, omitting the properties `callback` * returns truthy for. The `callback` is bound to `thisArg` and invoked * with three arguments; (value, key, object). @@ -2775,7 +2775,7 @@ /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property - * names. If `callback` is passed, it will be executed for each property in the + * names. If `callback` is provided, it will be executed for each property in the * `object`, picking the properties `callback` returns truthy for. The `callback` * is bound to `thisArg` and invoked with three arguments; (value, key, object). * @@ -2992,10 +2992,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3003,9 +3003,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -3028,10 +3028,10 @@ * `collection`. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3040,9 +3040,9 @@ * @alias all * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if all elements pass the callback check, * else `false`. @@ -3090,10 +3090,10 @@ * the `callback` returns truthy for. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3102,9 +3102,9 @@ * @alias select * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that passed the callback check. * @example @@ -3154,10 +3154,10 @@ * `callback` returns truthy for. The `callback` is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3166,9 +3166,9 @@ * @alias detect, findWhere * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -3225,9 +3225,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the found element, else `undefined`. * @example @@ -3329,10 +3329,10 @@ * the key. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false` * @@ -3340,9 +3340,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -3368,10 +3368,10 @@ * The `callback` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3379,9 +3379,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns the composed aggregate object. * @example @@ -3444,10 +3444,10 @@ * through the `callback`. The `callback` is bound to `thisArg` and invoked with * three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3456,9 +3456,9 @@ * @alias collect * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of the results of each `callback` execution. * @example @@ -3497,15 +3497,15 @@ } /** - * Retrieves the maximum value of an `array`. If `callback` is passed, + * Retrieves the maximum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3513,9 +3513,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the maximum value. * @example @@ -3566,15 +3566,15 @@ } /** - * Retrieves the minimum value of an `array`. If `callback` is passed, + * Retrieves the minimum value of an `array`. If `callback` is provided, * it will be executed for each value in the `array` to generate the * criterion by which the value is ranked. The `callback` is bound to `thisArg` * and invoked with three arguments; (value, index, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3582,9 +3582,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the minimum value. * @example @@ -3744,10 +3744,10 @@ * The opposite of `_.filter`, this method returns the elements of a * `collection` that `callback` does **not** return truthy for. * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3755,9 +3755,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of elements that did **not** pass the * callback check. @@ -3791,10 +3791,10 @@ * for and returns an array of removed elements. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3802,9 +3802,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to modify. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of removed elements. * @example @@ -3903,10 +3903,10 @@ * does not iterate over the entire `collection`. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3915,9 +3915,9 @@ * @alias any * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Boolean} Returns `true` if any element passes the callback check, * else `false`. @@ -3967,10 +3967,10 @@ * equal elements. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -3978,9 +3978,9 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new array of sorted elements. * @example @@ -4150,9 +4150,9 @@ * @memberOf _ * @category Arrays * @param {Array} array The array to search. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the index of the found element, else `-1`. * @example @@ -4183,9 +4183,9 @@ * @memberOf _ * @category Arrays * @param {Array} array The array to search. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the index of the found element, else `-1`. * @example @@ -4209,16 +4209,16 @@ } /** - * Gets the first element of the `array`. If a number `n` is passed, the first - * `n` elements of the `array` are returned. If a `callback` function is passed, + * Gets the first element of the `array`. If a number `n` is provided, the first + * `n` elements of the `array` are returned. If a `callback` function is provided, * elements at the beginning of the array are returned as long as the `callback` * returns truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4229,7 +4229,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the first element(s) of `array`. @@ -4289,14 +4289,14 @@ /** * Flattens a nested array (the nesting can be to any depth). If `isShallow` * is truthy, `array` will only be flattened a single level. If `callback` - * is passed, each element of `array` is passed through a `callback` before + * is provided, each element of `array` is provided through a `callback` before * flattening. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4305,9 +4305,9 @@ * @category Arrays * @param {Array} array The array to flatten. * @param {Boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a new flattened array. * @example @@ -4376,16 +4376,16 @@ } /** - * Gets all but the last element of `array`. If a number `n` is passed, the + * Gets all but the last element of `array`. If a number `n` is provided, the * last `n` elements are excluded from the result. If a `callback` function - * is passed, elements at the end of the array are excluded from the result + * is provided, elements at the end of the array are excluded from the result * as long as the `callback` returns truthy. The `callback` is bound to * `thisArg` and invoked with three arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4395,7 +4395,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -4510,17 +4510,17 @@ } /** - * Gets the last element of the `array`. If a number `n` is passed, the + * Gets the last element of the `array`. If a number `n` is provided, the * last `n` elements of the `array` are returned. If a `callback` function - * is passed, elements at the end of the array are returned as long as the + * is provided, elements at the end of the array are returned as long as the * `callback` returns truthy. The `callback` is bound to `thisArg` and * invoked with three arguments;(value, index, array). * * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4530,7 +4530,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n] The function called * per element or the number of elements to return. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Mixed} Returns the last element(s) of `array`. @@ -4708,16 +4708,16 @@ /** * The opposite of `_.initial`, this method gets all but the first value of - * `array`. If a number `n` is passed, the first `n` values are excluded from - * the result. If a `callback` function is passed, elements at the beginning + * `array`. If a number `n` is provided, the first `n` values are excluded from + * the result. If a `callback` function is provided, elements at the beginning * of the array are excluded from the result as long as the `callback` returns * truthy. The `callback` is bound to `thisArg` and invoked with three * arguments; (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4728,7 +4728,7 @@ * @param {Array} array The array to query. * @param {Function|Object|Number|String} [callback|n=1] The function called * per element or the number of elements to exclude. If a property name or - * object is passed, it will be used to create a "_.pluck" or "_.where" + * object is provided, it will be used to create a "_.pluck" or "_.where" * style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a slice of `array`. @@ -4783,14 +4783,14 @@ /** * Uses a binary search to determine the smallest index at which the `value` * should be inserted into `array` in order to maintain the sort order of the - * sorted `array`. If `callback` is passed, it will be executed for `value` and - * each element in `array` to compute their sort ranking. The `callback` is - * bound to `thisArg` and invoked with one argument; (value). + * sorted `array`. If `callback` is provided, it will be executed for `value` + * and each element in `array` to compute their sort ranking. The `callback` + * is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4799,9 +4799,9 @@ * @category Arrays * @param {Array} array The array to inspect. * @param {Mixed} value The value to evaluate. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Number} Returns the index at which the value should be inserted * into `array`. @@ -4866,14 +4866,15 @@ /** * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` - * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through the `callback` before uniqueness is computed. - * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). + * for `isSorted` will run a faster algorithm. If `callback` is provided, each + * element of `array` is provided through the `callback` before uniqueness is + * computed. The `callback` is bound to `thisArg` and invoked with three arguments; + * (value, index, array). * - * If a property name is passed for `callback`, the created "_.pluck" style + * If a property name is provided for `callback`, the created "_.pluck" style * callback will return the property value of the given element. * - * If an object is passed for `callback`, the created "_.where" style callback + * If an object is provided for `callback`, the created "_.where" style callback * will return `true` for elements that have the properties of the given object, * else `false`. * @@ -4883,9 +4884,9 @@ * @category Arrays * @param {Array} array The array to process. * @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted. - * @param {Function|Object|String} [callback=identity] The function called per - * iteration. If a property name or object is passed, it will be used to create - * a "_.pluck" or "_.where" style callback, respectively. + * @param {Function|Object|String} [callback=identity] The function called + * per iteration. If a property name or object is provided, it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array} Returns a duplicate-value-free array. * @example @@ -5736,7 +5737,8 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one - * argument is passed, a number between `0` and the given number will be returned. + * argument is provided, a number between `0` and the given number will be + * returned. * * @static * @memberOf _ @@ -6044,7 +6046,7 @@ } /** - * Generates a unique ID. If `prefix` is passed, the ID will be appended to it. + * Generates a unique ID. If `prefix` is provided, the ID will be appended to it. * * @static * @memberOf _