From 1d02c288b3645930ca8cb3519ff155d0a7ec1a64 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Mar 2014 23:18:54 -0700 Subject: [PATCH] Avoid `a`, `b` variable names and cleanup `_.isEqual` docs. --- dist/lodash.compat.js | 116 ++++++++++++++++++-------------------- dist/lodash.compat.min.js | 2 +- dist/lodash.js | 116 ++++++++++++++++++-------------------- dist/lodash.min.js | 2 +- dist/lodash.underscore.js | 72 +++++++++++------------ lodash.js | 114 ++++++++++++++++++------------------- 6 files changed, 203 insertions(+), 219 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index f23fb04d5..306d7fff8 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -249,16 +249,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; } } @@ -352,12 +352,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; } /** @@ -365,29 +365,29 @@ * collection and stable 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 compareMultipleAscending(a, b) { - var ac = a.criteria, - bc = b.criteria, - index = -1, - length = ac.length; + function compareMultipleAscending(object, other) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length; while (++index < length) { - var result = baseCompareAscending(ac[index], bc[index]); + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); if (result) { return result; } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications // that causes it, under certain circumstances, to provided the same value - // for `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247 + // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 // // This also ensures a stable sort in V8 and other engines. // See https://code.google.com/p/v8/issues/detail?id=90 - return a.index - b.index; + return object.index - other.index; } /** @@ -1213,8 +1213,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); @@ -1550,12 +1550,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, callback, isWhere, stackA, stackB) { @@ -2163,7 +2163,7 @@ var ctor, result; - // avoid non Object objects, `arguments` objects, and DOM elements + // avoid non `Object` objects, `arguments` objects, and DOM elements if (!(value && toString.call(value) == objectClass) || (!hasOwnProperty.call(value, 'constructor') && (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor))) || @@ -4389,8 +4389,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) { @@ -5447,8 +5447,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' }); @@ -6124,61 +6124,57 @@ /** * 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, callback, thisArg) { + function isEqual(value, other, callback, thisArg) { callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2); if (!callback) { // exit early for identical values - if (a === b) { + if (value === other) { // treat `-0` vs. `+0` as not equal - return a !== 0 || (1 / a == 1 / b); + return value !== 0 || (1 / value == 1 / other); } - var type = typeof a, - otherType = typeof b; + var vType = typeof value, + oType = typeof other; // exit early for unlike primitive values - if (a === a && (a == null || b == null || - (type != 'function' && type != 'object' && otherType != 'function' && otherType != 'object'))) { + if (value === value && (value == null || other == null || + (vType != 'function' && vType != 'object' && oType != 'function' && oType != 'object'))) { return false; } } - return baseIsEqual(a, b, callback); + return baseIsEqual(value, other, callback); } /** @@ -7697,18 +7693,18 @@ var props = keys(source), propsLength = props.length, key = props[0], - a = source[key]; + value = source[key]; // fast path the common case of providing an object with a single // property containing a primitive value - if (propsLength == 1 && a === a && !isObject(a)) { + if (propsLength == 1 && value === value && !isObject(value)) { return function(object) { if (!hasOwnProperty.call(object, key)) { return false; } // treat `-0` vs. `+0` as not equal - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); + var other = object[key]; + return value === other && (value !== 0 || (1 / value == 1 / other)); }; } return function(object) { diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index b7a479434..5b978becc 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,7 +4,7 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;(function(){function n(n,t){return typeof n=="undefined"?t:n}function t(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202 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; } } @@ -345,12 +345,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; } /** @@ -358,29 +358,29 @@ * collection and stable 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 compareMultipleAscending(a, b) { - var ac = a.criteria, - bc = b.criteria, - index = -1, - length = ac.length; + function compareMultipleAscending(object, other) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length; while (++index < length) { - var result = baseCompareAscending(ac[index], bc[index]); + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); if (result) { return result; } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications // that causes it, under certain circumstances, to provided the same value - // for `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247 + // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 // // This also ensures a stable sort in V8 and other engines. // See https://code.google.com/p/v8/issues/detail?id=90 - return a.index - b.index; + return object.index - other.index; } /** @@ -1056,8 +1056,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); @@ -1387,12 +1387,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, callback, isWhere, stackA, stackB) { @@ -2000,7 +2000,7 @@ var ctor, result; - // avoid non Object objects, `arguments` objects, and DOM elements + // avoid non `Object` objects, `arguments` objects, and DOM elements if (!(value && toString.call(value) == objectClass) || (!hasOwnProperty.call(value, 'constructor') && (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor)))) { @@ -4217,8 +4217,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) { @@ -5271,8 +5271,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' }); @@ -5940,61 +5940,57 @@ /** * 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, callback, thisArg) { + function isEqual(value, other, callback, thisArg) { callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2); if (!callback) { // exit early for identical values - if (a === b) { + if (value === other) { // treat `-0` vs. `+0` as not equal - return a !== 0 || (1 / a == 1 / b); + return value !== 0 || (1 / value == 1 / other); } - var type = typeof a, - otherType = typeof b; + var vType = typeof value, + oType = typeof other; // exit early for unlike primitive values - if (a === a && (a == null || b == null || - (type != 'function' && type != 'object' && otherType != 'function' && otherType != 'object'))) { + if (value === value && (value == null || other == null || + (vType != 'function' && vType != 'object' && oType != 'function' && oType != 'object'))) { return false; } } - return baseIsEqual(a, b, callback); + return baseIsEqual(value, other, callback); } /** @@ -7472,18 +7468,18 @@ var props = keys(source), propsLength = props.length, key = props[0], - a = source[key]; + value = source[key]; // fast path the common case of providing an object with a single // property containing a primitive value - if (propsLength == 1 && a === a && !isObject(a)) { + if (propsLength == 1 && value === value && !isObject(value)) { return function(object) { if (!hasOwnProperty.call(object, key)) { return false; } // treat `-0` vs. `+0` as not equal - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); + var other = object[key]; + return value === other && (value !== 0 || (1 / value == 1 / other)); }; } return function(object) { diff --git a/dist/lodash.min.js b/dist/lodash.min.js index ab6581fe8..4197f5c6c 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,7 +4,7 @@ * Build: `lodash modern -o ./dist/lodash.js` */ ;(function(){function n(n,t){return typeof n=="undefined"?t:n}function t(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202 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); } /** diff --git a/lodash.js b/lodash.js index f46fdda5c..3e174015c 100644 --- a/lodash.js +++ b/lodash.js @@ -248,16 +248,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; } } @@ -351,12 +351,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; } /** @@ -364,29 +364,29 @@ * collection and stable 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 compareMultipleAscending(a, b) { - var ac = a.criteria, - bc = b.criteria, - index = -1, - length = ac.length; + function compareMultipleAscending(object, other) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length; while (++index < length) { - var result = baseCompareAscending(ac[index], bc[index]); + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); if (result) { return result; } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications // that causes it, under certain circumstances, to provided the same value - // for `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247 + // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 // // This also ensures a stable sort in V8 and other engines. // See https://code.google.com/p/v8/issues/detail?id=90 - return a.index - b.index; + return object.index - other.index; } /** @@ -1212,8 +1212,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); @@ -1549,12 +1549,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, callback, isWhere, stackA, stackB) { @@ -4408,8 +4408,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) { @@ -5466,8 +5466,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' }); @@ -6143,61 +6143,57 @@ /** * 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, callback, thisArg) { + function isEqual(value, other, callback, thisArg) { callback = typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2); if (!callback) { // exit early for identical values - if (a === b) { + if (value === other) { // treat `-0` vs. `+0` as not equal - return a !== 0 || (1 / a == 1 / b); + return value !== 0 || (1 / value == 1 / other); } - var type = typeof a, - otherType = typeof b; + var vType = typeof value, + oType = typeof other; // exit early for unlike primitive values - if (a === a && (a == null || b == null || - (type != 'function' && type != 'object' && otherType != 'function' && otherType != 'object'))) { + if (value === value && (value == null || other == null || + (vType != 'function' && vType != 'object' && oType != 'function' && oType != 'object'))) { return false; } } - return baseIsEqual(a, b, callback); + return baseIsEqual(value, other, callback); } /** @@ -7716,18 +7712,18 @@ var props = keys(source), propsLength = props.length, key = props[0], - a = source[key]; + value = source[key]; // fast path the common case of providing an object with a single // property containing a primitive value - if (propsLength == 1 && a === a && !isObject(a)) { + if (propsLength == 1 && value === value && !isObject(value)) { return function(object) { if (!hasOwnProperty.call(object, key)) { return false; } // treat `-0` vs. `+0` as not equal - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); + var other = object[key]; + return value === other && (value !== 0 || (1 / value == 1 / other)); }; } return function(object) {