mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Rebuild dist.
This commit is contained in:
393
dist/lodash.underscore.js
vendored
393
dist/lodash.underscore.js
vendored
@@ -1140,57 +1140,44 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first element or first `n` elements of an array. If a callback
|
||||
* is provided elements at the beginning of the array are returned as long
|
||||
* as the callback returns truey. The callback is bound to `thisArg` and
|
||||
* invoked with three arguments; (value, index, array).
|
||||
*
|
||||
* 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`.
|
||||
* Creates an array with `n` elements dropped from the beginning of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias head, take
|
||||
* @type Function
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|number|string} [callback] 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.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {*} Returns the first element(s) of `array`.
|
||||
* @param {number} [n=1] The number of elements to drop.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.drop([1, 2, 3], 2);
|
||||
* // => [3]
|
||||
*
|
||||
* _.drop([1, 2, 3], 5);
|
||||
* // => []
|
||||
*
|
||||
* _.drop([1, 2, 3], 0);
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
var drop = rest;
|
||||
|
||||
/**
|
||||
* Gets the first element of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias head
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to query.
|
||||
* @returns {*} Returns the first element of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.first([1, 2, 3]);
|
||||
* // => 1
|
||||
*
|
||||
* // returns the first two elements
|
||||
* _.first([1, 2, 3], 2);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* // returns elements from the beginning until the callback result is falsey
|
||||
* _.first([1, 2, 3], function(num) {
|
||||
* return num < 3;
|
||||
* });
|
||||
* // => [1, 2]
|
||||
*
|
||||
* var characters = [
|
||||
* { 'name': 'barney', 'employer': 'slate', 'blocked': true },
|
||||
* { 'name': 'fred', 'employer': 'slate' },
|
||||
* { 'name': 'pebbles', 'employer': 'na', 'blocked': true }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.first(characters, 'blocked');
|
||||
* // => [{ 'name': 'barney', 'employer': 'slate', 'blocked': true }]
|
||||
*
|
||||
* // using "_.where" callback shorthand
|
||||
* _.pluck(_.first(characters, { 'employer': 'slate' }), 'name');
|
||||
* // => ['barney', 'fred']
|
||||
* _.first([]);
|
||||
* // => undefined
|
||||
*/
|
||||
function first(array, n, guard) {
|
||||
if (n == null || guard) {
|
||||
@@ -1201,7 +1188,7 @@
|
||||
|
||||
/**
|
||||
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
||||
* is truey, the array will only be flattened a single level. If a callback
|
||||
* is truthy, the array will only be flattened a single level. If a callback
|
||||
* is provided each element of the array is passed through the callback before
|
||||
* flattening. The callback is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, index, array).
|
||||
@@ -1291,56 +1278,17 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all but the last element or last `n` elements of an array. If a
|
||||
* callback is provided elements at the end of the array are excluded from
|
||||
* the result as long as the callback returns truey. The callback is bound
|
||||
* to `thisArg` and invoked with three arguments; (value, index, array).
|
||||
*
|
||||
* 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`.
|
||||
* Gets all but the last element of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|number|string} [callback=1] 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.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a slice of `array`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.initial([1, 2, 3]);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* // excludes the last two elements
|
||||
* _.initial([1, 2, 3], 2);
|
||||
* // => [1]
|
||||
*
|
||||
* // excludes elements from the end until the callback fails
|
||||
* _.initial([1, 2, 3], function(num) {
|
||||
* return num > 1;
|
||||
* });
|
||||
* // => [1]
|
||||
*
|
||||
* var characters = [
|
||||
* { 'name': 'barney', 'employer': 'slate' },
|
||||
* { 'name': 'fred', 'employer': 'slate', 'blocked': true },
|
||||
* { 'name': 'pebbles', 'employer': 'na', 'blocked': true }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.initial(characters, 'blocked');
|
||||
* // => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }]
|
||||
*
|
||||
* // using "_.where" callback shorthand
|
||||
* _.pluck(_.initial(characters, { 'employer': 'na' }), 'name');
|
||||
* // => ['barney', 'fred']
|
||||
*/
|
||||
function initial(array, n, guard) {
|
||||
var length = array ? array.length : 0;
|
||||
@@ -1396,56 +1344,17 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last element or last `n` elements of an array. If a callback is
|
||||
* provided elements at the end of the array are returned as long as the
|
||||
* callback returns truey. The callback is bound to `thisArg` and invoked
|
||||
* with three arguments; (value, index, array).
|
||||
*
|
||||
* 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`.
|
||||
* Gets the last element of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|number|string} [callback] 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.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {*} Returns the last element(s) of `array`.
|
||||
* @returns {*} Returns the last element of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.last([1, 2, 3]);
|
||||
* // => 3
|
||||
*
|
||||
* // returns the last two elements
|
||||
* _.last([1, 2, 3], 2);
|
||||
* // => [2, 3]
|
||||
*
|
||||
* // returns elements from the end until the callback fails
|
||||
* _.last([1, 2, 3], function(num) {
|
||||
* return num > 1;
|
||||
* });
|
||||
* // => [2, 3]
|
||||
*
|
||||
* var characters = [
|
||||
* { 'name': 'barney', 'employer': 'slate' },
|
||||
* { 'name': 'fred', 'employer': 'slate', 'blocked': true },
|
||||
* { 'name': 'pebbles', 'employer': 'na', 'blocked': true }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.pluck(_.last(characters, 'blocked'), 'name');
|
||||
* // => ['fred', 'pebbles']
|
||||
*
|
||||
* // using "_.where" callback shorthand
|
||||
* _.last(characters, { 'employer': 'na' });
|
||||
* // => [{ 'name': 'pebbles', 'employer': 'na', 'blocked': true }]
|
||||
*/
|
||||
function last(array, n, guard) {
|
||||
var length = array ? array.length : 0;
|
||||
@@ -1461,13 +1370,6 @@
|
||||
* equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
|
||||
* as the offset from the end of the 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 Arrays
|
||||
@@ -1551,58 +1453,18 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* The opposite of `_.initial`; this method gets all but the first element or
|
||||
* first `n` elements of an array. If a callback function is provided elements
|
||||
* at the beginning of the array are excluded from the result as long as the
|
||||
* callback returns truey. The callback is bound to `thisArg` and invoked
|
||||
* with three arguments; (value, index, array).
|
||||
*
|
||||
* 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`.
|
||||
* Gets all but the first element of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias drop, tail
|
||||
* @alias tail
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function|Object|number|string} [callback=1] 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.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a slice of `array`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.rest([1, 2, 3]);
|
||||
* // => [2, 3]
|
||||
*
|
||||
* // excludes the first two elements
|
||||
* _.rest([1, 2, 3], 2);
|
||||
* // => [3]
|
||||
*
|
||||
* // excludes elements from the beginning until the callback fails
|
||||
* _.rest([1, 2, 3], function(num) {
|
||||
* return num < 3;
|
||||
* });
|
||||
* // => [3]
|
||||
*
|
||||
* var characters = [
|
||||
* { 'name': 'barney', 'employer': 'slate', 'blocked': true },
|
||||
* { 'name': 'fred', 'employer': 'slate' },
|
||||
* { 'name': 'pebbles', 'employer': 'na', 'blocked': true }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.pluck(_.rest(characters, 'blocked'), 'name');
|
||||
* // => ['fred', 'pebbles']
|
||||
*
|
||||
* // using "_.where" callback shorthand
|
||||
* _.rest(characters, { 'employer': 'slate' });
|
||||
* // => [{ 'name': 'pebbles', 'employer': 'na', 'blocked': true }]
|
||||
*/
|
||||
function rest(array, n, guard) {
|
||||
if (n == null || guard) {
|
||||
@@ -1721,6 +1583,29 @@
|
||||
return low;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of the first `n` elements of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Arrays
|
||||
* @param {Array} array The array to query.
|
||||
* @param {number} [n=1] The number of elements to take.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.take([1, 2, 3], 2);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* _.take([1, 2, 3], 5);
|
||||
* // => [1, 2, 3]
|
||||
*
|
||||
* _.take([1, 2, 3], -1);
|
||||
* // => []
|
||||
*/
|
||||
var take = first;
|
||||
|
||||
/**
|
||||
* Creates an array of unique values, in order, of the provided arrays using
|
||||
* strict equality for comparisons, i.e. `===`.
|
||||
@@ -2084,14 +1969,14 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if the callback returns truey value for **all** elements of a
|
||||
* collection. The callback is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, index|key, collection).
|
||||
* Checks if the predicate returns truthy for **all** elements of a collection.
|
||||
* The predicate 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
|
||||
* If a property name is provided for `predicate` 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
|
||||
* If an object is provided for `predicate` the created "_.where" style callback
|
||||
* will return `true` for elements that have the properties of the given object,
|
||||
* else `false`.
|
||||
*
|
||||
@@ -2100,11 +1985,11 @@
|
||||
* @alias all
|
||||
* @category Collections
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function|Object|string} [callback=identity] The function called
|
||||
* @param {Function|Object|string} [predicate=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 {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {boolean} Returns `true` if all elements passed the callback check,
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {boolean} Returns `true` if all elements passed the predicate check,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
@@ -2124,36 +2009,36 @@
|
||||
* _.every(characters, { 'age': 36 });
|
||||
* // => false
|
||||
*/
|
||||
function every(collection, callback, thisArg) {
|
||||
function every(collection, predicate, thisArg) {
|
||||
var result = true;
|
||||
callback = createCallback(callback, thisArg, 3);
|
||||
|
||||
predicate = createCallback(predicate, thisArg, 3);
|
||||
var index = -1,
|
||||
length = collection ? collection.length : 0;
|
||||
|
||||
if (typeof length == 'number') {
|
||||
while (++index < length) {
|
||||
if (!callback(collection[index], index, collection)) {
|
||||
if (!predicate(collection[index], index, collection)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
return !(result = !!callback(value, index, collection)) && breakIndicator;
|
||||
return !(result = !!predicate(value, index, collection)) && breakIndicator;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over elements of a collection, returning an array of all elements
|
||||
* the callback returns truey for. The callback is bound to `thisArg` and
|
||||
* Iterates over elements of a collection returning an array of all elements
|
||||
* the predicate returns truthy for. The predicate 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
|
||||
* If a property name is provided for `predicate` 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
|
||||
* If an object is provided for `predicate` the created "_.where" style callback
|
||||
* will return `true` for elements that have the properties of the given object,
|
||||
* else `false`.
|
||||
*
|
||||
@@ -2162,11 +2047,11 @@
|
||||
* @alias select
|
||||
* @category Collections
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function|Object|string} [callback=identity] The function called
|
||||
* @param {Function|Object|string} [predicate=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 {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new array of elements that passed the callback check.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns a new array of elements that passed the predicate check.
|
||||
* @example
|
||||
*
|
||||
* var evens = _.filter([1, 2, 3, 4], function(num) { return num % 2 == 0; });
|
||||
@@ -2185,23 +2070,23 @@
|
||||
* _.filter(characters, { 'age': 36 });
|
||||
* // => [{ 'name': 'barney', 'age': 36 }]
|
||||
*/
|
||||
function filter(collection, callback, thisArg) {
|
||||
function filter(collection, predicate, thisArg) {
|
||||
var result = [];
|
||||
callback = createCallback(callback, thisArg, 3);
|
||||
|
||||
predicate = createCallback(predicate, 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)) {
|
||||
if (predicate(value, index, collection)) {
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
if (callback(value, index, collection)) {
|
||||
if (predicate(value, index, collection)) {
|
||||
result.push(value);
|
||||
}
|
||||
});
|
||||
@@ -2211,13 +2096,13 @@
|
||||
|
||||
/**
|
||||
* Iterates over elements of a collection, returning the first element that
|
||||
* the callback returns truey for. The callback is bound to `thisArg` and
|
||||
* the predicate returns truthy for. The predicate 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
|
||||
* If a property name is provided for `predicate` 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
|
||||
* If an object is provided for `predicate` the created "_.where" style callback
|
||||
* will return `true` for elements that have the properties of the given object,
|
||||
* else `false`.
|
||||
*
|
||||
@@ -2226,10 +2111,10 @@
|
||||
* @alias detect, findWhere
|
||||
* @category Collections
|
||||
* @param {Array|Object|string} collection The collection to search.
|
||||
* @param {Function|Object|string} [callback=identity] The function called
|
||||
* @param {Function|Object|string} [predicate=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 {*} [thisArg] The `this` binding of `callback`.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {*} Returns the found element, else `undefined`.
|
||||
* @example
|
||||
*
|
||||
@@ -2252,23 +2137,22 @@
|
||||
* _.find(characters, 'blocked');
|
||||
* // => { 'name': 'fred', 'age': 40, 'blocked': true }
|
||||
*/
|
||||
function find(collection, callback, thisArg) {
|
||||
callback = createCallback(callback, thisArg, 3);
|
||||
|
||||
function find(collection, predicate, thisArg) {
|
||||
predicate = createCallback(predicate, 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)) {
|
||||
if (predicate(value, index, collection)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var result;
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
if (callback(value, index, collection)) {
|
||||
if (predicate(value, index, collection)) {
|
||||
result = value;
|
||||
return breakIndicator;
|
||||
}
|
||||
@@ -2648,14 +2532,14 @@
|
||||
|
||||
/**
|
||||
* Creates an array of elements split into two groups, the first of which
|
||||
* contains elements the callback returns truey for, while the second of which
|
||||
* contains elements the callback returns falsey for. The callback is bound
|
||||
* contains elements the predicate returns truthy for, while the second of which
|
||||
* contains elements the predicate returns falsey for. The predicate 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
|
||||
* If a property name is provided for `predicate` 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
|
||||
* If an object is provided for `predicate` the created "_.where" style callback
|
||||
* will return `true` for elements that have the properties of the given object,
|
||||
* else `false`.
|
||||
*
|
||||
@@ -2663,10 +2547,10 @@
|
||||
* @memberOf _
|
||||
* @category Collections
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function|Object|string} [callback=identity] The function called
|
||||
* @param {Function|Object|string} [predicate=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 {*} [thisArg] The `this` binding of `callback`.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns a new array of grouped elements.
|
||||
* @example
|
||||
*
|
||||
@@ -2802,13 +2686,13 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* The opposite of `_.filter`; this method returns the elements of a
|
||||
* collection that the callback does **not** return truey for.
|
||||
* The opposite of `_.filter`; this method returns the elements of a collection
|
||||
* the predicate does **not** return truthy for.
|
||||
*
|
||||
* If a property name is provided for `callback` the created "_.pluck" style
|
||||
* If a property name is provided for `predicate` 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
|
||||
* If an object is provided for `predicate` the created "_.where" style callback
|
||||
* will return `true` for elements that have the properties of the given object,
|
||||
* else `false`.
|
||||
*
|
||||
@@ -2816,11 +2700,11 @@
|
||||
* @memberOf _
|
||||
* @category Collections
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function|Object|string} [callback=identity] The function called
|
||||
* @param {Function|Object|string} [predicate=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 {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new array of elements that failed the callback check.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Array} Returns a new array of elements that failed the predicate check.
|
||||
* @example
|
||||
*
|
||||
* var odds = _.reject([1, 2, 3, 4], function(num) { return num % 2 == 0; });
|
||||
@@ -2839,10 +2723,10 @@
|
||||
* _.reject(characters, { 'age': 36 });
|
||||
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
||||
*/
|
||||
function reject(collection, callback, thisArg) {
|
||||
callback = createCallback(callback, thisArg, 3);
|
||||
function reject(collection, predicate, thisArg) {
|
||||
predicate = createCallback(predicate, thisArg, 3);
|
||||
return filter(collection, function(value, index, collection) {
|
||||
return !callback(value, index, collection);
|
||||
return !predicate(value, index, collection);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2931,15 +2815,15 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the callback returns a truey value for **any** element of a
|
||||
* collection. The function returns as soon as it finds a 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).
|
||||
* Checks if the predicate returns truthy for **any** element of a collection.
|
||||
* The function returns as soon as it finds a passing value and does not iterate
|
||||
* over the entire collection. The predicate 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
|
||||
* If a property name is provided for `predicate` 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
|
||||
* If an object is provided for `predicate` the created "_.where" style callback
|
||||
* will return `true` for elements that have the properties of the given object,
|
||||
* else `false`.
|
||||
*
|
||||
@@ -2948,11 +2832,11 @@
|
||||
* @alias any
|
||||
* @category Collections
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function|Object|string} [callback=identity] The function called
|
||||
* @param {Function|Object|string} [predicate=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 {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {boolean} Returns `true` if any element passed the callback check,
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {boolean} Returns `true` if any element passed the predicate check,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
@@ -2972,22 +2856,22 @@
|
||||
* _.some(characters, { 'age': 1 });
|
||||
* // => false
|
||||
*/
|
||||
function some(collection, callback, thisArg) {
|
||||
function some(collection, predicate, thisArg) {
|
||||
var result;
|
||||
callback = createCallback(callback, thisArg, 3);
|
||||
|
||||
predicate = createCallback(predicate, thisArg, 3);
|
||||
var index = -1,
|
||||
length = collection ? collection.length : 0;
|
||||
|
||||
if (typeof length == 'number') {
|
||||
while (++index < length) {
|
||||
if (callback(collection[index], index, collection)) {
|
||||
if (predicate(collection[index], index, collection)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
baseEach(collection, function(value, index, collection) {
|
||||
return (result = callback(value, index, collection)) && breakIndicator;
|
||||
return (result = predicate(value, index, collection)) && breakIndicator;
|
||||
});
|
||||
}
|
||||
return !!result;
|
||||
@@ -4261,19 +4145,19 @@
|
||||
/**
|
||||
* 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 is provided it will be executed for each
|
||||
* property of `object` omitting the properties the callback returns truey
|
||||
* for. The callback is bound to `thisArg` and invoked with three arguments;
|
||||
* property names. If a predicate is provided it will be executed for each
|
||||
* property of `object` omitting the properties the predicate returns truthy
|
||||
* for. The predicate is bound to `thisArg` and invoked with three arguments;
|
||||
* (value, key, object).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The source object.
|
||||
* @param {Function|...string|string[]} [callback] The function called per
|
||||
* @param {Function|...string|string[]} [predicate] The function called per
|
||||
* iteration or property names to omit, specified as individual property
|
||||
* names or arrays of property names.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Object} Returns an object without the omitted properties.
|
||||
* @example
|
||||
*
|
||||
@@ -4339,19 +4223,19 @@
|
||||
/**
|
||||
* 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 a callback is provided it will be executed for each
|
||||
* property of `object` picking the properties the callback returns truey
|
||||
* for. The callback is bound to `thisArg` and invoked with three arguments;
|
||||
* property names. If a predicate is provided it will be executed for each
|
||||
* property of `object` picking the properties the predicate returns truthy
|
||||
* for. The predicate is bound to `thisArg` and invoked with three arguments;
|
||||
* (value, key, object).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The source object.
|
||||
* @param {Function|...string|string[]} [callback] The function called per
|
||||
* @param {Function|...string|string[]} [predicate] The function called per
|
||||
* iteration or property names to pick, specified as individual property
|
||||
* names or arrays of property names.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {Object} Returns an object composed of the picked properties.
|
||||
* @example
|
||||
*
|
||||
@@ -4702,9 +4586,9 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a "_.where" style function, which performs a deep comparison
|
||||
* between a given object and the `source` object, returning `true` if the
|
||||
* given object has equivalent property values, else `false`.
|
||||
* Creates a "_.where" style predicate function which performs a deep comparison
|
||||
* between a given object and the `source` object, returning `true` if the given
|
||||
* object has equivalent property values, else `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -4755,7 +4639,8 @@
|
||||
* @param {Function|Object} [object=lodash] object The destination object.
|
||||
* @param {Object} source The object of functions to add.
|
||||
* @param {Object} [options] The options object.
|
||||
* @param {boolean} [options.chain=true] Specify whether the functions added are chainable.
|
||||
* @param {boolean} [options.chain=true] Specify whether the functions added
|
||||
* are chainable.
|
||||
* @example
|
||||
*
|
||||
* function vowels(string) {
|
||||
@@ -4848,7 +4733,7 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a "_.pluck" style function, which returns the `key` value of a
|
||||
* Creates a "_.pluck" style function which returns the `key` value of a
|
||||
* given object.
|
||||
*
|
||||
* @static
|
||||
@@ -4880,7 +4765,7 @@
|
||||
/**
|
||||
* 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. If `floating` is truey or either `min` or `max` are floats a
|
||||
* returned. If `floating` is truthy or either `min` or `max` are floats a
|
||||
* floating-point number will be returned instead of an integer.
|
||||
*
|
||||
* @static
|
||||
@@ -5030,6 +4915,7 @@
|
||||
lodash.defer = defer;
|
||||
lodash.delay = delay;
|
||||
lodash.difference = difference;
|
||||
lodash.drop = drop;
|
||||
lodash.filter = filter;
|
||||
lodash.flatten = flatten;
|
||||
lodash.forEach = forEach;
|
||||
@@ -5073,7 +4959,6 @@
|
||||
|
||||
// add aliases
|
||||
lodash.collect = map;
|
||||
lodash.drop = rest;
|
||||
lodash.each = forEach;
|
||||
lodash.extend = assign;
|
||||
lodash.methods = functions;
|
||||
@@ -5140,9 +5025,9 @@
|
||||
lodash.first = first;
|
||||
lodash.last = last;
|
||||
lodash.sample = sample;
|
||||
lodash.take = first;
|
||||
|
||||
// add aliases
|
||||
lodash.take = first;
|
||||
lodash.head = first;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user