mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Ensure more Arrays methods accept arguments objects and allow falsey arguments.
Former-commit-id: 06dfbb25236c6daf3efc6b0c1d06d00cf17180b8
This commit is contained in:
43
lodash.js
43
lodash.js
@@ -488,7 +488,6 @@
|
||||
/** Native method shortcuts */
|
||||
var ceil = Math.ceil,
|
||||
clearTimeout = context.clearTimeout,
|
||||
concat = arrayRef.concat,
|
||||
floor = Math.floor,
|
||||
fnToString = Function.prototype.toString,
|
||||
getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
||||
@@ -2517,7 +2516,7 @@
|
||||
if (isFunc) {
|
||||
callback = lodash.createCallback(callback, thisArg);
|
||||
} else {
|
||||
var props = concat.apply(arrayRef, nativeSlice.call(arguments, 1));
|
||||
var props = basicFlatten(nativeSlice.call(arguments, 1));
|
||||
}
|
||||
forIn(object, function(value, key, object) {
|
||||
if (isFunc
|
||||
@@ -2568,8 +2567,9 @@
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The source object.
|
||||
* @param {Array|Function|String} callback|[prop1, prop2, ...] The function called
|
||||
* per iteration or properties to pick, either as individual arguments or arrays.
|
||||
* @param {Array|Function|String} callback|[prop1, prop2, ...] The function
|
||||
* called per iteration or property names to pick, specified as individual
|
||||
* property names or arrays of property names.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Object} Returns an object composed of the picked properties.
|
||||
* @example
|
||||
@@ -2586,7 +2586,7 @@
|
||||
var result = {};
|
||||
if (typeof callback != 'function') {
|
||||
var index = -1,
|
||||
props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),
|
||||
props = basicFlatten(nativeSlice.call(arguments, 1)),
|
||||
length = isObject(object) ? props.length : 0;
|
||||
|
||||
while (++index < length) {
|
||||
@@ -2693,8 +2693,8 @@
|
||||
* @memberOf _
|
||||
* @category Collections
|
||||
* @param {Array|Object|String} collection The collection to iterate over.
|
||||
* @param {Array|Number|String} [index1, index2, ...] The indexes of
|
||||
* `collection` to retrieve, either as individual arguments or arrays.
|
||||
* @param {Array|Number|String} [index1, index2, ...] The indexes of `collection`
|
||||
* to retrieve, specified as individual indexes or arrays of indexes.
|
||||
* @returns {Array} Returns a new array of elements corresponding to the
|
||||
* provided indexes.
|
||||
* @example
|
||||
@@ -2707,7 +2707,7 @@
|
||||
*/
|
||||
function at(collection) {
|
||||
var index = -1,
|
||||
props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),
|
||||
props = basicFlatten(nativeSlice.call(arguments, 1)),
|
||||
length = props.length,
|
||||
result = Array(length);
|
||||
|
||||
@@ -3733,16 +3733,17 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of `array` elements not present in the other arrays
|
||||
* using strict equality for comparisons, i.e. `===`.
|
||||
* Creates an arrat with all occurrences of the passed values removed using
|
||||
* using strict equality for comparisons, i.e. `===`. Values to exclude may
|
||||
* be specified as individual arguments or as arrays.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to process.
|
||||
* @param {Array} [array1, array2, ...] Arrays to check.
|
||||
* @returns {Array} Returns a new array of `array` elements not present in the
|
||||
* other arrays.
|
||||
* @param {Array} [array1, array2, ...] The values to exclude, specified as
|
||||
* individual values or arrays of values.
|
||||
* @returns {Array} Returns a new filtered array.
|
||||
* @example
|
||||
*
|
||||
* _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
||||
@@ -3752,7 +3753,7 @@
|
||||
var index = -1,
|
||||
indexOf = getIndexOf(),
|
||||
length = array ? array.length : 0,
|
||||
seen = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),
|
||||
seen = basicFlatten(nativeSlice.call(arguments, 1)),
|
||||
result = [];
|
||||
|
||||
var isLarge = length >= largeArraySize && indexOf === basicIndexOf;
|
||||
@@ -4417,10 +4418,7 @@
|
||||
* // => [1, 2, 3, 101, 10]
|
||||
*/
|
||||
function union(array) {
|
||||
if (!array) {
|
||||
arguments[0] = arrayRef;
|
||||
}
|
||||
return basicUniq(basicFlatten(arguments, true));
|
||||
return basicUniq(basicFlatten(compact(arguments), true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4469,14 +4467,14 @@
|
||||
var uniq = overloadWrapper(basicUniq);
|
||||
|
||||
/**
|
||||
* Creates an array with all occurrences of the passed values removed using
|
||||
* Creates an array excluding all occurrences of the passed values using
|
||||
* strict equality for comparisons, i.e. `===`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to filter.
|
||||
* @param {Mixed} [value1, value2, ...] Values to remove.
|
||||
* @param {Mixed} [value1, value2, ...] Values to exclude.
|
||||
* @returns {Array} Returns a new filtered array.
|
||||
* @example
|
||||
*
|
||||
@@ -4618,7 +4616,8 @@
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Object} object The object to bind and assign the bound methods to.
|
||||
* @param {String} [methodName1, methodName2, ...] Method names on the object to bind.
|
||||
* @param {String} [methodName1, methodName2, ...] The object method names to
|
||||
* bind, specified as individual values or arrays of values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
@@ -4632,7 +4631,7 @@
|
||||
* // => alerts 'clicked docs', when the button is clicked
|
||||
*/
|
||||
function bindAll(object) {
|
||||
var funcs = arguments.length > 1 ? concat.apply(arrayRef, nativeSlice.call(arguments, 1)) : functions(object),
|
||||
var funcs = arguments.length > 1 ? basicFlatten(nativeSlice.call(arguments, 1)) : functions(object),
|
||||
index = -1,
|
||||
length = funcs.length;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user