Avoid a, b variable names and cleanup _.isEqual docs.

This commit is contained in:
John-David Dalton
2014-03-22 23:18:54 -07:00
parent 3776920807
commit 1d02c288b3
6 changed files with 203 additions and 219 deletions

116
dist/lodash.compat.js vendored
View File

@@ -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) {

View File

@@ -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(n<t||typeof t=="undefined")return-1}return 0}function r(n,t,r){r=(+r||0)-1;for(var e=n?n.length:0;++r<e;)if(n[r]===t)return r;return-1}function e(n,t){return n.has(t)?0:-1}function u(n){return n.charCodeAt(0)}function o(n,t){for(var r=-1,e=n.length;++r<e&&0<=t.indexOf(n.charAt(r)););return r}function a(n,t){for(var r=n.length;r--&&0<=t.indexOf(n.charAt(r)););return r}function i(n,r){return t(n.a,r.a)||n.b-r.b
}function l(n,r){for(var e=n.a,u=r.a,o=-1,a=e.length;++o<a;){var i=t(e[o],u[o]);if(i)return i}return n.b-r.b}function f(n){return function(t){for(var r=-1,e=(t=null!=t&&(t+"").replace(U,c).match(X))?t.length:0,u="";++r<e;)u=n(u,t[r],r,t);return u}}function c(n){return ht[n]}function s(n){return st[n]}function p(n){return"\\"+vt[n]}function h(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function g(n,t){return(n=null==n?"":n+"")?null==t?n.slice(m(n),d(n)+1):(t+="",n.slice(o(n,t),a(n,t)+1)):n
}function l(n,r){for(var e=-1,u=n.a,o=r.a,a=u.length;++e<a;){var i=t(u[e],o[e]);if(i)return i}return n.b-r.b}function f(n){return function(t){for(var r=-1,e=(t=null!=t&&(t+"").replace(U,c).match(X))?t.length:0,u="";++r<e;)u=n(u,t[r],r,t);return u}}function c(n){return ht[n]}function s(n){return st[n]}function p(n){return"\\"+vt[n]}function h(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function g(n,t){return(n=null==n?"":n+"")?null==t?n.slice(m(n),d(n)+1):(t+="",n.slice(o(n,t),a(n,t)+1)):n
}function v(n,t){return(n=null==n?"":n+"")?null==t?n.slice(m(n)):(t+="",n.slice(o(n,t))):n}function y(n,t){return(n=null==n?"":n+"")?null==t?n.slice(0,d(n)+1):(t+="",n.slice(0,a(n,t)+1)):n}function m(n){for(var t=-1,r=n.length;++t<r;){var e=n.charCodeAt(t);if((160<e||9>e||13<e)&&32!=e&&160!=e&&5760!=e&&6158!=e&&(8192>e||8202<e&&8232!=e&&8233!=e&&8239!=e&&8287!=e&&12288!=e&&65279!=e))break}return t}function d(n){for(var t=n.length;t--;){var r=n.charCodeAt(t);if((160<r||9>r||13<r)&&32!=r&&160!=r&&5760!=r&&6158!=r&&(8192>r||8202<r&&8232!=r&&8233!=r&&8239!=r&&8287!=r&&12288!=r&&65279!=r))break
}return t}function b(n){return pt[n]}function _(t){function o(n){return n&&typeof n=="object"&&!Te(n)&&te.call(n,"__wrapped__")?n:new a(n)}function a(n,t){this.__chain__=!!t,this.__wrapped__=n}function c(n){function t(){if(u){for(var n=-1,a=arguments.length,i=Ir(a);++n<a;)i[n]=arguments[n];i=At(u,o,i)}return this instanceof t?(n=d(r.prototype),i=r.apply(n,i||arguments),vr(i)?i:n):r.apply(e,i||arguments)}var r=n[0],e=n[3],u=n[4],o=n[6];return Ee(t,n),t}function m(n,t,r,e,u){if(r){var o=r(n);if(typeof o!="undefined")return o
}if(!vr(n))return n;var a=Xr.call(n);if(!lt[a]||!ke.nodeClass&&h(n))return n;var i=Ce[a];switch(a){case nt:case tt:return new i(+n);case ut:case it:return new i(n);case at:return o=i(n.source,z.exec(n)),o.lastIndex=n.lastIndex,o}if(a=Te(n),t){e||(e=[]),u||(u=[]);for(var l=e.length;l--;)if(e[l]==n)return u[l];o=a?i(n.length):{}}else o=a?qt(n):fr({},n);return a&&(te.call(n,"index")&&(o.index=n.index),te.call(n,"input")&&(o.input=n.input)),t?(e.push(n),u.push(o),(a?pt:wt)(n,function(n,a){o[a]=m(n,t,r,e,u)

116
dist/lodash.js vendored
View File

@@ -242,16 +242,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;
}
}
@@ -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) {

2
dist/lodash.min.js vendored
View File

@@ -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(n<t||typeof t=="undefined")return-1}return 0}function r(n,t,r){r=(+r||0)-1;for(var e=n?n.length:0;++r<e;)if(n[r]===t)return r;return-1}function e(n,t){return n.has(t)?0:-1}function u(n){return n.charCodeAt(0)}function o(n,t){for(var r=-1,e=n.length;++r<e&&0<=t.indexOf(n.charAt(r)););return r}function i(n,t){for(var r=n.length;r--&&0<=t.indexOf(n.charAt(r)););return r}function a(n,r){return t(n.a,r.a)||n.b-r.b
}function l(n,r){for(var e=n.a,u=r.a,o=-1,i=e.length;++o<i;){var a=t(e[o],u[o]);if(a)return a}return n.b-r.b}function f(n){return function(t){for(var r=-1,e=(t=null!=t&&(t+"").replace(U,c).match(Z))?t.length:0,u="";++r<e;)u=n(u,t[r],r,t);return u}}function c(n){return ct[n]}function p(n){return lt[n]}function s(n){return"\\"+st[n]}function h(n,t){return(n=null==n?"":n+"")?null==t?n.slice(y(n),m(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function g(n,t){return(n=null==n?"":n+"")?null==t?n.slice(y(n)):(t+="",n.slice(o(n,t))):n
}function l(n,r){for(var e=-1,u=n.a,o=r.a,i=u.length;++e<i;){var a=t(u[e],o[e]);if(a)return a}return n.b-r.b}function f(n){return function(t){for(var r=-1,e=(t=null!=t&&(t+"").replace(U,c).match(Z))?t.length:0,u="";++r<e;)u=n(u,t[r],r,t);return u}}function c(n){return ct[n]}function p(n){return lt[n]}function s(n){return"\\"+st[n]}function h(n,t){return(n=null==n?"":n+"")?null==t?n.slice(y(n),m(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function g(n,t){return(n=null==n?"":n+"")?null==t?n.slice(y(n)):(t+="",n.slice(o(n,t))):n
}function v(n,t){return(n=null==n?"":n+"")?null==t?n.slice(0,m(n)+1):(t+="",n.slice(0,i(n,t)+1)):n}function y(n){for(var t=-1,r=n.length;++t<r;){var e=n.charCodeAt(t);if((160<e||9>e||13<e)&&32!=e&&160!=e&&5760!=e&&6158!=e&&(8192>e||8202<e&&8232!=e&&8233!=e&&8239!=e&&8287!=e&&12288!=e&&65279!=e))break}return t}function m(n){for(var t=n.length;t--;){var r=n.charCodeAt(t);if((160<r||9>r||13<r)&&32!=r&&160!=r&&5760!=r&&6158!=r&&(8192>r||8202<r&&8232!=r&&8233!=r&&8239!=r&&8287!=r&&12288!=r&&65279!=r))break
}return t}function d(n){return ft[n]}function b(t){function o(n){return n&&typeof n=="object"&&!Oe(n)&&Yr.call(n,"__wrapped__")?n:new i(n)}function i(n,t){this.__chain__=!!t,this.__wrapped__=n}function c(n){function t(){if(u){for(var n=-1,i=arguments.length,a=Or(i);++n<i;)a[n]=arguments[n];a=jt(u,o,a)}return this instanceof t?(n=m(r.prototype),a=r.apply(n,a||arguments),pr(a)?a:n):r.apply(e,a||arguments)}var r=n[0],e=n[3],u=n[4],o=n[6];return _e(t,n),t}function y(n,t,r,e,u){if(r){var o=r(n);if(typeof o!="undefined")return o
}if(!pr(n))return n;var i=Ur.call(n);if(!ot[i])return n;var a=ye[i];switch(i){case J:case Q:return new a(+n);case tt:case ut:return new a(n);case et:return o=a(n.source,z.exec(n)),o.lastIndex=n.lastIndex,o}if(i=Oe(n),t){e||(e=[]),u||(u=[]);for(var l=e.length;l--;)if(e[l]==n)return u[l];o=i?a(n.length):{}}else o=i?Lt(n):or({},n);return i&&(Yr.call(n,"index")&&(o.index=n.index),Yr.call(n,"input")&&(o.input=n.input)),t?(e.push(n),u.push(o),(i?ft:mt)(n,function(n,i){o[i]=y(n,t,r,e,u)}),o):o}function m(n){return pr(n)?ee(n):{}

View File

@@ -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);
}
/**

114
lodash.js
View File

@@ -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) {