mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Avoid a, b variable names and cleanup _.isEqual docs.
This commit is contained in:
72
dist/lodash.underscore.js
vendored
72
dist/lodash.underscore.js
vendored
@@ -133,16 +133,16 @@
|
||||
* sort them in ascending order without guaranteeing a stable sort.
|
||||
*
|
||||
* @private
|
||||
* @param {*} a The value to compare to `b`.
|
||||
* @param {*} b The value to compare to `a`.
|
||||
* @param {*} value The value to compare to `other`.
|
||||
* @param {*} other The value to compare to `value`.
|
||||
* @returns {number} Returns the sort order indicator for `a`.
|
||||
*/
|
||||
function baseCompareAscending(a, b) {
|
||||
if (a !== b) {
|
||||
if (a > b || typeof a == 'undefined') {
|
||||
function baseCompareAscending(value, other) {
|
||||
if (value !== other) {
|
||||
if (value > other || typeof value == 'undefined') {
|
||||
return 1;
|
||||
}
|
||||
if (a < b || typeof b == 'undefined') {
|
||||
if (value < other || typeof other == 'undefined') {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -175,12 +175,12 @@
|
||||
* sort them in ascending order.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} a The object to compare to `b`.
|
||||
* @param {Object} b The object to compare to `a`.
|
||||
* @returns {number} Returns the sort order indicator for `a`.
|
||||
* @param {Object} value The object to compare to `other`.
|
||||
* @param {Object} other The object to compare to `object`.
|
||||
* @returns {number} Returns the sort order indicator for `object`.
|
||||
*/
|
||||
function compareAscending(a, b) {
|
||||
return baseCompareAscending(a.criteria, b.criteria) || a.index - b.index;
|
||||
function compareAscending(object, other) {
|
||||
return baseCompareAscending(object.criteria, other.criteria) || object.index - other.index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -473,8 +473,8 @@
|
||||
case 1: return function(value) {
|
||||
return func.call(thisArg, value);
|
||||
};
|
||||
case 2: return function(a, b) {
|
||||
return func.call(thisArg, a, b);
|
||||
case 2: return function(value, other) {
|
||||
return func.call(thisArg, value, other);
|
||||
};
|
||||
case 3: return function(value, index, collection) {
|
||||
return func.call(thisArg, value, index, collection);
|
||||
@@ -769,12 +769,12 @@
|
||||
* binding, that allows partial "_.where" style comparisons.
|
||||
*
|
||||
* @private
|
||||
* @param {*} a The value to compare.
|
||||
* @param {*} b The other value to compare.
|
||||
* @param {*} value The value to compare to `other`.
|
||||
* @param {*} other The value to compare to `value`.
|
||||
* @param {Function} [callback] The function to customize comparing values.
|
||||
* @param {Function} [isWhere=false] A flag to indicate performing partial comparisons.
|
||||
* @param {Array} [stackA=[]] Tracks traversed `a` objects.
|
||||
* @param {Array} [stackB=[]] Tracks traversed `b` objects.
|
||||
* @param {Array} [stackA=[]] Tracks traversed `value` objects.
|
||||
* @param {Array} [stackB=[]] Tracks traversed `other` objects.
|
||||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||||
*/
|
||||
function baseIsEqual(a, b, stackA, stackB) {
|
||||
@@ -2720,8 +2720,8 @@
|
||||
* @returns {*} Returns the accumulated value.
|
||||
* @example
|
||||
*
|
||||
* var list = [[0, 1], [2, 3], [4, 5]];
|
||||
* var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
|
||||
* var array = [[0, 1], [2, 3], [4, 5]];
|
||||
* _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []);
|
||||
* // => [4, 5, 2, 3, 0, 1]
|
||||
*/
|
||||
function reduceRight(collection, callback, accumulator, thisArg) {
|
||||
@@ -3630,8 +3630,8 @@
|
||||
* _.assign({ 'name': 'fred' }, { 'employer': 'slate' });
|
||||
* // => { 'name': 'fred', 'employer': 'slate' }
|
||||
*
|
||||
* var defaults = _.partialRight(_.assign, function(a, b) {
|
||||
* return typeof a == 'undefined' ? b : a;
|
||||
* var defaults = _.partialRight(_.assign, function(value, other) {
|
||||
* return typeof value == 'undefined' ? other : value;
|
||||
* });
|
||||
*
|
||||
* defaults({ 'name': 'barney' }, { 'name': 'fred', 'employer': 'slate' });
|
||||
@@ -3987,44 +3987,40 @@
|
||||
|
||||
/**
|
||||
* Performs a deep comparison between two values to determine if they are
|
||||
* equivalent to each other. If a callback is provided it will be executed
|
||||
* to compare values. If the callback returns `undefined` comparisons will
|
||||
* be handled by the method instead. The callback is bound to `thisArg` and
|
||||
* invoked with two arguments; (a, b).
|
||||
* equivalent. If a callback is provided it will be executed to compare
|
||||
* values. If the callback returns `undefined` comparisons will be handled
|
||||
* by the method instead. The callback is bound to `thisArg` and invoked
|
||||
* with two arguments; (value, other).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {*} a The value to compare.
|
||||
* @param {*} b The other value to compare.
|
||||
* @param {*} value The value to compare to `other`.
|
||||
* @param {*} other The value to compare to `value`.
|
||||
* @param {Function} [callback] The function to customize comparing values.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'name': 'fred' };
|
||||
* var copy = { 'name': 'fred' };
|
||||
* var other = { 'name': 'fred' };
|
||||
*
|
||||
* object == copy;
|
||||
* object == other;
|
||||
* // => false
|
||||
*
|
||||
* _.isEqual(object, copy);
|
||||
* _.isEqual(object, other);
|
||||
* // => true
|
||||
*
|
||||
* var words = ['hello', 'goodbye'];
|
||||
* var otherWords = ['hi', 'goodbye'];
|
||||
*
|
||||
* _.isEqual(words, otherWords, function(a, b) {
|
||||
* var reGreet = /^(?:hello|hi)$/i,
|
||||
* aGreet = _.isString(a) && reGreet.test(a),
|
||||
* bGreet = _.isString(b) && reGreet.test(b);
|
||||
*
|
||||
* return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
|
||||
* _.isEqual(words, otherWords, function() {
|
||||
* return _.every(arguments, _.bind(RegExp.prototype.test, /^h(?:i|ello)$/)) || undefined;
|
||||
* });
|
||||
* // => true
|
||||
*/
|
||||
function isEqual(a, b) {
|
||||
return baseIsEqual(a, b);
|
||||
function isEqual(value, other) {
|
||||
return baseIsEqual(value, other);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user