From ef238de7a7e428c303a851527e8c8dad0c1e62eb Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 10 Mar 2014 23:58:42 -0700 Subject: [PATCH] Rebuild dist. --- dist/lodash.compat.js | 80 +++++++++++++----------- dist/lodash.compat.min.js | 88 +++++++++++++------------- dist/lodash.js | 112 ++++++++++++++++++---------------- dist/lodash.min.js | 74 +++++++++++----------- dist/lodash.underscore.js | 100 +++++++++++++++--------------- dist/lodash.underscore.min.js | 56 ++++++++--------- 6 files changed, 263 insertions(+), 247 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 4594c6090..7474e70f2 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -78,7 +78,7 @@ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; /** Used to match words to create compound words */ - var reWords = /[a-zA-Z0-9][a-z0-9]*/g; + var reWords = /[A-Z]{2,}|[a-zA-Z0-9][a-z0-9]*/g; /** Used to detect and test whitespace */ var whitespace = ( @@ -262,7 +262,7 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = (fromIndex | 0) - 1, length = array ? array.length : 0; while (++index < length) { @@ -1012,8 +1012,8 @@ // avoid `arguments` object use disqualifying optimizations by // converting it to an array before passing it to `composeArgs` var index = -1, - length = arguments.length, - args = Array(length); + length = arguments.length, + args = Array(length); while (++index < length) { args[index] = arguments[index]; @@ -1329,6 +1329,7 @@ length = collection ? collection.length : 0; if (typeof length == 'number') { + length |= 0; if (support.unindexedChars && isString(iterable)) { iterable = iterable.split(''); } @@ -1357,6 +1358,7 @@ length = collection ? collection.length : 0; if (typeof length == 'number') { + length = (length |= 0) < 0 ? 0 : length; if (support.unindexedChars && isString(iterable)) { iterable = iterable.split(''); } @@ -1383,7 +1385,7 @@ * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isShallow, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = (fromIndex | 0) - 1, length = array ? array.length : 0, result = []; @@ -1953,7 +1955,7 @@ */ function createPad(string, length, chars) { var strLength = string.length; - length = +length || 0; + length |= 0; if (strLength >= length) { return ''; @@ -2499,7 +2501,7 @@ return array ? array[0] : undefined; } } - return slice(array, 0, n > 0 ? n : 0); + return slice(array, 0, n < 0 ? 0 : n); } /** @@ -2596,7 +2598,7 @@ function indexOf(array, value, fromIndex) { var length = array ? array.length : 0; if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(0, length + fromIndex) : (fromIndex || 0); + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) | 0; } else if (fromIndex) { var index = sortedIndex(array, value); return (length && array[index] === value) ? index : -1; @@ -2632,7 +2634,7 @@ n = (predicate == null || thisArg) ? 1 : predicate; } n = length - n; - return slice(array, 0, n > 0 ? n : 0); + return slice(array, 0, n < 0 ? 0 : n); } /** @@ -2726,7 +2728,7 @@ } } n = length - n; - return slice(array, n > 0 ? n : 0); + return slice(array, n < 0 ? 0 : n); } /** @@ -2753,6 +2755,7 @@ function lastIndexOf(array, value, fromIndex) { var index = array ? array.length : 0; if (typeof fromIndex == 'number') { + fromIndex |= 0; index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1; } while (index--) { @@ -2928,7 +2931,7 @@ } else if (predicate == null || thisArg) { n = 1; } else { - n = predicate > 0 ? predicate : 0; + n = predicate < 0 ? 0 : predicate; } return slice(array, n); } @@ -2965,7 +2968,7 @@ } else if (end > length) { end = length; } - length = end - start || 0; + length = (length = (end - start) | 0) < 0 ? 0 : length; var result = Array(length); while (++index < length) { @@ -3580,9 +3583,10 @@ */ function contains(collection, target, fromIndex) { var length = collection ? collection.length : 0; - fromIndex = typeof fromIndex == 'number' ? fromIndex : 0; + fromIndex = typeof fromIndex == 'number' ? fromIndex | 0 : 0; if (typeof length == 'number') { + length = (length |= 0) < 0 ? 0 : length; if (fromIndex >= length) { return false; } @@ -3592,7 +3596,7 @@ : collection.indexOf(target, fromIndex) > -1; } var indexOf = getIndexOf(); - fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; + fromIndex = fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex; return indexOf(collection, target, fromIndex) > -1; } var index = -1, @@ -4056,8 +4060,8 @@ var args = slice(arguments, 2), index = -1, isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); baseEach(collection, function(value) { result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); @@ -4106,8 +4110,8 @@ */ function map(collection, callback, thisArg) { var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); callback = lodash.createCallback(callback, thisArg, 3); if (isArray(collection)) { @@ -4495,7 +4499,8 @@ collection = collection.split(''); } if (n == null || guard) { - return collection ? collection[baseRandom(0, collection.length - 1)] : undefined; + var length = collection ? collection.length | 0 : 0; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; } var result = shuffle(collection); result.length = nativeMin(nativeMax(0, n), result.length); @@ -4519,8 +4524,8 @@ */ function shuffle(collection) { var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); baseEach(collection, function(value) { var rand = baseRandom(0, ++index); @@ -4553,7 +4558,7 @@ */ function size(collection) { var length = collection ? collection.length : 0; - return typeof length == 'number' ? length : keys(collection).length; + return typeof length == 'number' && length > -1 ? length : keys(collection).length; } /** @@ -4671,8 +4676,8 @@ function sortBy(collection, callback, thisArg) { var index = -1, multi = callback && isArray(callback), - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); if (!multi) { callback = lodash.createCallback(callback, thisArg, 3); @@ -4713,7 +4718,8 @@ * // => [2, 3, 4] */ function toArray(collection) { - if (collection && typeof collection.length == 'number') { + var length = collection && collection.length; + if (typeof length == 'number' && length > -1) { return (support.unindexedChars && isString(collection)) ? collection.split('') : slice(collection); @@ -5044,7 +5050,7 @@ if (!isFunction(func)) { throw new TypeError; } - wait = wait > 0 ? wait : 0; + wait = wait < 0 ? 0 : wait; if (options === true) { var leading = true; trailing = false; @@ -6977,7 +6983,7 @@ target = String(target); var length = string.length; - position = (typeof position == 'number' ? nativeMin(nativeMax(position, 0), length) : length) - target.length; + position = (typeof position == 'number' ? nativeMin(nativeMax(position | 0, 0), length) : length) - target.length; return position >= 0 && string.indexOf(target, position) == position; } @@ -7074,7 +7080,7 @@ */ function pad(string, length, chars) { string = string == null ? '' : String(string); - length = +length || 0; + length |= 0; var strLength = string.length; if (strLength >= length) { @@ -7166,7 +7172,7 @@ */ function repeat(string, n) { var result = ''; - n = +n || 0; + n |= 0; if (n < 1 || string == null) { return result; @@ -7178,7 +7184,7 @@ } n = floor(n / 2); string += string; - } while (n > 0); + } while (n); return result; } @@ -7230,7 +7236,7 @@ */ function startsWith(string, target, position) { string = string == null ? '' : String(string); - position = typeof position == 'number' ? nativeMin(nativeMax(position, 0), string.length) : 0; + position = typeof position == 'number' ? nativeMin(nativeMax(position | 0, 0), string.length) : 0; return string.lastIndexOf(target, position) == position; } @@ -7536,11 +7542,11 @@ if (options && isObject(options)) { var separator = 'separator' in options ? options.separator : separator; - length = 'length' in options ? +options.length || 0 : length; + length = 'length' in options ? options.length | 0 : length; omission = 'omission' in options ? String(options.omission) : omission; } else if (options != null) { - length = +options || 0; + length = options | 0; } string = string == null ? '' : String(string); if (length >= string.length) { @@ -7714,14 +7720,14 @@ */ function matches(source) { source || (source = {}); - var props = keys(source), + propsLength = props.length, key = props[0], a = source[key]; // fast path the common case of providing an object with a single // property containing a primitive value - if (props.length == 1 && a === a && !isObject(a)) { + if (propsLength == 1 && a === a && !isObject(a)) { return function(object) { if (!hasOwnProperty.call(object, key)) { return false; @@ -7732,13 +7738,13 @@ }; } return function(object) { - var length = props.length, + var length = propsLength, result = false; while (length--) { var key = props[length]; if (!(result = hasOwnProperty.call(object, key) && - baseIsEqual(object[key], source[key], null, true))) { + baseIsEqual(object[key], source[key], null, true))) { break; } } diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index a8c579ded..961dd5c52 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -3,67 +3,67 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(nt||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202a(e,l)&&f.push(l);return f}function st(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number")for(be.unindexedChars&&hr(e)&&(e=e.split(""));++ra(e,l)&&f.push(l);return f}function st(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number")for(u|=0,be.unindexedChars&&hr(e)&&(e=e.split(""));++r(e|=0)?0:e,be.unindexedChars&&hr(r)&&(r=r.split(""));e--&&false!==t(r[e],e,n););else yt(n,t,Se);return n}function ht(n,t,r,e){e=(0|e)-1;for(var u=n?n.length:0,o=[];++ei(s,h)&&((u||f)&&s.push(h),c.push(p))}return c}function Ct(n,t){for(var r=-1,e=t(n),u=e.length,o=kr(u);++rr&&(r=0),s&&(a=[]),p&&(i=[]),h=[n,t,r,e,u,o,a,i],t==w||t==(w|k)?f(h):X(h)) -}function At(){var n=(n=u.indexOf)===Tt?t:n;return n}function St(n){return typeof n=="function"&&Ur.test(Xr.call(n))}function It(n){var t,r;return!n||qr.call(n)!=ut||!Zr.call(n,"constructor")&&(t=n.constructor,fr(t)&&!(t instanceof t))||!be.argsClass&&ir(n)||!be.nodeClass&&p(n)?false:be.ownLast?(gt(n,function(n,t,e){return r=Zr.call(e,t),false},gr),false!==r):(gt(n,function(n,t){r=t},gr),typeof r=="undefined"||Zr.call(n,r))}function Rt(n){for(var t=-1,r=gr(n),e=r.length,u=[];++te?fe(0,u+e):e||0;else if(e)return e=$t(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Lt(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,a=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)a++}else a=null==t||r?1:t; -return a=e-a,Pt(n,0,0t?t=fe(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=fe(u+r,0):r>u&&(r=u),u=r-t||0,r=kr(u);++er&&(r=0),s&&(a=[]),p&&(i=[]),h=[n,t,r,e,u,o,a,i],t==w||t==(w|k)?f(h):Z(h)) +}function At(){var n=(n=u.indexOf)===Tt?t:n;return n}function St(n){return typeof n=="function"&&Ur.test(Zr.call(n))}function It(n){var t,r;return!n||qr.call(n)!=ut||!Yr.call(n,"constructor")&&(t=n.constructor,fr(t)&&!(t instanceof t))||!be.argsClass&&ir(n)||!be.nodeClass&&p(n)?false:be.ownLast?(gt(n,function(n,t,e){return r=Yr.call(e,t),false},gr),false!==r):(gt(n,function(n,t){r=t},gr),typeof r=="undefined"||Yr.call(n,r))}function Rt(n){for(var t=-1,r=gr(n),e=r.length,u=[];++ta?0:a)}function Tt(n,r,e){var u=n?n.length:0;if(typeof e=="number")e=0|(0>e?fe(0,u+e):e);else if(e)return e=$t(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Lt(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,a=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)a++}else a=null==t||r?1:t; +return a=e-a,Pt(n,0,0>a?0:a)}function Wt(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,a=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)a++}else if(a=t,null==a||r)return n?n[e-1]:_;return a=e-a,Pt(n,0>a?0:a)}function Ft(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,o=n?n.length:0,a=0;for(t=u.createCallback(t,r,3);++et?0:t;return Pt(n,a)}function Pt(n,t,r){var e=-1,u=n?n.length:0;for(typeof t=="undefined"?t=0:0>t?t=fe(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=fe(u+r,0):r>u&&(r=u),u=0>(u=r-t|0)?0:u,r=kr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!Ee(n)&&hr(n))return ee?ee.call(n,t,r):-1r?fe(0,e+r):r)||0,-1a&&(a=l)}else t=null==t&&hr(n)?e:u.createCallback(t,r,3),st(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,a=n)});return a}function Ht(n,t,r,e){var o=3>arguments.length;if(t=u.createCallback(t,e,4),Ee(n)){var a=-1,i=n.length;for(o&&i&&(r=n[++a]);++aarguments.length;return t=u.createCallback(t,e,4),pt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Qt(n){var t=-1,r=n?n.length:0,e=kr(typeof r=="number"?r:0); -return st(n,function(n){var r=wt(0,++t);e[t]=e[r],e[r]=n}),e}function nr(n,t,r){var e;if(t=u.createCallback(t,r,3),Ee(n)){r=-1;for(var o=n.length;++rarguments.length)return Et(n,w,null,t);if(n)var r=n[A]?n[A][2]:n.length,e=Pt(arguments,2),r=r-e.length;return Et(n,w|k,r,t,e)}function rr(n,t,r){var e,u,o,a,i,l,f,c=0,s=false,p=true;if(!fr(n))throw new Wr;if(t=0(e|=0)?0:e,r>=e)return false;if(typeof n=="string"||!Ee(n)&&hr(n))return ee?ee.call(n,t,r):-1r?fe(0,e+r):r,-1o?0:o);if(t=u.createCallback(t,r,3),Ee(n))for(;++ea&&(a=l)}else t=null==t&&hr(n)?e:u.createCallback(t,r,3),st(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,a=n)});return a}function Ht(n,t,r,e){var o=3>arguments.length;if(t=u.createCallback(t,e,4),Ee(n)){var a=-1,i=n.length;for(o&&i&&(r=n[++a]);++aarguments.length;return t=u.createCallback(t,e,4),pt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Qt(n){var t=-1,r=n?0|n.length:0,e=kr(0>r?0:r); +return st(n,function(n){var r=wt(0,++t);e[t]=e[r],e[r]=n}),e}function nr(n,t,r){var e;if(t=u.createCallback(t,r,3),Ee(n)){r=-1;for(var o=n.length;++rarguments.length)return Et(n,w,null,t);if(n)var r=n[A]?n[A][2]:n.length,e=Pt(arguments,2),r=r-e.length;return Et(n,w|k,r,t,e)}function rr(n,t,r){var e,u,o,a,i,l,f,c=0,s=false,p=true;if(!fr(n))throw new Wr;if(t=0>t?0:t,true===r)var h=true,p=false;else cr(r)&&(h=r.leading,s="maxWait"in r&&(fe(t,r.maxWait)||0),p="trailing"in r?r.trailing:p); var g=function(){var r=t-(Fe()-a);0>=r||r>t?(u&&Mr(u),r=f,u=l=f=_,r&&(c=Fe(),o=n.apply(i,e),l||u||(e=i=null))):l=Qr(g,r)},v=function(){l&&Mr(l),u=l=f=_,(p||s!==t)&&(c=Fe(),o=n.apply(i,e),l||u||(e=i=null))};return function(){if(e=arguments,a=Fe(),i=this,f=p&&(l||!h),false===s)var r=h&&!l;else{u||h||(c=a);var y=s-(a-c),m=0>=y||y>s;m?(u&&(u=Mr(u)),c=a,o=n.apply(i,e)):u||(u=Qr(v,y))}return m&&l?l=Mr(l):l||t===s||(l=Qr(g,t)),r&&(m=true,o=n.apply(i,e)),!m||l||u||(e=i=null),o}}function er(n){if(!fr(n))throw new Wr; return function(){return!n.apply(this,arguments)}}function ur(n,t,r){if(!n)return n;var e=arguments,u=0,o=e.length,a=typeof r;if("number"!=a&&"string"!=a||!e[3]||e[3][r]!==t||(o=2),3t||null==n)return r;n=Lr(n);do t%2&&(r+=n),t=Vr(t/2),n+=n;while(0--n?t.apply(this,arguments):void 0}},u.assign=ur,u.at=function(n,t){var r=arguments,e=-1,u=ht(r,true,false,1),o=u.length,a=typeof t;for("number"!=a&&"string"!=a||!r[2]||r[2][t]!==n||(o=1),be.unindexedChars&&hr(n)&&(n=n.split("")),r=kr(o);++et||null==n)return r;n=Lr(n);do t%2&&(r+=n),t=Vr(t/2),n+=n;while(t);return r}function br(n,t,r){var e=typeof n;return"function"==e||null==n?(typeof t=="undefined"||!("prototype"in n))&&n||q(n,t,r):"object"!=e?jr(n):wr(n)}function _r(n){return n}function wr(n){n||(n={});var t=Se(n),r=t.length,e=t[0],u=n[e];return 1!=r||u!==u||cr(u)?function(e){for(var u=r,o=false;u--&&(o=t[u],o=Yr.call(e,o)&&bt(e[o],n[o],null,true)););return o}:function(n){return Yr.call(n,e)?(n=n[e],u===n&&(0!==u||1/u==1/n)):false +}}function xr(n,t,r){var e=true,o=t&&ar(t);t&&(r||o.length)||(null==r&&(r=t),t=n,n=u,o=ar(t)),false===r?e=false:cr(r)&&"chain"in r&&(e=r.chain),r=-1;for(var a=fr(n),i=o?o.length:0;++r--n?t.apply(this,arguments):void 0}},u.assign=ur,u.at=function(n,t){var r=arguments,e=-1,u=ht(r,true,false,1),o=u.length,a=typeof t;for("number"!=a&&"string"!=a||!r[2]||r[2][t]!==n||(o=1),be.unindexedChars&&hr(n)&&(n=n.split("")),r=kr(o);++earguments.length?Et(t,w|x,null,n):Et(t,w|x|k,null,n,Pt(arguments,2))},u.chain=function(n){return n=new o(n),n.__chain__=true,n},u.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(h?r(h,c):i(f,c))){for(u=o,(h||f).push(c);--u;)if(h=a[u],0>(h?r(h,c):i(e[u],c)))continue n; -p.push(c)}}return p},u.invert=function(n,t){for(var r=-1,e=Se(n),u=e.length,o={};++ro?0:o);return st(n,function(n){a[++e]=(u?t:n[t]).apply(n,r)}),a},u.keys=Se,u.keysIn=gr,u.map=Yt,u.mapValues=function(n,t,r){var e={};return t=u.createCallback(t,r,3),mt(n,function(n,r,u){e[r]=t(n,r,u)}),e},u.matches=wr,u.max=Gt,u.memoize=function(n,t){if(!fr(n))throw new Wr; +var r=function(){var e=r.cache,u=t?t.apply(this,arguments):"_"+arguments[0];return Yr.call(e,u)?e[u]:e[u]=n.apply(this,arguments)};return r.cache={},r},u.merge=function(n,t,r){if(!n)return n;var e=arguments,u=e.length,o=typeof r;if("number"!=o&&"string"!=o||!e[3]||e[3][r]!==t||(u=2),3l?0:l); for(o||(t=u.createCallback(t,r,3)),st(n,function(n,r,u){if(o)for(r=t.length,u=kr(r);r--;)u[r]=n[t[r]];else u=t(n,r,u);f[++e]={a:u,b:e,c:n}}),l=f.length,f.sort(o?i:a);l--;)f[l]=f[l].c;return f},u.tap=function(n,t,r){return t.call(r,n),n},u.throttle=function(n,t,r){var e=true,u=true;if(!fr(n))throw new Wr;return false===r?e=false:cr(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),lt.leading=e,lt.maxWait=+t,lt.trailing=u,rr(n,t,lt)},u.times=function(n,t,r){n=-1<(n=+n)?n:0;var e=-1,u=kr(n);for(t=q(t,r,1);++er?fe(0,e+r):ce(r,e-1))+1);e--;)if(n[e]===t)return e; -return-1},u.mixin=xr,u.noConflict=function(){return n._=Br,this},u.noop=Cr,u.now=Fe,u.pad=function(n,t,r){n=null==n?"":Lr(n),t=+t||0;var e=n.length;return er?fe(0,e+r):ce(r,e-1))+1);e--;)if(n[e]===t)return e; +return-1},u.mixin=xr,u.noConflict=function(){return n._=Br,this},u.noop=Cr,u.now=Fe,u.pad=function(n,t,r){n=null==n?"":Lr(n),t|=0;var e=n.length;return e=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(pr(u)){if(n.slice(o).search(u)){var a,i,l=n.slice(0,o);for(u.global||(u=Tr(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;a=u.exec(l);)i=a.index; -r=r.slice(0,null==i?o:i)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(T,d))},u.uniqueId=function(n){var t=++S;return Lr(null==n?"":n)+t},u.all=Kt,u.any=nr,u.detect=Vt,u.findWhere=Vt,u.foldl=Ht,u.foldr=Jt,u.include=Ut,u.inject=Ht,xr(function(){var n={};return mt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Nt,u.last=Wt,u.sample=function(n,t,r){return n&&typeof n.length!="number"?n=yr(n):be.unindexedChars&&hr(n)&&(n=n.split("")),null==t||r?n?n[wt(0,n.length-1)]:_:(n=Qt(n),n.length=ce(fe(0,t),n.length),n) +}catch(h){throw h.source=c,h}return t?p(t):(p.source=c,p)},u.trim=Te,u.trimLeft=Le,u.trimRight=We,u.truncate=function(n,t){var r=30,e="...";if(t&&cr(t))var u="separator"in t?t.separator:u,r="length"in t?0|t.length:r,e="omission"in t?Lr(t.omission):e;else null!=t&&(r=0|t);if(n=null==n?"":Lr(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(pr(u)){if(n.slice(o).search(u)){var a,i,l=n.slice(0,o);for(u.global||(u=Tr(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;a=u.exec(l);)i=a.index; +r=r.slice(0,null==i?o:i)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(T,d))},u.uniqueId=function(n){var t=++S;return Lr(null==n?"":n)+t},u.all=Kt,u.any=nr,u.detect=Vt,u.findWhere=Vt,u.foldl=Ht,u.foldr=Jt,u.include=Ut,u.inject=Ht,xr(function(){var n={};return mt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Nt,u.last=Wt,u.sample=function(n,t,r){return n&&typeof n.length!="number"?n=yr(n):be.unindexedChars&&hr(n)&&(n=n.split("")),null==t||r?(t=n?0|n.length:0,0"']/g,W=/<%-([\s\S]+?)%>/g,F=/<%([\s\S]+?)%>/g,P=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,z=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,q=/[\xC0-\xFF]/g,U=/($^)/,K=/[.*+?^${}()|[\]\\]/g,M=/\bthis\b/,V=/['\n\r\t\u2028\u2029\\]/g,X=/[a-zA-Z0-9][a-z0-9]*/g,Y=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Z="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),G="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),H="[object Arguments]",J="[object Array]",Q="[object Boolean]",nt="[object Date]",tt="[object Error]",rt="[object Function]",et="[object Number]",ut="[object Object]",ot="[object RegExp]",at="[object String]",it={}; +}}),u}var _,w=1,x=2,C=4,j=8,k=16,O=32,E="2.4.1",A="__lodash@"+E+"__",S=0,I=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,N=/(__e\(.*?\)|\b__t\))\+'';/g,T=/&(?:amp|lt|gt|quot|#39);/g,L=/[&<>"']/g,W=/<%-([\s\S]+?)%>/g,F=/<%([\s\S]+?)%>/g,P=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,z=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,q=/[\xC0-\xFF]/g,U=/($^)/,K=/[.*+?^${}()|[\]\\]/g,M=/\bthis\b/,V=/['\n\r\t\u2028\u2029\\]/g,Z=/[A-Z]{2,}|[a-zA-Z0-9][a-z0-9]*/g,X=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Y="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),G="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),H="[object Arguments]",J="[object Array]",Q="[object Boolean]",nt="[object Date]",tt="[object Error]",rt="[object Function]",et="[object Number]",ut="[object Object]",ot="[object RegExp]",at="[object String]",it={}; it[rt]=false,it[H]=it[J]=it[Q]=it[nt]=it[et]=it[ut]=it[ot]=it[at]=true;var lt={leading:false,maxWait:0,trailing:false},ft={configurable:false,enumerable:false,value:null,writable:false},ct={"&":"&","<":"<",">":">",'"':""","'":"'"},st={"&":"&","<":"<",">":">",""":'"',"'":"'"},pt={\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"AE",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"ss","\xd7":" ","\xf7":" "},ht={"function":true,object:true},gt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},vt=ht[typeof window]&&window||this,yt=ht[typeof exports]&&exports&&!exports.nodeType&&exports,ht=ht[typeof module]&&module&&!module.nodeType&&module,mt=yt&&ht&&typeof global=="object"&&global; !mt||mt.global!==mt&&mt.window!==mt&&mt.self!==mt||(vt=mt);var mt=ht&&ht.exports===yt&&yt,dt=b();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(vt._=dt, define(function(){return dt})):yt&&ht?mt?(ht.exports=dt)._=dt:yt._=dt:vt._=dt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index a727a6e70..34ccba2e1 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -78,7 +78,7 @@ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; /** Used to match words to create compound words */ - var reWords = /[a-zA-Z0-9][a-z0-9]*/g; + var reWords = /[A-Z]{2,}|[a-zA-Z0-9][a-z0-9]*/g; /** Used to detect and test whitespace */ var whitespace = ( @@ -255,7 +255,7 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = (fromIndex | 0) - 1, length = array ? array.length : 0; while (++index < length) { @@ -855,8 +855,8 @@ // avoid `arguments` object use disqualifying optimizations by // converting it to an array before passing it to `composeArgs` var index = -1, - length = arguments.length, - args = Array(length); + length = arguments.length, + args = Array(length); while (++index < length) { args[index] = arguments[index]; @@ -1172,6 +1172,7 @@ length = collection ? collection.length : 0; if (typeof length == 'number') { + length |= 0; while (++index < length) { if (callback(iterable[index], index, collection) === false) { break; @@ -1197,6 +1198,7 @@ length = collection ? collection.length : 0; if (typeof length == 'number') { + length = (length |= 0) < 0 ? 0 : length; while (length--) { if (callback(iterable[length], length, collection) === false) { break; @@ -1220,7 +1222,7 @@ * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isShallow, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = (fromIndex | 0) - 1, length = array ? array.length : 0, result = []; @@ -1743,9 +1745,9 @@ callback = lodash.createCallback(callback, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { var value = collection[index]; setter(result, value, callback(value, index, collection), collection); @@ -1790,7 +1792,7 @@ */ function createPad(string, length, chars) { var strLength = string.length; - length = +length || 0; + length |= 0; if (strLength >= length) { return ''; @@ -2324,7 +2326,7 @@ return array ? array[0] : undefined; } } - return slice(array, 0, n > 0 ? n : 0); + return slice(array, 0, n < 0 ? 0 : n); } /** @@ -2421,7 +2423,7 @@ function indexOf(array, value, fromIndex) { var length = array ? array.length : 0; if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(0, length + fromIndex) : (fromIndex || 0); + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) | 0; } else if (fromIndex) { var index = sortedIndex(array, value); return (length && array[index] === value) ? index : -1; @@ -2457,7 +2459,7 @@ n = (predicate == null || thisArg) ? 1 : predicate; } n = length - n; - return slice(array, 0, n > 0 ? n : 0); + return slice(array, 0, n < 0 ? 0 : n); } /** @@ -2551,7 +2553,7 @@ } } n = length - n; - return slice(array, n > 0 ? n : 0); + return slice(array, n < 0 ? 0 : n); } /** @@ -2578,6 +2580,7 @@ function lastIndexOf(array, value, fromIndex) { var index = array ? array.length : 0; if (typeof fromIndex == 'number') { + fromIndex |= 0; index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1; } while (index--) { @@ -2753,7 +2756,7 @@ } else if (predicate == null || thisArg) { n = 1; } else { - n = predicate > 0 ? predicate : 0; + n = predicate < 0 ? 0 : predicate; } return slice(array, n); } @@ -2790,7 +2793,7 @@ } else if (end > length) { end = length; } - length = end - start || 0; + length = (length = (end - start) | 0) < 0 ? 0 : length; var result = Array(length); while (++index < length) { @@ -3402,9 +3405,10 @@ */ function contains(collection, target, fromIndex) { var length = collection ? collection.length : 0; - fromIndex = typeof fromIndex == 'number' ? fromIndex : 0; + fromIndex = typeof fromIndex == 'number' ? fromIndex | 0 : 0; if (typeof length == 'number') { + length = (length |= 0) < 0 ? 0 : length; if (fromIndex >= length) { return false; } @@ -3414,7 +3418,7 @@ : collection.indexOf(target, fromIndex) > -1; } var indexOf = getIndexOf(); - fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; + fromIndex = fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex; return indexOf(collection, target, fromIndex) > -1; } var index = -1, @@ -3513,9 +3517,9 @@ predicate = lodash.createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { if (!predicate(collection[index], index, collection)) { return false; @@ -3574,9 +3578,9 @@ predicate = lodash.createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { var value = collection[index]; if (predicate(value, index, collection)) { @@ -3639,9 +3643,9 @@ function find(collection, predicate, thisArg) { predicate = lodash.createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { var value = collection[index]; if (predicate(value, index, collection)) { @@ -3721,10 +3725,10 @@ */ function forEach(collection, callback, thisArg) { var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { if (callback(collection[index], index, collection) === false) { break; @@ -3754,10 +3758,10 @@ * // => logs each number from right to left and returns '3,2,1' */ function forEachRight(collection, callback, thisArg) { - var length = collection ? collection.length : 0; + var length = collection ? collection.length | 0 : 0; callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { + if (length > 0) { while (length--) { if (callback(collection[length], length, collection) === false) { break; @@ -3881,8 +3885,8 @@ var args = slice(arguments, 2), index = -1, isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); baseEach(collection, function(value) { result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); @@ -3931,10 +3935,10 @@ */ function map(collection, callback, thisArg) { var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; callback = lodash.createCallback(callback, thisArg, 3); - if (typeof length == 'number') { + if (length > 0) { var result = Array(length); while (++index < length) { result[index] = callback(collection[index], index, collection); @@ -4203,9 +4207,9 @@ callback = lodash.createCallback(callback, thisArg, 4); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { if (noaccum && length) { accumulator = collection[++index]; } @@ -4319,7 +4323,8 @@ collection = values(collection); } if (n == null || guard) { - return collection ? collection[baseRandom(0, collection.length - 1)] : undefined; + var length = collection ? collection.length | 0 : 0; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; } var result = shuffle(collection); result.length = nativeMin(nativeMax(0, n), result.length); @@ -4343,8 +4348,8 @@ */ function shuffle(collection) { var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); baseEach(collection, function(value) { var rand = baseRandom(0, ++index); @@ -4377,7 +4382,7 @@ */ function size(collection) { var length = collection ? collection.length : 0; - return typeof length == 'number' ? length : keys(collection).length; + return typeof length == 'number' && length > -1 ? length : keys(collection).length; } /** @@ -4427,9 +4432,9 @@ predicate = lodash.createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { if (predicate(collection[index], index, collection)) { return true; @@ -4495,8 +4500,8 @@ function sortBy(collection, callback, thisArg) { var index = -1, multi = callback && isArray(callback), - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); if (!multi) { callback = lodash.createCallback(callback, thisArg, 3); @@ -4537,7 +4542,8 @@ * // => [2, 3, 4] */ function toArray(collection) { - if (collection && typeof collection.length == 'number') { + var length = collection && collection.length; + if (typeof length == 'number' && length > -1) { return slice(collection); } return values(collection); @@ -4866,7 +4872,7 @@ if (!isFunction(func)) { throw new TypeError; } - wait = wait > 0 ? wait : 0; + wait = wait < 0 ? 0 : wait; if (options === true) { var leading = true; trailing = false; @@ -6750,7 +6756,7 @@ target = String(target); var length = string.length; - position = (typeof position == 'number' ? nativeMin(nativeMax(position, 0), length) : length) - target.length; + position = (typeof position == 'number' ? nativeMin(nativeMax(position | 0, 0), length) : length) - target.length; return position >= 0 && string.indexOf(target, position) == position; } @@ -6847,7 +6853,7 @@ */ function pad(string, length, chars) { string = string == null ? '' : String(string); - length = +length || 0; + length |= 0; var strLength = string.length; if (strLength >= length) { @@ -6939,7 +6945,7 @@ */ function repeat(string, n) { var result = ''; - n = +n || 0; + n |= 0; if (n < 1 || string == null) { return result; @@ -6951,7 +6957,7 @@ } n = floor(n / 2); string += string; - } while (n > 0); + } while (n); return result; } @@ -7003,7 +7009,7 @@ */ function startsWith(string, target, position) { string = string == null ? '' : String(string); - position = typeof position == 'number' ? nativeMin(nativeMax(position, 0), string.length) : 0; + position = typeof position == 'number' ? nativeMin(nativeMax(position | 0, 0), string.length) : 0; return string.lastIndexOf(target, position) == position; } @@ -7309,11 +7315,11 @@ if (options && isObject(options)) { var separator = 'separator' in options ? options.separator : separator; - length = 'length' in options ? +options.length || 0 : length; + length = 'length' in options ? options.length | 0 : length; omission = 'omission' in options ? String(options.omission) : omission; } else if (options != null) { - length = +options || 0; + length = options | 0; } string = string == null ? '' : String(string); if (length >= string.length) { @@ -7487,14 +7493,14 @@ */ function matches(source) { source || (source = {}); - var props = keys(source), + propsLength = props.length, key = props[0], a = source[key]; // fast path the common case of providing an object with a single // property containing a primitive value - if (props.length == 1 && a === a && !isObject(a)) { + if (propsLength == 1 && a === a && !isObject(a)) { return function(object) { if (!hasOwnProperty.call(object, key)) { return false; @@ -7505,13 +7511,13 @@ }; } return function(object) { - var length = props.length, + var length = propsLength, result = false; while (length--) { var key = props[length]; if (!(result = hasOwnProperty.call(object, key) && - baseIsEqual(object[key], source[key], null, true))) { + baseIsEqual(object[key], source[key], null, true))) { break; } } diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 73d9a124a..6b73200de 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,62 +3,62 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(nt||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202i(e,f)&&l.push(f);return l}function ft(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(;++ri(e,f)&&l.push(f);return l}function ft(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(e|=0;++r(r|=0)?0:r;r--&&false!==t(n[r],r,n););else ht(n,t,ke);return n}function ct(n,t,r,e){e=(0|e)-1;for(var u=n?n.length:0,o=[];++ea(p,h)&&((u||l)&&p.push(h),c.push(s))}return c}function _t(n,t){for(var r=-1,e=t(n),u=e.length,o=xr(u);++rr&&(r=0),p&&(i=[]),s&&(a=[]),h=[n,t,r,e,u,o,i,a],t==_||t==(_|j)?l(h):V(h)) +if(f){for(var g=p.length;g--;)if(p[g]===h)continue n;u&&p.push(h),c.push(s)}else e?i&&p===h||(p=h,c.push(s)):0>a(p,h)&&((u||l)&&p.push(h),c.push(s))}return c}function _t(n,t){for(var r=-1,e=t(n),u=e.length,o=xr(u);++rr&&(r=0),p&&(i=[]),s&&(a=[]),h=[n,t,r,e,u,o,i,a],t==_||t==(_|j)?l(h):V(h)) }function Ct(){var n=(n=u.indexOf)===Rt?t:n;return n}function Ot(n){return typeof n=="function"&&Lr.test(Ur.call(n))}function At(n){var t,r;return n&&Dr.call(n)==tt&&(Kr.call(n,"constructor")||(t=n.constructor,!ir(t)||t instanceof t))?(pt(n,function(n,t){r=t},pr),typeof r=="undefined"||Kr.call(n,r)):false}function It(n){for(var t=-1,r=pr(n),e=r.length,u=[];++te?ee(0,u+e):e||0;else if(e)return e=Ft(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Nt(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,i=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)i++}else i=null==t||r?1:t;return i=e-i,Wt(n,0,0t?t=ee(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=ee(u+r,0):r>u&&(r=u),u=r-t||0,r=xr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!we(n)&&cr(n))return Hr?Hr.call(n,t,r):-1r?ee(0,e+r):r)||0,-1i&&(i=f) -}else t=null==t&&cr(n)?e:u.createCallback(t,r,3),ft(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,i=n)});return i}function Yt(n,t,r,e){var o=3>arguments.length;t=u.createCallback(t,e,4);var i=-1,a=n?n.length:0;if(typeof a=="number")for(o&&a&&(r=n[++i]);++iarguments.length;return t=u.createCallback(t,e,4),lt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Gt(n){var t=-1,r=n?n.length:0,e=xr(typeof r=="number"?r:0); -return ft(n,function(n){var r=dt(0,++t);e[t]=e[r],e[r]=n}),e}function Ht(n,t,r){var e;t=u.createCallback(t,r,3),r=-1;var o=n?n.length:0;if(typeof o=="number"){for(;++rarguments.length)return jt(n,_,null,t);if(n)var r=n[A]?n[A][2]:n.length,e=Wt(arguments,2),r=r-e.length;return jt(n,_|j,r,t,e)}function Qt(n,t,r){var e,u,o,i,a,f,l,c=0,p=false,s=true;if(!ir(n))throw new Nr;if(t=0=r||r>t?(u&&Br(u),r=l,u=f=l=b,r&&(c=Re(),o=n.apply(a,e),f||u||(e=a=null))):f=Xr(g,r)},v=function(){f&&Br(f),u=f=l=b,(s||p!==t)&&(c=Re(),o=n.apply(a,e),f||u||(e=a=null))};return function(){if(e=arguments,i=Re(),a=this,l=s&&(f||!h),false===p)var r=h&&!f;else{u||h||(c=i);var y=p-(i-c),m=0>=y||y>p;m?(u&&(u=Br(u)),c=i,o=n.apply(a,e)):u||(u=Xr(v,y))}return m&&f?f=Br(f):f||t===p||(f=Xr(g,t)),r&&(m=true,o=n.apply(a,e)),!m||f||u||(e=a=null),o -}}function nr(n){if(!ir(n))throw new Nr;return function(){return!n.apply(this,arguments)}}function tr(n,t,r){if(!n)return n;var e=arguments,u=0,o=e.length,i=typeof r;if("number"!=i&&"string"!=i||!e[3]||e[3][r]!==t||(o=2),3t||null==n)return r;n=Rr(n);do t%2&&(r+=n),t=qr(t/2),n+=n;while(0i?0:i)}function Rt(n,r,e){var u=n?n.length:0;if(typeof e=="number")e=0|(0>e?ee(0,u+e):e);else if(e)return e=Ft(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Nt(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,i=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)i++}else i=null==t||r?1:t;return i=e-i,Wt(n,0,0>i?0:i)}function St(n,t,r){var e=n?n.length:0;if(typeof t!="number"&&null!=t){var o=e,i=0;for(t=u.createCallback(t,r,3);o--&&t(n[o],o,n);)i++ +}else if(i=t,null==i||r)return n?n[e-1]:b;return i=e-i,Wt(n,0>i?0:i)}function Tt(n,t,r){if(typeof t!="number"&&null!=t){var e=-1,o=n?n.length:0,i=0;for(t=u.createCallback(t,r,3);++et?0:t;return Wt(n,i)}function Wt(n,t,r){var e=-1,u=n?n.length:0;for(typeof t=="undefined"?t=0:0>t?t=ee(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=ee(u+r,0):r>u&&(r=u),u=0>(u=r-t|0)?0:u,r=xr(u);++e>>1,r(n[e])r?0:r);++t(e|=0)?0:e,r>=e)return false;if(typeof n=="string"||!we(n)&&cr(n))return Hr?Hr.call(n,t,r):-1r?ee(0,e+r):r,-1=e){var o;return ft(n,function(n,r,e){return t(n,r,e)?(o=n,false):void 0}),o}for(;++ri&&(i=f)}else t=null==t&&cr(n)?e:u.createCallback(t,r,3),ft(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,i=n) +});return i}function Xt(n,t,r,e){var o=3>arguments.length;t=u.createCallback(t,e,4);var i=-1,a=n?0|n.length:0;if(0arguments.length;return t=u.createCallback(t,e,4),lt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Gt(n){var t=-1,r=n?0|n.length:0,e=xr(0>r?0:r);return ft(n,function(n){var r=dt(0,++t);e[t]=e[r],e[r]=n}),e}function Ht(n,t,r){var e;t=u.createCallback(t,r,3),r=-1; +var o=n?0|n.length:0;if(0arguments.length)return jt(n,_,null,t);if(n)var r=n[A]?n[A][2]:n.length,e=Wt(arguments,2),r=r-e.length;return jt(n,_|j,r,t,e)}function Qt(n,t,r){var e,u,o,i,a,f,l,c=0,p=false,s=true;if(!ir(n))throw new Nr;if(t=0>t?0:t,true===r)var h=true,s=false;else ar(r)&&(h=r.leading,p="maxWait"in r&&(ee(t,r.maxWait)||0),s="trailing"in r?r.trailing:s);var g=function(){var r=t-(Re()-i); +0>=r||r>t?(u&&Br(u),r=l,u=f=l=b,r&&(c=Re(),o=n.apply(a,e),f||u||(e=a=null))):f=Zr(g,r)},v=function(){f&&Br(f),u=f=l=b,(s||p!==t)&&(c=Re(),o=n.apply(a,e),f||u||(e=a=null))};return function(){if(e=arguments,i=Re(),a=this,l=s&&(f||!h),false===p)var r=h&&!f;else{u||h||(c=i);var y=p-(i-c),m=0>=y||y>p;m?(u&&(u=Br(u)),c=i,o=n.apply(a,e)):u||(u=Zr(v,y))}return m&&f?f=Br(f):f||t===p||(f=Zr(g,t)),r&&(m=true,o=n.apply(a,e)),!m||f||u||(e=a=null),o}}function nr(n){if(!ir(n))throw new Nr;return function(){return!n.apply(this,arguments) +}}function tr(n,t,r){if(!n)return n;var e=arguments,u=0,o=e.length,i=typeof r;if("number"!=i&&"string"!=i||!e[3]||e[3][r]!==t||(o=2),3t||null==n)return r;n=Rr(n);do t%2&&(r+=n),t=qr(t/2),n+=n;while(t);return r}function yr(n,t,r){var e=typeof n;return"function"==e||null==n?(typeof t=="undefined"||!("prototype"in n))&&n||q(n,t,r):"object"!=e?wr(n):dr(n)}function mr(n){return n}function dr(n){n||(n={});var t=ke(n),r=t.length,e=t[0],u=n[e];return 1!=r||u!==u||ar(u)?function(e){for(var u=r,o=false;u--&&(o=t[u],o=Kr.call(e,o)&&yt(e[o],n[o],null,true)););return o}:function(n){return Kr.call(n,e)?(n=n[e],u===n&&(0!==u||1/u==1/n)):false +}}function br(n,t,r){var e=true,o=t&&er(t);t&&(r||o.length)||(null==r&&(r=t),t=n,n=u,o=er(t)),false===r?e=false:ar(r)&&"chain"in r&&(e=r.chain),r=-1;for(var i=ir(n),a=o?o.length:0;++r--n?t.apply(this,arguments):void 0 +}),Ce=f(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Oe=f(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Ae=fe?function(n,t){return null==n?"":null==t?fe.call(n):s(n,t)}:s,Ie=le?function(n,t){return null==n?"":null==t?le.call(n):h(n,t)}:h,Ee=ce?function(n,t){return null==n?"":null==t?ce.call(n):g(n,t)}:g,Re=oe||function(){return(new jr).getTime()},Ne=8==ie(Z+"08")?ie:function(n,t){return n=Ae(n),ie(n,+t||(B.test(n)?16:10))};return u.after=function(n,t){if(!ir(t))throw new Nr;return function(){return 1>--n?t.apply(this,arguments):void 0 }},u.assign=tr,u.at=function(n,t){var r=arguments,e=-1,u=ct(r,true,false,1),o=u.length,i=typeof t;for("number"!=i&&"string"!=i||!r[2]||r[2][t]!==n||(o=1),r=xr(o);++earguments.length?jt(t,_|w,null,n):jt(t,_|w|j,null,n,Wt(arguments,2))},u.chain=function(n){return n=new o(n),n.__chain__=true,n },u.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t(h?r(h,c):a(l,c))){for(u=o,(h||l).push(c);--u;)if(h=i[u],0>(h?r(h,c):a(e[u],c)))continue n;s.push(c)}}return s},u.invert=function(n,t){for(var r=-1,e=ke(n),u=e.length,o={};++r(h?r(h,c):a(l,c))){for(u=o,(h||l).push(c);--u;)if(h=i[u],0>(h?r(h,c):a(e[u],c)))continue n;s.push(c)}}return s},u.invert=function(n,t){for(var r=-1,e=ke(n),u=e.length,o={};++ro?0:o); +return ft(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=ke,u.keysIn=pr,u.map=Vt,u.mapValues=function(n,t,r){var e={};return t=u.createCallback(t,r,3),gt(n,function(n,r,u){e[r]=t(n,r,u)}),e},u.matches=dr,u.max=Zt,u.memoize=function(n,t){if(!ir(n))throw new Nr;var r=function(){var e=r.cache,u=t?t.apply(this,arguments):"_"+arguments[0];return Kr.call(e,u)?e[u]:e[u]=n.apply(this,arguments)};return r.cache={},r},u.merge=function(n,t,r){if(!n)return n;var e=arguments,u=e.length,o=typeof r;if("number"!=o&&"string"!=o||!e[3]||e[3][r]!==t||(u=2),3f?0:f); for(o||(t=u.createCallback(t,r,3)),ft(n,function(n,r,u){if(o)for(r=t.length,u=xr(r);r--;)u[r]=n[t[r]];else u=t(n,r,u);l[++e]={a:u,b:e,c:n}}),f=l.length,l.sort(o?a:i);f--;)l[f]=l[f].c;return l},u.tap=function(n,t,r){return t.call(r,n),n},u.throttle=function(n,t,r){var e=true,u=true;if(!ir(n))throw new Nr;return false===r?e=false:ar(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),ot.leading=e,ot.maxWait=+t,ot.trailing=u,Qt(n,t,ot)},u.times=function(n,t,r){n=-1<(n=+n)?n:0;var e=-1,u=xr(n);for(t=q(t,r,1);++er?ee(0,e+r):ue(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=br,u.noConflict=function(){return n._=$r,this},u.noop=_r,u.now=Re,u.pad=function(n,t,r){n=null==n?"":Rr(n),t=+t||0; -var e=n.length;return er?ee(0,e+r):ue(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=br,u.noConflict=function(){return n._=$r,this},u.noop=_r,u.now=Re,u.pad=function(n,t,r){n=null==n?"":Rr(n),t|=0; +var e=n.length;return e=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(lr(u)){if(n.slice(o).search(u)){var i,a,f=n.slice(0,o);for(u.global||(u=Er(u.source,(L.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(f);)a=i.index; -r=r.slice(0,null==a?o:a)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(S,m))},u.uniqueId=function(n){var t=++I;return Rr(null==n?"":n)+t},u.all=qt,u.any=Ht,u.detect=Pt,u.findWhere=Pt,u.foldl=Yt,u.foldr=Zt,u.include=Bt,u.inject=Yt,br(function(){var n={};return gt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Et,u.last=St,u.sample=function(n,t,r){return n&&typeof n.length!="number"&&(n=hr(n)),null==t||r?n?n[dt(0,n.length-1)]:b:(n=Gt(n),n.length=ue(ee(0,t),n.length),n) +}catch(h){throw h.source=c,h}return t?s(t):(s.source=c,s)},u.trim=Ae,u.trimLeft=Ie,u.trimRight=Ee,u.truncate=function(n,t){var r=30,e="...";if(t&&ar(t))var u="separator"in t?t.separator:u,r="length"in t?0|t.length:r,e="omission"in t?Rr(t.omission):e;else null!=t&&(r=0|t);if(n=null==n?"":Rr(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(lr(u)){if(n.slice(o).search(u)){var i,a,f=n.slice(0,o);for(u.global||(u=Er(u.source,(L.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(f);)a=i.index; +r=r.slice(0,null==a?o:a)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1n.indexOf(";")?n:n.replace(S,m))},u.uniqueId=function(n){var t=++I;return Rr(null==n?"":n)+t},u.all=qt,u.any=Ht,u.detect=Pt,u.findWhere=Pt,u.foldl=Xt,u.foldr=Yt,u.include=Bt,u.inject=Xt,br(function(){var n={};return gt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Et,u.last=St,u.sample=function(n,t,r){return n&&typeof n.length!="number"&&(n=hr(n)),null==t||r?(t=n?0|n.length:0,0"']/g,W=/<%-([\s\S]+?)%>/g,F=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,D=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,L=/\w*$/,z=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,q=/[\xC0-\xFF]/g,U=/($^)/,P=/[.*+?^${}()|[\]\\]/g,K=/\bthis\b/,M=/['\n\r\t\u2028\u2029\\]/g,V=/[a-zA-Z0-9][a-z0-9]*/g,X=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Y="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),Z="[object Arguments]",G="[object Array]",H="[object Boolean]",J="[object Date]",Q="[object Function]",nt="[object Number]",tt="[object Object]",rt="[object RegExp]",et="[object String]",ut={}; -ut[Q]=false,ut[Z]=ut[G]=ut[H]=ut[J]=ut[nt]=ut[tt]=ut[rt]=ut[et]=true;var ot={leading:false,maxWait:0,trailing:false},it={configurable:false,enumerable:false,value:null,writable:false},at={"&":"&","<":"<",">":">",'"':""","'":"'"},ft={"&":"&","<":"<",">":">",""":'"',"'":"'"},lt={\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"AE",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"ss","\xd7":" ","\xf7":" "},ct={"function":true,object:true},pt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},st=ct[typeof window]&&window||this,ht=ct[typeof exports]&&exports&&!exports.nodeType&&exports,ct=ct[typeof module]&&module&&!module.nodeType&&module,gt=ht&&ct&&typeof global=="object"&&global; +return n?new o(r,n):r}}),ft(["push","reverse","sort","unshift"],function(n){var t=Sr[n];u.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ft(["concat","splice"],function(n){var t=Sr[n];u.prototype[n]=function(){return new o(t.apply(this.__wrapped__,arguments),this.__chain__)}}),u}var b,_=1,w=2,x=4,k=8,j=16,C=32,O="2.4.1",A="__lodash@"+O+"__",I=0,E=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,N=/(__e\(.*?\)|\b__t\))\+'';/g,S=/&(?:amp|lt|gt|quot|#39);/g,T=/[&<>"']/g,W=/<%-([\s\S]+?)%>/g,F=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,D=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,L=/\w*$/,z=/^\s*function[ \n\r\t]+\w/,B=/^0[xX]/,q=/[\xC0-\xFF]/g,U=/($^)/,P=/[.*+?^${}()|[\]\\]/g,K=/\bthis\b/,M=/['\n\r\t\u2028\u2029\\]/g,V=/[A-Z]{2,}|[a-zA-Z0-9][a-z0-9]*/g,Z=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",X="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),Y="[object Arguments]",G="[object Array]",H="[object Boolean]",J="[object Date]",Q="[object Function]",nt="[object Number]",tt="[object Object]",rt="[object RegExp]",et="[object String]",ut={}; +ut[Q]=false,ut[Y]=ut[G]=ut[H]=ut[J]=ut[nt]=ut[tt]=ut[rt]=ut[et]=true;var ot={leading:false,maxWait:0,trailing:false},it={configurable:false,enumerable:false,value:null,writable:false},at={"&":"&","<":"<",">":">",'"':""","'":"'"},ft={"&":"&","<":"<",">":">",""":'"',"'":"'"},lt={\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"AE",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"ss","\xd7":" ","\xf7":" "},ct={"function":true,object:true},pt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},st=ct[typeof window]&&window||this,ht=ct[typeof exports]&&exports&&!exports.nodeType&&exports,ct=ct[typeof module]&&module&&!module.nodeType&&module,gt=ht&&ct&&typeof global=="object"&&global; !gt||gt.global!==gt&>.window!==gt&>.self!==gt||(st=gt);var gt=ct&&ct.exports===ht&&ht,vt=d();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(st._=vt, define(function(){return vt})):ht&&ct?gt?(ct.exports=vt)._=vt:ht._=vt:st._=vt}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index d491c1929..edb0830ee 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -159,7 +159,7 @@ * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = (fromIndex | 0) - 1, length = array ? array.length : 0; while (++index < length) { @@ -567,6 +567,7 @@ length = collection ? collection.length : 0; if (typeof length == 'number') { + length |= 0; while (++index < length) { if (callback(iterable[index], index, collection) === breakIndicator) { break; @@ -592,6 +593,7 @@ length = collection ? collection.length : 0; if (typeof length == 'number') { + length = (length |= 0) < 0 ? 0 : length; while (length--) { if (callback(iterable[length], length, collection) === breakIndicator) { break; @@ -615,7 +617,7 @@ * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isShallow, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = (fromIndex | 0) - 1, length = array ? array.length : 0, result = []; @@ -976,9 +978,9 @@ callback = createCallback(callback, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { var value = collection[index]; setter(result, value, callback(value, index, collection), collection); @@ -1204,7 +1206,7 @@ if (n == null || guard) { return array ? array[0] : undefined; } - return slice(array, 0, n > 0 ? n : 0); + return slice(array, 0, n < 0 ? 0 : n); } /** @@ -1290,7 +1292,7 @@ function indexOf(array, value, fromIndex) { var length = array ? array.length : 0; if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(0, length + fromIndex) : (fromIndex || 0); + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) | 0; } else if (fromIndex) { var index = sortedIndex(array, value); return (length && array[index] === value) ? index : -1; @@ -1314,7 +1316,7 @@ function initial(array, n, guard) { var length = array ? array.length : 0; n = length - ((n == null || guard) ? 1 : n); - return slice(array, 0, n > 0 ? n : 0); + return slice(array, 0, n < 0 ? 0 : n); } /** @@ -1384,7 +1386,7 @@ return array ? array[length - 1] : undefined; } n = length - n; - return slice(array, n > 0 ? n : 0); + return slice(array, n < 0 ? 0 : n); } /** @@ -1411,6 +1413,7 @@ function lastIndexOf(array, value, fromIndex) { var index = array ? array.length : 0; if (typeof fromIndex == 'number') { + fromIndex |= 0; index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1; } while (index--) { @@ -1492,7 +1495,7 @@ if (n == null || guard) { n = 1; } else { - n = n > 0 ? n : 0; + n = n < 0 ? 0 : n; } return slice(array, n); } @@ -1529,7 +1532,7 @@ } else if (end > length) { end = length; } - length = end - start || 0; + length = (length = (end - start) | 0) < 0 ? 0 : length; var result = Array(length); while (++index < length) { @@ -1941,10 +1944,10 @@ */ function contains(collection, target) { var indexOf = getIndexOf(), - length = collection ? collection.length : 0, + length = collection ? collection.length | 0 : 0, result = false; - if (length && typeof length == 'number') { + if (length > 0) { return indexOf(collection, target) > -1; } baseEach(collection, function(value) { @@ -2037,9 +2040,9 @@ predicate = createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { if (!predicate(collection[index], index, collection)) { return false; @@ -2098,9 +2101,9 @@ predicate = createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { var value = collection[index]; if (predicate(value, index, collection)) { @@ -2163,9 +2166,9 @@ function find(collection, predicate, thisArg) { predicate = createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { var value = collection[index]; if (predicate(value, index, collection)) { @@ -2212,10 +2215,10 @@ */ function forEach(collection, callback, thisArg) { var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { if (callback(collection[index], index, collection) === breakIndicator) { break; @@ -2339,8 +2342,8 @@ var args = slice(arguments, 2), index = -1, isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); baseEach(collection, function(value) { result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); @@ -2389,10 +2392,10 @@ */ function map(collection, callback, thisArg) { var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; callback = createCallback(callback, thisArg, 3); - if (typeof length == 'number') { + if (length > 0) { var result = Array(length); while (++index < length) { result[index] = callback(collection[index], index, collection); @@ -2456,9 +2459,9 @@ callback = null; } var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (callback == null && typeof length == 'number') { + if (callback == null && length > 0) { while (++index < length) { var value = collection[index]; if (value > result) { @@ -2529,9 +2532,9 @@ callback = null; } var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (callback == null && typeof length == 'number') { + if (callback == null && length > 0) { while (++index < length) { var value = collection[index]; if (value < result) { @@ -2657,9 +2660,9 @@ callback = createCallback(callback, thisArg, 4); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { if (noaccum && length) { accumulator = collection[++index]; } @@ -2773,7 +2776,8 @@ collection = values(collection); } if (n == null || guard) { - return collection ? collection[baseRandom(0, collection.length - 1)] : undefined; + var length = collection ? collection.length | 0 : 0; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; } var result = shuffle(collection); result.length = nativeMin(nativeMax(0, n), result.length); @@ -2797,8 +2801,8 @@ */ function shuffle(collection) { var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); baseEach(collection, function(value) { var rand = baseRandom(0, ++index); @@ -2831,7 +2835,7 @@ */ function size(collection) { var length = collection ? collection.length : 0; - return typeof length == 'number' ? length : keys(collection).length; + return typeof length == 'number' && length > -1 ? length : keys(collection).length; } /** @@ -2881,9 +2885,9 @@ predicate = createCallback(predicate, thisArg, 3); var index = -1, - length = collection ? collection.length : 0; + length = collection ? collection.length | 0 : 0; - if (typeof length == 'number') { + if (length > 0) { while (++index < length) { if (predicate(collection[index], index, collection)) { return true; @@ -2948,8 +2952,8 @@ */ function sortBy(collection, callback, thisArg) { var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); + length = collection ? collection.length | 0 : 0, + result = Array(length < 0 ? 0 : length); callback = createCallback(callback, thisArg, 3); baseEach(collection, function(value, key, collection) { @@ -3229,7 +3233,7 @@ if (!isFunction(func)) { throw new TypeError; } - wait = wait > 0 ? wait : 0; + wait = wait < 0 ? 0 : wait; if (options === true) { var leading = true; trailing = false; @@ -3542,12 +3546,11 @@ leading = 'leading' in options ? options.leading : leading; trailing = 'trailing' in options ? options.trailing : trailing; } - options = {}; - options.leading = leading; - options.maxWait = wait; - options.trailing = trailing; - - return debounce(func, wait, options); + return debounce(func, wait, { + 'leading': leading, + 'maxWait': wait, + 'trailing': trailing + }); } /** @@ -4704,16 +4707,17 @@ */ function matches(source) { source || (source = {}); + var props = keys(source), + propsLength = props.length; - var props = keys(source); return function(object) { - var length = props.length, + var length = propsLength, result = true; while (length--) { var key = props[length]; if (!(result = hasOwnProperty.call(object, key) && - object[key] === source[key])) { + object[key] === source[key])) { break; } } diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 0a6ed2687..01b0a3855 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,37 +3,37 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash underscore -o ./dist/lodash.underscore.js` */ -;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined"){t=1;break n}if(te||typeof t=="undefined"){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function p(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(;++to(f,c)&&(t&&f.push(c),i.push(a))}return i}function b(n,r){return function(t,e,u){var o=r?[[],[]]:{}; -e=nr(e,u,3),u=-1;var i=t?t.length:0;if(typeof i=="number")for(;++ue?Lr(0,u+e):e||0;else if(e)return e=O(r,t),u&&r[e]===t?e:-1;return n(r,t,e)}function T(n,r,t){return E(n,null==r||t?1:0r?r=Lr(u+r,0):r>u&&(r=u),typeof t=="undefined"?t=u:0>t?t=Lr(u+t,0):t>u&&(t=u),u=t-r||0,t=Array(u);++e>>1,t(n[e])u&&(u=t);else r=nr(r,t,3),p(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function I(n,r,t,e){var u=3>arguments.length;r=nr(r,e,4);var o=-1,i=n?n.length:0; -if(typeof i=="number")for(u&&i&&(t=n[++o]);++oarguments.length;return r=nr(r,e,4),s(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function D(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return p(n,function(n){var t;t=++r,t=0+Dr(Yr()*(t-0+1)),e[r]=e[t],e[t]=n}),e}function W(n,r,t){var e;r=nr(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number"){for(;++targuments.length?_(n,ir,r):_(n,ir|fr,r,E(arguments,2))}function C(n,r,t){function e(){l&&clearTimeout(l),i=l=p=or,(h||g!==r)&&(s=ct(),f=n.apply(c,o),l||i||(o=c=null))}function u(){var t=r-(ct()-a);0>=t||t>r?(i&&clearTimeout(i),t=p,i=l=p=or,t&&(s=ct(),f=n.apply(c,o),l||i||(o=c=null))):l=setTimeout(u,t)}var o,i,f,a,c,l,p,s=0,g=false,h=true;if(!J(n))throw new TypeError;if(r=0=y||y>g;m?(i&&(i=clearTimeout(i)),s=a,f=n.apply(c,o)):i||(i=setTimeout(e,y))}return m&&l?l=clearTimeout(l):l||r===g||(l=setTimeout(u,r)),t&&(m=true,f=n.apply(c,o)),!m||l||i||(o=c=null),f}}function P(n){if(!J(n))throw new TypeError;return function(){return!n.apply(this,arguments)}}function U(n,r,t){if(!n)return n;var e=arguments,u=0,o=e.length,i=typeof t;for("number"!=i&&"string"!=i||!e[3]||e[3][t]!==r||(o=2);++u"']/g,sr=/($^)/,gr=/[.*+?^${}()|[\]\\]/g,hr=/['\n\r\t\u2028\u2029\\]/g,vr="[object Arguments]",yr="[object Array]",mr="[object Boolean]",br="[object Date]",_r="[object Number]",dr="[object Object]",wr="[object RegExp]",jr="[object String]",xr={"&":"&","<":"<",">":">",'"':""","'":"'"},Ar={"&":"&","<":"<",">":">",""":'"',"'":"'"},Tr={"function":true,object:true},Er={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Or=Tr[typeof window]&&window||this,Sr=Tr[typeof exports]&&exports&&!exports.nodeType&&exports,kr=Tr[typeof module]&&module&&!module.nodeType&&module,Nr=Sr&&kr&&typeof global=="object"&&global; +for(;s--;)v[g++]=c[p++];c=v}return n=i?e:this,this instanceof r?(n=f(t.prototype),a=t.apply(n,c),K(a)?a:n):t.apply(n,c)}var t=n[0],e=n[3],u=n[4],o=n[6],i=n[1]&ir;return r}function l(n,r){var t=n?n.length:0;if(!t)return[];for(var e=-1,u=b(),o=[];++eu(r,i)&&o.push(i)}return o}function p(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(e|=0;++t(t|=0)?0:t;t--&&r(n[t],t,n)!==ar;);else for(var t=at(n),e=t.length;e--;){var u=t[e]; +if(r(n[u],u,n)===ar)break}}function g(n,r,t,e){e=(0|e)-1;for(var u=n?n.length:0,o=[];++eo(f,c)&&(t&&f.push(c),i.push(a))}return i}function _(n,r){return function(t,e,u){var o=r?[[],[]]:{}; +e=nr(e,u,3),u=-1;var i=t?0|t.length:0;if(0r?0:r)}function A(r,t,e){var u=r?r.length:0;if(typeof e=="number")e=0|(0>e?Lr(0,u+e):e);else if(e)return e=O(r,t),u&&r[e]===t?e:-1;return n(r,t,e)}function T(n,r,t){return E(n,null==r||t?1:0>r?0:r)}function E(n,r,t){var e=-1,u=n?n.length:0;for(typeof r=="undefined"?r=0:0>r?r=Lr(u+r,0):r>u&&(r=u),typeof t=="undefined"?t=u:0>t?t=Lr(u+t,0):t>u&&(t=u),u=0>(u=t-r|0)?0:u,t=Array(u);++e>>1,t(n[e])=e){var u;return p(n,function(n,t,e){return r(n,t,e)?(u=n,ar):void 0}),u}for(;++tu&&(u=t);else r=nr(r,t,3),p(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function I(n,r,t,e){var u=3>arguments.length;r=nr(r,e,4);var o=-1,i=n?0|n.length:0;if(0arguments.length;return r=nr(r,e,4),s(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function D(n){var r=-1,t=n?0|n.length:0,e=Array(0>t?0:t);return p(n,function(n){var t;t=++r,t=0+Dr(Yr()*(t-0+1)),e[r]=e[t],e[t]=n}),e}function W(n,r,t){var e;r=nr(r,t,3),t=-1;var u=n?0|n.length:0;if(0arguments.length?d(n,ir,r):d(n,ir|fr,r,E(arguments,2)) +}function C(n,r,t){function e(){l&&clearTimeout(l),i=l=p=or,(h||g!==r)&&(s=ct(),f=n.apply(c,o),l||i||(o=c=null))}function u(){var t=r-(ct()-a);0>=t||t>r?(i&&clearTimeout(i),t=p,i=l=p=or,t&&(s=ct(),f=n.apply(c,o),l||i||(o=c=null))):l=setTimeout(u,t)}var o,i,f,a,c,l,p,s=0,g=false,h=true;if(!J(n))throw new TypeError;if(r=0>r?0:r,true===t)var v=true,h=false;else K(t)&&(v=t.leading,g="maxWait"in t&&(Lr(r,t.maxWait)||0),h="trailing"in t?t.trailing:h);return function(){if(o=arguments,a=ct(),c=this,p=h&&(l||!v),false===g)var t=v&&!l; +else{i||v||(s=a);var y=g-(a-s),m=0>=y||y>g;m?(i&&(i=clearTimeout(i)),s=a,f=n.apply(c,o)):i||(i=setTimeout(e,y))}return m&&l?l=clearTimeout(l):l||r===g||(l=setTimeout(u,r)),t&&(m=true,f=n.apply(c,o)),!m||l||i||(o=c=null),f}}function P(n){if(!J(n))throw new TypeError;return function(){return!n.apply(this,arguments)}}function U(n,r,t){if(!n)return n;var e=arguments,u=0,o=e.length,i=typeof t;for("number"!=i&&"string"!=i||!e[3]||e[3][t]!==r||(o=2);++u"']/g,sr=/($^)/,gr=/[.*+?^${}()|[\]\\]/g,hr=/['\n\r\t\u2028\u2029\\]/g,vr="[object Arguments]",yr="[object Array]",mr="[object Boolean]",_r="[object Date]",dr="[object Number]",br="[object Object]",wr="[object RegExp]",jr="[object String]",xr={"&":"&","<":"<",">":">",'"':""","'":"'"},Ar={"&":"&","<":"<",">":">",""":'"',"'":"'"},Tr={"function":true,object:true},Er={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Or=Tr[typeof window]&&window||this,Sr=Tr[typeof exports]&&exports&&!exports.nodeType&&exports,kr=Tr[typeof module]&&module&&!module.nodeType&&module,Nr=Sr&&kr&&typeof global=="object"&&global; !Nr||Nr.global!==Nr&&Nr.window!==Nr&&Nr.self!==Nr||(Or=Nr);var qr=kr&&kr.exports===Sr&&Sr,Fr=Array.prototype,Br=Object.prototype,Rr=Or._,$r=Br.toString,Ir=RegExp("^"+(null==$r?"":($r+"").replace(gr,"\\$&")).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Mr=Math.ceil,Dr=Math.floor,Wr=Function.prototype.toString,zr=Br.hasOwnProperty,Cr=Fr.push,Pr=Br.propertyIsEnumerable,Ur=Fr.splice,Vr=w(Vr=Object.create)&&Vr,Gr=w(Gr=Array.isArray)&&Gr,Hr=Or.isFinite,Jr=Or.isNaN,Kr=w(Kr=Object.keys)&&Kr,Lr=Math.max,Qr=Math.min,Xr=w(Xr=Date.now)&&Xr,Yr=Math.random; -i.prototype=o.prototype;var Zr={};!function(){var n={0:1,length:1};Zr.spliceObjects=(Ur.call(n,0,1),!n[0])}(1),o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Vr||(f=function(){function n(){}return function(r){if(K(r)){n.prototype=r;var t=new n;n.prototype=null}return t||Or.Object()}}());var nt=T,rt=b(function(n,r,t){zr.call(n,t)?n[t]++:n[t]=1}),tt=b(function(n,r,t){zr.call(n,t)?n[t].push(r):n[t]=[r]}),et=b(function(n,r,t){n[t]=r -}),ut=b(function(n,r,t){n[t?0:1].push(r)},true),ot=R,it=q;H(arguments)||(H=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&zr.call(n,"callee")&&!Pr.call(n,"callee")||false});var ft=Gr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&$r.call(n)==yr||false};J(/x/)&&(J=function(n){return typeof n=="function"&&"[object Function]"==$r.call(n)});var at=Kr?function(n){return K(n)?Kr(n):[]}:j,ct=Xr||function(){return(new Date).getTime()};o.after=function(n,r){if(!J(r))throw new TypeError; -return function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=z,o.bindAll=function(n){for(var r=1/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Vr||(f=function(){function n(){}return function(r){if(K(r)){n.prototype=r;var t=new n;n.prototype=null}return t||Or.Object()}}());var nt=T,rt=_(function(n,r,t){zr.call(n,t)?n[t]++:n[t]=1}),tt=_(function(n,r,t){zr.call(n,t)?n[t].push(r):n[t]=[r]}),et=_(function(n,r,t){n[t]=r +}),ut=_(function(n,r,t){n[t?0:1].push(r)},true),ot=R,it=q;H(arguments)||(H=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&zr.call(n,"callee")&&!Pr.call(n,"callee")||false});var ft=Gr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&$r.call(n)==yr||false};J(/x/)&&(J=function(n){return typeof n=="function"&&"[object Function]"==$r.call(n)});var at=Kr?function(n){return K(n)?Kr(n):[]}:j,ct=Xr||function(){return(new Date).getTime()};o.after=function(n,r){if(!J(r))throw new TypeError; +return function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=z,o.bindAll=function(n){for(var r=1i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},o.invert=function(n){for(var r=-1,t=at(n),e=t.length,u={};++rr?0:r);++nt?Lr(0,e+t):Qr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.mixin=er,o.noConflict=function(){return Or._=Rr,this},o.now=ct,o.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Dr(Yr()*(r-n+1))},o.reduce=I,o.reduceRight=M,o.result=function(n,r){if(null!=n){var t=n[r];return J(t)?n[r]():t}},o.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:at(n).length},o.some=W,o.sortedIndex=O,o.template=function(n,r,t){var u=o,i=u.templateSettings; +},o.forEach=B,o.functions=G,o.groupBy=tt,o.indexBy=et,o.initial=function(n,r,t){return r=(n?n.length:0)-(null==r||t?1:r),E(n,0,0>r?0:r)},o.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},o.invert=function(n){for(var r=-1,t=at(n),e=t.length,u={};++ro?0:o); +return p(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},o.keys=at,o.map=R,o.matches=tr,o.max=$,o.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):"_"+arguments[0];return zr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},o.min=function(n,r,t){var e=1/0,u=e,o=typeof r;"number"!=o&&"string"!=o||!t||t[r]!==n||(r=null);var o=-1,i=n?0|n.length:0;if(null==r&&0o?0:o);for(t=nr(t,e,3),p(n,function(n,r,e){i[++u]={a:t(n,r,e),b:u,c:n}}),o=i.length,i.sort(r);o--;)i[o]=i[o].c;return i},o.tap=function(n,r){return r(n),n},o.throttle=function(n,r,t){var e=true,u=true;if(!J(n))throw new TypeError;return false===t?e=false:K(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),C(n,r,{leading:e,maxWait:r,trailing:u})},o.times=function(n,r,t){n=-1<(n=+n)?n:0;var e=-1,u=Array(n);for(r=a(r,t,1);++er?0:r);++nt?Lr(0,e+t):Qr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.mixin=er,o.noConflict=function(){return Or._=Rr,this},o.now=ct,o.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Dr(Yr()*(r-n+1))},o.reduce=I,o.reduceRight=M,o.result=function(n,r){if(null!=n){var t=n[r];return J(t)?n[r]():t}},o.size=function(n){var r=n?n.length:0;return typeof r=="number"&&-1n.indexOf(";")?n:n.replace(lr,u))},o.uniqueId=function(n){var r=++cr+"";return n?n+r:r},o.all=N,o.any=W,o.detect=F,o.findWhere=F,o.foldl=I,o.foldr=M,o.include=k,o.inject=I,o.first=x,o.last=function(n,r,t){var e=n?n.length:0;return null==r||t?n?n[e-1]:or:(r=e-r,E(n,0n.indexOf(";")?n:n.replace(lr,u))},o.uniqueId=function(n){var r=++cr+"";return n?n+r:r},o.all=N,o.any=W,o.detect=F,o.findWhere=F,o.foldl=I,o.foldr=M,o.include=k,o.inject=I,o.first=x,o.last=function(n,r,t){var e=n?n.length:0;return null==r||t?n?n[e-1]:or:(r=e-r,E(n,0>r?0:r))},o.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=Z(n)),null==r||t?(r=n?0|n.length:0,0