From e9387d322c3f1c86bf4290798b89cd935e08171f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 26 May 2013 18:57:17 -0700 Subject: [PATCH] Disable use of `basicIndexOf` optimization if `_.indexOf` is customized. Former-commit-id: 5b2273b36934581e34c6f6042de95bf556c61ca2 --- build.js | 34 +++--- dist/lodash.compat.js | 29 ++++- dist/lodash.compat.min.js | 86 +++++++------- dist/lodash.js | 29 ++++- dist/lodash.min.js | 75 ++++++------ dist/lodash.underscore.js | 39 +++++-- dist/lodash.underscore.min.js | 57 ++++----- doc/README.md | 210 +++++++++++++++++----------------- lodash.js | 29 ++++- test/test.js | 74 +++++++++++- 10 files changed, 402 insertions(+), 260 deletions(-) diff --git a/build.js b/build.js index de40b7937..4bfc5c402 100755 --- a/build.js +++ b/build.js @@ -88,14 +88,14 @@ 'cloneDeep': ['clone'], 'compact': [], 'compose': [], - 'contains': ['basicEach', 'basicIndexOf', 'isString'], + 'contains': ['basicEach', 'getIndexOf', 'isString'], 'countBy': ['createCallback', 'forEach'], 'createCallback': ['identity', 'isEqual', 'keys'], 'debounce': ['isObject'], 'defaults': ['createIterator', 'isArguments', 'keys'], 'defer': ['bind'], 'delay': [], - 'difference': ['basicIndexOf', 'createCache'], + 'difference': ['createCache'], 'escape': ['escapeHtmlChar'], 'every': ['basicEach', 'createCallback', 'isArray'], 'filter': ['basicEach', 'createCallback', 'isArray'], @@ -113,7 +113,7 @@ 'identity': [], 'indexOf': ['basicIndexOf', 'sortedIndex'], 'initial': ['slice'], - 'intersection': ['basicIndexOf', 'createCache'], + 'intersection': ['createCache'], 'invert': ['keys'], 'invoke': ['forEach'], 'isArguments': [], @@ -143,7 +143,7 @@ 'min': ['basicEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'], 'mixin': ['forEach', 'functions'], 'noConflict': [], - 'omit': ['basicIndexOf', 'forIn'], + 'omit': ['forIn', 'getIndexOf'], 'once': [], 'pairs': ['keys'], 'parseInt': ['isString'], @@ -172,7 +172,7 @@ 'transform': ['createCallback', 'createObject', 'forOwn', 'isArray'], 'unescape': ['unescapeHtmlChar'], 'union': ['isArray', 'uniq'], - 'uniq': ['basicIndexOf', 'createCache', 'overloadWrapper'], + 'uniq': ['createCache', 'getIndexOf', 'overloadWrapper'], 'uniqueId': [], 'unzip': ['max', 'pluck'], 'value': ['basicEach', 'forOwn', 'isArray', 'lodashWrapper'], @@ -189,11 +189,12 @@ 'charAtCallback': [], 'compareAscending': [], 'createBound': ['createObject', 'isFunction', 'isObject'], - 'createCache': ['basicIndexOf'], + 'createCache': ['basicIndexOf', 'getIndexOf'], 'createIterator': ['iteratorTemplate'], 'createObject': [ 'isObject', 'noop'], 'escapeHtmlChar': [], 'escapeStringChar': [], + 'getIndexOf': ['basicIndexOf', 'indexOf'], 'iteratorTemplate': [], 'isNode': [], 'lodashWrapper': [], @@ -2277,10 +2278,11 @@ if (!useLodashMethod('contains')) { source = replaceFunction(source, 'contains', [ 'function contains(collection, target) {', - ' var length = collection ? collection.length : 0,', + ' var indexOf = getIndexOf(),', + ' length = collection ? collection.length : 0,', ' result = false;', " if (length && typeof length == 'number') {", - ' result = basicIndexOf(collection, target) > -1;', + ' result = indexOf(collection, target) > -1;', ' } else {', ' basicEach(collection, function(value) {', ' return !(result = value === target);', @@ -2347,13 +2349,14 @@ source = replaceFunction(source, 'difference', [ 'function difference(array) {', ' var index = -1,', + ' indexOf = getIndexOf(),', ' length = array.length,', ' flattened = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),', ' result = [];', '', ' while (++index < length) {', ' var value = array[index];', - ' if (basicIndexOf(flattened, value) < 0) {', + ' if (indexOf(flattened, value) < 0) {', ' result.push(value);', ' }', ' }', @@ -2388,16 +2391,17 @@ ' var args = arguments,', ' argsLength = args.length,', ' index = -1,', + ' indexOf = getIndexOf(),', ' length = array ? array.length : 0,', ' result = [];', '', ' outer:', ' while (++index < length) {', ' var value = array[index];', - ' if (basicIndexOf(result, value) < 0) {', + ' if (indexOf(result, value) < 0) {', ' var argsIndex = argsLength;', ' while (--argsIndex) {', - ' if (basicIndexOf(args[argsIndex], value) < 0) {', + ' if (indexOf(args[argsIndex], value) < 0) {', ' continue outer;', ' }', ' }', @@ -2547,11 +2551,12 @@ if (!useLodashMethod('omit')) { source = replaceFunction(source, 'omit', [ 'function omit(object) {', - ' var props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),', + ' var indexOf = getIndexOf(),', + ' props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),', ' result = {};', '', ' forIn(object, function(value, key) {', - ' if (basicIndexOf(props, key) < 0) {', + ' if (indexOf(props, key) < 0) {', ' result[key] = value;', ' }', ' });', @@ -2716,6 +2721,7 @@ source = replaceFunction(source, 'uniq', [ 'function uniq(array, isSorted, callback, thisArg) {', ' var index = -1,', + ' indexOf = getIndexOf(),', ' length = array ? array.length : 0,', ' result = [],', ' seen = result;', @@ -2735,7 +2741,7 @@ '', ' if (isSorted', ' ? !index || seen[seen.length - 1] !== computed', - ' : basicIndexOf(seen, computed) < 0', + ' : indexOf(seen, computed) < 0', ' ) {', ' if (callback) {', ' seen.push(computed);', diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 1a490c72e..9541b516b 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -776,8 +776,9 @@ var bailout, index = -1, + indexOf = getIndexOf(), length = array.length, - isLarge = length >= largeArraySize, + isLarge = length >= largeArraySize && lodash.indexOf != indexOf, objCache = {}; var caches = { @@ -792,7 +793,7 @@ }; function basicContains(value) { - return basicIndexOf(array, value) > -1; + return indexOf(array, value) > -1; } function basicPush(value) { @@ -938,6 +939,19 @@ return '\\' + stringEscapes[match]; } + /** + * Gets the appropriate "indexOf" function. If the `_.indexOf` method is + * customized, this method returns the custom method, otherwise it returns + * the `basicIndexOf` function. + * + * @private + * @returns {Function} Returns the "indexOf" function. + */ + function getIndexOf(array, value, fromIndex) { + var result = (result = lodash.indexOf) == indexOf ? basicIndexOf : result; + return result; + } + /** * Checks if `value` is a DOM node in IE < 9. * @@ -2281,7 +2295,8 @@ * // => { 'name': 'moe' } */ function omit(object, callback, thisArg) { - var isFunc = typeof callback == 'function', + var indexOf = getIndexOf(), + isFunc = typeof callback == 'function', result = {}; if (isFunc) { @@ -2292,7 +2307,7 @@ forIn(object, function(value, key, object) { if (isFunc ? !callback(value, key, object) - : basicIndexOf(props, key) < 0 + : indexOf(props, key) < 0 ) { result[key] = value; } @@ -2518,6 +2533,7 @@ */ function contains(collection, target, fromIndex) { var index = -1, + indexOf = getIndexOf(), length = collection ? collection.length : 0, result = false; @@ -2525,7 +2541,7 @@ if (length && typeof length == 'number') { result = (isString(collection) ? collection.indexOf(target, fromIndex) - : basicIndexOf(collection, target, fromIndex) + : indexOf(collection, target, fromIndex) ) > -1; } else { basicEach(collection, function(value) { @@ -4221,6 +4237,7 @@ */ var uniq = overloadWrapper(function(array, isSorted, callback) { var index = -1, + indexOf = getIndexOf(), length = array ? array.length : 0, isLarge = !isSorted && length >= largeArraySize, result = [], @@ -4232,7 +4249,7 @@ if (isSorted ? !index || seen[seen.length - 1] !== computed - : (isLarge ? !seen.contains(computed) : basicIndexOf(seen, computed) < 0) + : (isLarge ? !seen.contains(computed) : indexOf(seen, computed) < 0) ) { if (callback || isLarge) { seen.push(computed); diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index c5063acc7..6fb6238b4 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,46 +4,46 @@ * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;!function(n){function t(e){function a(n){return n&&typeof n=="object"&&!Or(n)&&rr.call(n,"__wrapped__")?n:new W(n)}function T(n,t,r){r=(r||0)-1;for(var e=n.length;++rt||typeof n=="undefined")return 1;if(n=l,p={},s={"false":!1,"function":!1,"null":!1,number:{},object:p,string:{},"true":!1,undefined:!1}; -if(f){for(;++ok;k++)e+="m='"+t.g[k]+"';if((!(p&&v[m])&&l.call(r,m))",t.i||(e+="||(!v[m]&&r[m]!==y[m])"),e+="){"+t.f+"}"; -e+="}"}return(t.b||wr.nonEnumArgs)&&(e+="}"),e+=t.c+";return C",n("i,j,l,n,o,q,t,u,y,z,w,G,H,J",r+e+"}")(I,Kt,rr,rt,Or,ft,Ar,a,Mt,q,jr,F,Ut,ir)}function M(n){return ct(n)?lr(n):{}}function U(n){return Br[n]}function V(n){return"\\"+D[n]}function Q(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function W(n){this.__wrapped__=n}function X(){}function Y(n){return function(t,e,u,o){return typeof e!="boolean"&&null!=e&&(o=u,u=o&&o[e]===t?r:e,e=!1),null!=u&&(u=a.createCallback(u,o)),n(t,e,u,o) -}}function Z(n){var t,e;return!n||ir.call(n)!=P||(t=n.constructor,it(t)&&!(t instanceof t))||!wr.argsClass&&rt(n)||!wr.nodeClass&&Q(n)?!1:wr.ownLast?(Fr(n,function(n,t,r){return e=rr.call(r,t),!1}),!1!==e):(Fr(n,function(n,t){e=t}),e===r||rr.call(n,e))}function nt(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=zt(0>r?0:r);++er?vr(0,u+r):r)||0,u&&typeof u=="number"?a=-1<(ft(n)?n.indexOf(t,r):T(n,t,r)):Ir(n,function(n){return++eu&&(u=i)}}else t=!t&&ft(n)?L:a.createCallback(t,r),Ir(n,function(n,r,a){r=t(n,r,a),r>e&&(e=r,u=n)});return u}function _t(n,t,r,e){var u=3>arguments.length;if(t=a.createCallback(t,e,4),Or(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var c=Ar(n),o=c.length;else wr.unindexedChars&&ft(n)&&(u=n.split(""));return t=a.createCallback(t,e,4),mt(n,function(n,e,a){e=c?c[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function jt(n,t,r){var e;if(t=a.createCallback(t,r),Or(n)){r=-1;for(var u=n.length;++r>>1,r(n[e])r?0:r);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:y,variable:"",imports:{_:a}};var kr={a:"x,F,k",h:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Nr=at(Br),Pr=K(kr,{h:kr.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=u.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),f:"C[m]=d?d(C[m],r[m]):r[m]"}),zr=K(kr),Fr=K(xr,Er,{i:!1}),$r=K(xr,Er); -it(/x/)&&(it=function(n){return typeof n=="function"&&ir.call(n)==B});var qr=tr?function(n){if(!n||ir.call(n)!=P||!wr.argsClass&&rt(n))return!1;var t=n.valueOf,r=typeof t=="function"&&(r=tr(t))&&tr(r);return r?n==r||tr(n)==r:Z(n)}:Z,Dr=dt,Rr=Y(function Gr(n,t,r){for(var e=-1,u=n?n.length:0,a=[];++e=l,o=[],i=a?J():r?[]:o;++en?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Pr,a.at=function(n){var t=-1,r=Yt.apply(Jt,dr.call(arguments,1)),e=r.length,u=zt(e);for(wr.unindexedChars&&ft(n)&&(n=n.split(""));++t++i&&(a=n.apply(o,u)),c=or(e,t),a}},a.defaults=zr,a.defer=It,a.delay=function(n,t){var e=dr.call(arguments,2);return or(function(){n.apply(r,e)},t)},a.difference=wt,a.filter=ht,a.flatten=Rr,a.forEach=mt,a.forIn=Fr,a.forOwn=$r,a.functions=ut,a.groupBy=function(n,t,r){var e={};return t=a.createCallback(t,r),mt(n,function(n,r,u){r=Gt(t(n,r,u)),(rr.call(e,r)?e[r]:e[r]=[]).push(n) -}),e},a.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else e=null==t||r?1:t||e;return nt(n,0,hr(vr(0,u-e),u))},a.intersection=function(n){var t=arguments,r=t.length,e=J(),u={},a=-1,o=n?n.length:0,i=[];n:for(;++aT(o,r))&&(u[r]=n)}),u},a.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},a.pairs=function(n){for(var t=-1,r=Ar(n),e=r.length,u=zt(e);++tr?vr(0,e+r):r||0}else if(r)return r=Et(n,t),n[r]===t?r:-1;return n?T(n,t,r):-1},a.isArguments=rt,a.isArray=Or,a.isBoolean=function(n){return!0===n||!1===n||ir.call(n)==S},a.isDate=function(n){return n?typeof n=="object"&&ir.call(n)==A:!1 -},a.isElement=function(n){return n?1===n.nodeType:!1},a.isEmpty=function(n){var t=!0;if(!n)return t;var r=ir.call(n),e=n.length;return r==O||r==F||(wr.argsClass?r==E:rt(n))||r==P&&typeof e=="number"&&it(n.splice)?!e:($r(n,function(){return t=!1}),t)},a.isEqual=ot,a.isFinite=function(n){return pr(n)&&!sr(parseFloat(n))},a.isFunction=it,a.isNaN=function(n){return lt(n)&&n!=+n},a.isNull=function(n){return null===n},a.isNumber=lt,a.isObject=ct,a.isPlainObject=qr,a.isRegExp=function(n){return!(!n||!q[typeof n])&&ir.call(n)==z -},a.isString=ft,a.isUndefined=function(n){return typeof n=="undefined"},a.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?vr(0,e+r):hr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},a.mixin=Nt,a.noConflict=function(){return e._=Vt,this},a.parseInt=Lr,a.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=mr();return n%1||t%1?n+hr(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+Zt(r*(t-n+1))},a.reduce=_t,a.reduceRight=Ct,a.result=function(n,t){var e=n?n[t]:r; -return it(e)?n[t]():e},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ar(n).length},a.some=jt,a.sortedIndex=Et,a.template=function(n,t,e){var u=a.templateSettings;n||(n=""),e=zr({},e,u);var o,i=zr({},e.imports,u.imports),u=Ar(i),i=st(i),c=0,l=e.interpolate||_,g="__p+='",l=Lt((e.escape||_).source+"|"+l.source+"|"+(l===y?v:_).source+"|"+(e.evaluate||_).source+"|$","g");n.replace(l,function(t,r,e,u,a,i){return e||(e=u),g+=n.slice(c,i).replace(j,V),r&&(g+="'+__e("+r+")+'"),a&&(o=!0,g+="';"+a+";__p+='"),e&&(g+="'+((__t=("+e+"))==null?'':__t)+'"),c=i+t.length,t -}),g+="';\n",l=e=e.variable,l||(e="obj",g="with("+e+"){"+g+"}"),g=(o?g.replace(f,""):g).replace(p,"$1").replace(s,"$1;"),g="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+g+"return __p}";try{var h=qt(u,"return "+g).apply(r,i)}catch(m){throw m.source=g,m}return t?h(t):(h.source=g,h)},a.unescape=function(n){return null==n?"":Gt(n).replace(g,tt)},a.uniqueId=function(n){var t=++o;return Gt(null==n?"":n)+t -},a.all=vt,a.any=jt,a.detect=yt,a.foldl=_t,a.foldr=Ct,a.include=gt,a.inject=_t,$r(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return er.apply(t,arguments),n.apply(a,t)})}),a.first=kt,a.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return nt(n,vr(0,u-e))}},a.take=kt,a.head=kt,$r(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r); -return null==t||r&&typeof t!="function"?e:new W(e)})}),a.VERSION="1.2.1",a.prototype.toString=function(){return Gt(this.__wrapped__)},a.prototype.value=Pt,a.prototype.valueOf=Pt,Ir(["join","pop","shift"],function(n){var t=Jt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Ir(["push","reverse","sort","unshift"],function(n){var t=Jt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ir(["concat","slice","splice"],function(n){var t=Jt[n];a.prototype[n]=function(){return new W(t.apply(this.__wrapped__,arguments)) -}}),wr.spliceObjects||Ir(["pop","shift","splice"],function(n){var t=Jt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new W(e):e}}),a}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},c=+new Date+"",l=75,f=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,g=/&(?:amp|lt|gt|quot|#39);/g,v=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=(m=/\bthis\b/)&&m.test(t)&&m,d=" \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",b=RegExp("^["+d+"]*0+(?=.$)"),_=/($^)/,C=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),E="[object Arguments]",O="[object Array]",S="[object Boolean]",A="[object Date]",I="[object Error]",B="[object Function]",N="[object Number]",P="[object Object]",z="[object RegExp]",F="[object String]",$={}; -$[B]=!1,$[E]=$[O]=$[S]=$[A]=$[N]=$[P]=$[z]=$[F]=!0;var q={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},D={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},R=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=R, define(function(){return R})):e&&!e.nodeType?u?(u.exports=R)._=R:e._=R:n._=R}(this); \ No newline at end of file +;!function(n){function t(e){function a(n){return n&&typeof n=="object"&&!Ar(n)&&ur.call(n,"__wrapped__")?n:new X(n)}function T(n,t,r){r=(r||0)-1;for(var e=n.length;++rt||typeof n=="undefined")return 1;if(n=l&&a.indexOf!=f,g={},v={"false":!1,"function":!1,"null":!1,number:{},object:g,string:{},"true":!1,undefined:!1}; +if(s){for(;++ik;k++)e+="m='"+t.g[k]+"';if((!(p&&v[m])&&l.call(r,m))",t.i||(e+="||(!v[m]&&r[m]!==y[m])"),e+="){"+t.f+"}"; +e+="}"}return(t.b||xr.nonEnumArgs)&&(e+="}"),e+=t.c+";return C",n("i,j,l,n,o,q,t,u,y,z,w,G,H,J",r+e+"}")(I,Ut,ur,et,Ar,pt,Br,a,Vt,q,kr,F,Qt,lr)}function M(n){return lt(n)?pr(n):{}}function U(n){return Pr[n]}function V(n){return"\\"+D[n]}function Q(){var n=(n=a.indexOf)==Ot?T:n;return n}function W(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function X(n){this.__wrapped__=n}function Y(){}function Z(n){return function(t,e,u,o){return typeof e!="boolean"&&null!=e&&(o=u,u=o&&o[e]===t?r:e,e=!1),null!=u&&(u=a.createCallback(u,o)),n(t,e,u,o) +}}function nt(n){var t,e;return!n||lr.call(n)!=P||(t=n.constructor,ct(t)&&!(t instanceof t))||!xr.argsClass&&et(n)||!xr.nodeClass&&W(n)?!1:xr.ownLast?(qr(n,function(n,t,r){return e=ur.call(r,t),!1}),!1!==e):(qr(n,function(n,t){e=t}),e===r||ur.call(n,e))}function tt(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=$t(0>r?0:r);++er?yr(0,a+r):r)||0,a&&typeof a=="number"?o=-1<(pt(n)?n.indexOf(t,r):u(n,t,r)):Nr(n,function(n){return++eu&&(u=i)}}else t=!t&&pt(n)?L:a.createCallback(t,r),Nr(n,function(n,r,a){r=t(n,r,a),r>e&&(e=r,u=n)});return u}function Ct(n,t,r,e){var u=3>arguments.length;if(t=a.createCallback(t,e,4),Ar(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var c=Br(n),o=c.length;else xr.unindexedChars&&pt(n)&&(u=n.split(""));return t=a.createCallback(t,e,4),dt(n,function(n,e,a){e=c?c[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function wt(n,t,r){var e;if(t=a.createCallback(t,r),Ar(n)){r=-1;for(var u=n.length;++rr?yr(0,e+r):r||0}else if(r)return r=St(n,t),n[r]===t?r:-1;return n?T(n,t,r):-1}function Et(n,t,r){if(typeof t!="number"&&null!=t){var e=0,u=-1,o=n?n.length:0;for(t=a.createCallback(t,r);++u>>1,r(n[e])r?0:r);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:y,variable:"",imports:{_:a}};var Or={a:"x,F,k",h:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},zr=ot(Pr),Fr=K(Or,{h:Or.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=u.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),f:"C[m]=d?d(C[m],r[m]):r[m]"}),$r=K(Or),qr=K(Er,Sr,{i:!1}),Dr=K(Er,Sr); +ct(/x/)&&(ct=function(n){return typeof n=="function"&&lr.call(n)==B});var Rr=er?function(n){if(!n||lr.call(n)!=P||!xr.argsClass&&et(n))return!1;var t=n.valueOf,r=typeof t=="function"&&(r=er(t))&&er(r);return r?n==r||er(n)==r:nt(n)}:nt,Tr=bt,Lr=Z(function Jr(n,t,r){for(var e=-1,u=n?n.length:0,a=[];++e=l,i=[],c=o?J():r?[]:i;++en?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Fr,a.at=function(n){var t=-1,r=nr.apply(Mt,_r.call(arguments,1)),e=r.length,u=$t(e);for(xr.unindexedChars&&pt(n)&&(n=n.split(""));++t++i&&(a=n.apply(o,u)),c=cr(e,t),a}},a.defaults=$r,a.defer=Nt,a.delay=function(n,t){var e=_r.call(arguments,2);return cr(function(){n.apply(r,e)},t)},a.difference=kt,a.filter=yt,a.flatten=Lr,a.forEach=dt,a.forIn=qr,a.forOwn=Dr,a.functions=at,a.groupBy=function(n,t,r){var e={};return t=a.createCallback(t,r),dt(n,function(n,r,u){r=Jt(t(n,r,u)),(ur.call(e,r)?e[r]:e[r]=[]).push(n) +}),e},a.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else e=null==t||r?1:t||e;return tt(n,0,mr(yr(0,u-e),u))},a.intersection=function(n){var t=arguments,r=t.length,e=J(),u={},a=-1,o=n?n.length:0,i=[];n:for(;++ae(i,r))&&(o[r]=n)}),o},a.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},a.pairs=function(n){for(var t=-1,r=Br(n),e=r.length,u=$t(e);++tr?yr(0,e+r):mr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},a.mixin=zt,a.noConflict=function(){return e._=Wt,this},a.parseInt=Hr,a.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=br();return n%1||t%1?n+mr(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+tr(r*(t-n+1))},a.reduce=Ct,a.reduceRight=jt,a.result=function(n,t){var e=n?n[t]:r;return ct(e)?n[t]():e},a.runInContext=t,a.size=function(n){var t=n?n.length:0; +return typeof t=="number"?t:Br(n).length},a.some=wt,a.sortedIndex=St,a.template=function(n,t,e){var u=a.templateSettings;n||(n=""),e=$r({},e,u);var o,i=$r({},e.imports,u.imports),u=Br(i),i=gt(i),c=0,l=e.interpolate||_,g="__p+='",l=Ht((e.escape||_).source+"|"+l.source+"|"+(l===y?v:_).source+"|"+(e.evaluate||_).source+"|$","g");n.replace(l,function(t,r,e,u,a,i){return e||(e=u),g+=n.slice(c,i).replace(j,V),r&&(g+="'+__e("+r+")+'"),a&&(o=!0,g+="';"+a+";__p+='"),e&&(g+="'+((__t=("+e+"))==null?'':__t)+'"),c=i+t.length,t +}),g+="';\n",l=e=e.variable,l||(e="obj",g="with("+e+"){"+g+"}"),g=(o?g.replace(f,""):g).replace(p,"$1").replace(s,"$1;"),g="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+g+"return __p}";try{var h=Rt(u,"return "+g).apply(r,i)}catch(m){throw m.source=g,m}return t?h(t):(h.source=g,h)},a.unescape=function(n){return null==n?"":Jt(n).replace(g,rt)},a.uniqueId=function(n){var t=++o;return Jt(null==n?"":n)+t +},a.all=ht,a.any=wt,a.detect=mt,a.foldl=Ct,a.foldr=jt,a.include=vt,a.inject=Ct,Dr(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return ar.apply(t,arguments),n.apply(a,t)})}),a.first=xt,a.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return tt(n,yr(0,u-e))}},a.take=xt,a.head=xt,Dr(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r); +return null==t||r&&typeof t!="function"?e:new X(e)})}),a.VERSION="1.2.1",a.prototype.toString=function(){return Jt(this.__wrapped__)},a.prototype.value=Ft,a.prototype.valueOf=Ft,Nr(["join","pop","shift"],function(n){var t=Mt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Nr(["push","reverse","sort","unshift"],function(n){var t=Mt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Nr(["concat","slice","splice"],function(n){var t=Mt[n];a.prototype[n]=function(){return new X(t.apply(this.__wrapped__,arguments)) +}}),xr.spliceObjects||Nr(["pop","shift","splice"],function(n){var t=Mt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new X(e):e}}),a}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},c=+new Date+"",l=75,f=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,g=/&(?:amp|lt|gt|quot|#39);/g,v=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=(m=/\bthis\b/)&&m.test(t)&&m,d=" \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",b=RegExp("^["+d+"]*0+(?=.$)"),_=/($^)/,C=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),O="[object Arguments]",E="[object Array]",S="[object Boolean]",A="[object Date]",I="[object Error]",B="[object Function]",N="[object Number]",P="[object Object]",z="[object RegExp]",F="[object String]",$={}; +$[B]=!1,$[O]=$[E]=$[S]=$[A]=$[N]=$[P]=$[z]=$[F]=!0;var q={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},D={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},R=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=R, define(function(){return R})):e&&!e.nodeType?u?(u.exports=R)._=R:e._=R:n._=R}(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 9d5dc2850..fd4c3b4c3 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -506,8 +506,9 @@ var bailout, index = -1, + indexOf = getIndexOf(), length = array.length, - isLarge = length >= largeArraySize, + isLarge = length >= largeArraySize && lodash.indexOf != indexOf, objCache = {}; var caches = { @@ -522,7 +523,7 @@ }; function basicContains(value) { - return basicIndexOf(array, value) > -1; + return indexOf(array, value) > -1; } function basicPush(value) { @@ -605,6 +606,19 @@ return '\\' + stringEscapes[match]; } + /** + * Gets the appropriate "indexOf" function. If the `_.indexOf` method is + * customized, this method returns the custom method, otherwise it returns + * the `basicIndexOf` function. + * + * @private + * @returns {Function} Returns the "indexOf" function. + */ + function getIndexOf(array, value, fromIndex) { + var result = (result = lodash.indexOf) == indexOf ? basicIndexOf : result; + return result; + } + /** * A fast path for creating `lodash` wrapper objects. * @@ -1948,7 +1962,8 @@ * // => { 'name': 'moe' } */ function omit(object, callback, thisArg) { - var isFunc = typeof callback == 'function', + var indexOf = getIndexOf(), + isFunc = typeof callback == 'function', result = {}; if (isFunc) { @@ -1959,7 +1974,7 @@ forIn(object, function(value, key, object) { if (isFunc ? !callback(value, key, object) - : basicIndexOf(props, key) < 0 + : indexOf(props, key) < 0 ) { result[key] = value; } @@ -2182,6 +2197,7 @@ */ function contains(collection, target, fromIndex) { var index = -1, + indexOf = getIndexOf(), length = collection ? collection.length : 0, result = false; @@ -2189,7 +2205,7 @@ if (length && typeof length == 'number') { result = (isString(collection) ? collection.indexOf(target, fromIndex) - : basicIndexOf(collection, target, fromIndex) + : indexOf(collection, target, fromIndex) ) > -1; } else { forOwn(collection, function(value) { @@ -3895,6 +3911,7 @@ */ var uniq = overloadWrapper(function(array, isSorted, callback) { var index = -1, + indexOf = getIndexOf(), length = array ? array.length : 0, isLarge = !isSorted && length >= largeArraySize, result = [], @@ -3906,7 +3923,7 @@ if (isSorted ? !index || seen[seen.length - 1] !== computed - : (isLarge ? !seen.contains(computed) : basicIndexOf(seen, computed) < 0) + : (isLarge ? !seen.contains(computed) : indexOf(seen, computed) < 0) ) { if (callback || isLarge) { seen.push(computed); diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 1c0e20bdc..23c306b7c 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,42 +4,41 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;!function(n){function t(o){function f(n){if(!n||oe.call(n)!=B)return a;var t=n.valueOf,e=typeof t=="function"&&(e=te(t))&&te(e);return e?n==e||te(n)==e:tt(n)}function P(n,t,e){if(!n||!q[typeof n])return n;t=t&&typeof e=="undefined"?t:G.createCallback(t,e);for(var r=-1,u=q[typeof n]?ke(n):[],o=u.length;++rt||typeof n=="undefined")return 1;if(n=s,g={},y={"false":a,"function":a,"null":a,number:{},object:g,string:{},"true":a,undefined:a};if(v){for(;++ce?0:e);++re?ve(0,u+e):e)||0,u&&typeof u=="number"?o=-1<(pt(n)?n.indexOf(t,e):H(n,t,e)):P(n,function(n){return++ru&&(u=o) -}}else t=!t&&pt(n)?J:G.createCallback(t,e),mt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function kt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Tt(r);++earguments.length;t=G.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length; -if(typeof u!="number")var i=ke(n),u=i.length;return t=G.createCallback(t,r,4),mt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function Ct(n,t,e){var r;t=G.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:G}},Z.prototype=G.prototype;var _e=ce,ke=se?function(n){return ct(n)?se(n):[]}:V,je={"&":"&","<":"<",">":">",'"':""","'":"'"},we=ot(je),qt=nt(function xe(n,t,e){for(var r=-1,u=n?n.length:0,a=[];++r=s,o=[],i=a?W():e?[]:o;++rn?t():function(){return 1>--n?t.apply(this,arguments):void 0}},G.assign=U,G.at=function(n){for(var t=-1,e=Yt.apply(Ht,be.call(arguments,1)),r=e.length,u=Tt(r);++t++l&&(f=n.apply(c,i)),p=ae(o,t),f}},G.defaults=M,G.defer=$t,G.delay=function(n,t){var r=be.call(arguments,2);return ae(function(){n.apply(e,r)},t)},G.difference=xt,G.filter=ht,G.flatten=qt,G.forEach=mt,G.forIn=K,G.forOwn=P,G.functions=at,G.groupBy=function(n,t,e){var r={};return t=G.createCallback(t,e),mt(n,function(n,e,u){e=Vt(t(n,e,u)),(ee.call(r,e)?r[e]:r[e]=[]).push(n) -}),r},G.initial=function(n,t,e){if(!n)return[];var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=t==u||e?1:t||r;return et(n,0,ge(ve(0,a-r),a))},G.intersection=function(n){var t=arguments,e=t.length,r=W(),u={},a=-1,o=n?n.length:0,i=[];n:for(;++aH(a,e))&&(u[e]=n)}),u},G.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},G.pairs=function(n){for(var t=-1,e=ke(n),r=e.length,u=Tt(r);++te?ve(0,r+e):e||0}else if(e)return e=St(n,t),n[e]===t?e:-1;return n?H(n,t,e):-1},G.isArguments=function(n){return oe.call(n)==E},G.isArray=_e,G.isBoolean=function(n){return n===r||n===a||oe.call(n)==I -},G.isDate=function(n){return n?typeof n=="object"&&oe.call(n)==N:a},G.isElement=function(n){return n?1===n.nodeType:a},G.isEmpty=function(n){var t=r;if(!n)return t;var e=oe.call(n),u=n.length;return e==S||e==R||e==E||e==B&&typeof u=="number"&&ft(n.splice)?!u:(P(n,function(){return t=a}),t)},G.isEqual=it,G.isFinite=function(n){return le(n)&&!pe(parseFloat(n))},G.isFunction=ft,G.isNaN=function(n){return lt(n)&&n!=+n},G.isNull=function(n){return n===u},G.isNumber=lt,G.isObject=ct,G.isPlainObject=f,G.isRegExp=function(n){return n?typeof n=="object"&&oe.call(n)==F:a -},G.isString=pt,G.isUndefined=function(n){return typeof n=="undefined"},G.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?ve(0,r+e):ge(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},G.mixin=Ft,G.noConflict=function(){return o._=Lt,this},G.parseInt=ue,G.random=function(n,t){n==u&&t==u&&(t=1),n=+n||0,t==u?(t=n,n=0):t=+t||0;var e=he();return n%1||t%1?n+ge(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+Zt(e*(t-n+1))},G.reduce=jt,G.reduceRight=wt,G.result=function(n,t){var r=n?n[t]:e; -return ft(r)?n[t]():r},G.runInContext=t,G.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ke(n).length},G.some=Ct,G.sortedIndex=St,G.template=function(n,t,u){var a=G.templateSettings;n||(n=""),u=M({},u,a);var o,i=M({},u.imports,a.imports),a=ke(i),i=vt(i),f=0,c=u.interpolate||w,l="__p+='",c=Ut((u.escape||w).source+"|"+c.source+"|"+(c===d?b:w).source+"|"+(u.evaluate||w).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(x,Y),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t -}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=zt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},G.unescape=function(n){return n==u?"":Vt(n).replace(h,rt)},G.uniqueId=function(n){var t=++c;return Vt(n==u?"":n)+t -},G.all=yt,G.any=Ct,G.detect=bt,G.foldl=jt,G.foldr=wt,G.include=gt,G.inject=jt,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(){var t=[this.__wrapped__];return re.apply(t,arguments),n.apply(G,t)})}),G.first=Ot,G.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return et(n,ve(0,a-r))}},G.take=Ot,G.head=Ot,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); -return t==u||e&&typeof t!="function"?r:new Z(r)})}),G.VERSION="1.2.1",G.prototype.toString=function(){return Vt(this.__wrapped__)},G.prototype.value=Rt,G.prototype.valueOf=Rt,mt(["join","pop","shift"],function(n){var t=Ht[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),mt(["push","reverse","sort","unshift"],function(n){var t=Ht[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),mt(["concat","slice","splice"],function(n){var t=Ht[n];G.prototype[n]=function(){return new Z(t.apply(this.__wrapped__,arguments)) -}}),G}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=75,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,b=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,m=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=(_=/\bthis\b/)&&_.test(t)&&_,k=" \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",j=RegExp("^["+k+"]*0+(?=.$)"),w=/($^)/,C=/[&<>"']/g,x=/['\n\r\t\u2028\u2029\\]/g,O="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),E="[object Arguments]",S="[object Array]",I="[object Boolean]",N="[object Date]",A="[object Function]",$="[object Number]",B="[object Object]",F="[object RegExp]",R="[object String]",T={}; +;!function(n){function t(o){function f(n){if(!n||fe.call(n)!=B)return a;var t=n.valueOf,e=typeof t=="function"&&(e=re(t))&&re(e);return e?n==e||re(n)==e:et(n)}function P(n,t,e){if(!n||!q[typeof n])return n;t=t&&typeof e=="undefined"?t:G.createCallback(t,e);for(var r=-1,u=q[typeof n]?xe(n):[],o=u.length;++rt||typeof n=="undefined")return 1;if(n=s&&G.indexOf!=l,y={},h={"false":a,"function":a,"null":a,number:{},object:y,string:{},"true":a,undefined:a};if(g){for(;++ce?0:e);++re?ye(0,o+e):e)||0,o&&typeof o=="number"?i=-1<(st(n)?n.indexOf(t,e):u(n,t,e)):P(n,function(n){return++ru&&(u=o)}}else t=!t&&st(n)?J:G.createCallback(t,e),dt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function jt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Dt(r);++earguments.length;t=G.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;if(typeof u!="number")var i=xe(n),u=i.length;return t=G.createCallback(t,r,4),dt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function xt(n,t,e){var r;t=G.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++ee?ye(0,r+e):e||0}else if(e)return e=Nt(n,t),n[e]===t?e:-1;return n?H(n,t,e):-1}function It(n,t,e){if(typeof t!="number"&&t!=u){var r=0,a=-1,o=n?n.length:0;for(t=G.createCallback(t,e);++a>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:G}},nt.prototype=G.prototype;var Ce=pe,xe=ge?function(n){return lt(n)?ge(n):[]}:V,Oe={"&":"&","<":"<",">":">",'"':""","'":"'"},Ee=it(Oe),Se=tt(function Ae(n,t,e){for(var r=-1,u=n?n.length:0,a=[];++r=s,i=[],f=o?W():e?[]:i;++rn?t():function(){return 1>--n?t.apply(this,arguments):void 0}},G.assign=U,G.at=function(n){for(var t=-1,e=ne.apply(Lt,de.call(arguments,1)),r=e.length,u=Dt(r);++t++l&&(f=n.apply(c,i)),p=ie(o,t),f}},G.defaults=M,G.defer=Ft,G.delay=function(n,t){var r=de.call(arguments,2);return ie(function(){n.apply(e,r)},t)},G.difference=Ot,G.filter=bt,G.flatten=Se,G.forEach=dt,G.forIn=K,G.forOwn=P,G.functions=ot,G.groupBy=function(n,t,e){var r={};return t=G.createCallback(t,e),dt(n,function(n,e,u){e=Ht(t(n,e,u)),(ue.call(r,e)?r[e]:r[e]=[]).push(n) +}),r},G.initial=function(n,t,e){if(!n)return[];var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=t==u||e?1:t||r;return rt(n,0,he(ye(0,a-r),a))},G.intersection=function(n){var t=arguments,e=t.length,r=W(),u={},a=-1,o=n?n.length:0,i=[];n:for(;++ar(o,e))&&(a[e]=n)}),a},G.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},G.pairs=function(n){for(var t=-1,e=xe(n),r=e.length,u=Dt(r);++te?ye(0,r+e):he(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},G.mixin=Tt,G.noConflict=function(){return o._=Wt,this},G.parseInt=Ne,G.random=function(n,t){n==u&&t==u&&(t=1),n=+n||0,t==u?(t=n,n=0):t=+t||0;var e=me();return n%1||t%1?n+he(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+te(e*(t-n+1))},G.reduce=wt,G.reduceRight=Ct,G.result=function(n,t){var r=n?n[t]:e;return ct(r)?n[t]():r},G.runInContext=t,G.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:xe(n).length +},G.some=xt,G.sortedIndex=Nt,G.template=function(n,t,u){var a=G.templateSettings;n||(n=""),u=M({},u,a);var o,i=M({},u.imports,a.imports),a=xe(i),i=gt(i),f=0,c=u.interpolate||w,l="__p+='",c=Gt((u.escape||w).source+"|"+c.source+"|"+(c===d?b:w).source+"|"+(u.evaluate||w).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(x,Y),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}"; +try{var p=Kt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},G.unescape=function(n){return n==u?"":Ht(n).replace(h,ut)},G.uniqueId=function(n){var t=++c;return Ht(n==u?"":n)+t},G.all=ht,G.any=xt,G.detect=mt,G.foldl=wt,G.foldr=Ct,G.include=yt,G.inject=wt,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(){var t=[this.__wrapped__];return ae.apply(t,arguments),n.apply(G,t)})}),G.first=Et,G.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a; +for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return rt(n,ye(0,a-r))}},G.take=Et,G.head=Et,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return t==u||e&&typeof t!="function"?r:new nt(r)})}),G.VERSION="1.2.1",G.prototype.toString=function(){return Ht(this.__wrapped__)},G.prototype.value=qt,G.prototype.valueOf=qt,dt(["join","pop","shift"],function(n){var t=Lt[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments) +}}),dt(["push","reverse","sort","unshift"],function(n){var t=Lt[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),dt(["concat","slice","splice"],function(n){var t=Lt[n];G.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments))}}),G}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=75,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,b=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,m=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=(_=/\bthis\b/)&&_.test(t)&&_,k=" \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",j=RegExp("^["+k+"]*0+(?=.$)"),w=/($^)/,C=/[&<>"']/g,x=/['\n\r\t\u2028\u2029\\]/g,O="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),E="[object Arguments]",S="[object Array]",I="[object Boolean]",N="[object Date]",A="[object Function]",$="[object Number]",B="[object Object]",F="[object RegExp]",R="[object String]",T={}; T[A]=a,T[E]=T[S]=T[I]=T[N]=T[$]=T[B]=T[F]=T[R]=r;var q={"boolean":a,"function":r,object:r,number:a,string:a,undefined:a},D={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},z=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=z, define(function(){return z})):o&&!o.nodeType?i?(i.exports=z)._=z:o._=z:n._=z}(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index beeaaae7f..fb47ab194 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -430,8 +430,9 @@ var bailout, index = -1, + indexOf = getIndexOf(), length = array.length, - isLarge = length >= largeArraySize, + isLarge = length >= largeArraySize && lodash.indexOf != indexOf, objCache = {}; var caches = { @@ -446,7 +447,7 @@ }; function basicContains(value) { - return basicIndexOf(array, value) > -1; + return indexOf(array, value) > -1; } function basicPush(value) { @@ -540,6 +541,19 @@ return '\\' + stringEscapes[match]; } + /** + * Gets the appropriate "indexOf" function. If the `_.indexOf` method is + * customized, this method returns the custom method, otherwise it returns + * the `basicIndexOf` function. + * + * @private + * @returns {Function} Returns the "indexOf" function. + */ + function getIndexOf(array, value, fromIndex) { + var result = (result = lodash.indexOf) == indexOf ? basicIndexOf : result; + return result; + } + /** * A fast path for creating `lodash` wrapper objects. * @@ -1432,11 +1446,12 @@ * // => { 'name': 'moe' } */ function omit(object) { - var props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)), + var indexOf = getIndexOf(), + props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)), result = {}; forIn(object, function(value, key) { - if (basicIndexOf(props, key) < 0) { + if (indexOf(props, key) < 0) { result[key] = value; } }); @@ -1565,10 +1580,11 @@ * // => true */ function contains(collection, target) { - var length = collection ? collection.length : 0, + var indexOf = getIndexOf(), + length = collection ? collection.length : 0, result = false; if (length && typeof length == 'number') { - result = basicIndexOf(collection, target) > -1; + result = indexOf(collection, target) > -1; } else { forOwn(collection, function(value) { return (result = value === target) && indicatorObject; @@ -2596,13 +2612,14 @@ */ function difference(array) { var index = -1, + indexOf = getIndexOf(), length = array.length, flattened = concat.apply(arrayProto, nativeSlice.call(arguments, 1)), result = []; while (++index < length) { var value = array[index]; - if (basicIndexOf(flattened, value) < 0) { + if (indexOf(flattened, value) < 0) { result.push(value); } } @@ -2873,16 +2890,17 @@ var args = arguments, argsLength = args.length, index = -1, + indexOf = getIndexOf(), length = array ? array.length : 0, result = []; outer: while (++index < length) { var value = array[index]; - if (basicIndexOf(result, value) < 0) { + if (indexOf(result, value) < 0) { var argsIndex = argsLength; while (--argsIndex) { - if (basicIndexOf(args[argsIndex], value) < 0) { + if (indexOf(args[argsIndex], value) < 0) { continue outer; } } @@ -3258,6 +3276,7 @@ */ function uniq(array, isSorted, callback, thisArg) { var index = -1, + indexOf = getIndexOf(), length = array ? array.length : 0, result = [], seen = result; @@ -3277,7 +3296,7 @@ if (isSorted ? !index || seen[seen.length - 1] !== computed - : basicIndexOf(seen, computed) < 0 + : indexOf(seen, computed) < 0 ) { if (callback) { seen.push(computed); diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 85c7df7e8..a90a55f18 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -4,31 +4,32 @@ * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;!function(n){function t(n,t){var r;if(n&&ht[typeof n])for(r in n)if(xt.call(n,r)&&t(n[r],r,n)===tt)break}function r(n,t){var r;if(n&&ht[typeof n])for(r in n)if(t(n[r],r,n)===tt)break}function e(n){var t,r=[];if(!n||!ht[typeof n])return r;for(t in n)xt.call(n,t)&&r.push(t);return r}function u(n){return n instanceof u?n:new p(n)}function o(n,t,r){r=(r||0)-1;for(var e=n.length;++rt||typeof n=="undefined")return 1; -if(ne&&(e=r,u=n)});else for(;++ou&&(u=r);return u}function R(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=G(r,u,4);var i=-1,a=n.length; -if(typeof a=="number")for(o&&(e=n[++i]);++iarguments.length;if(typeof u!="number")var i=Pt(n),u=i.length;return t=G(t,e,4),B(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=Q,n[a]):t(r,n[a],a,f)}),r}function T(n,r,e){var u;r=G(r,e),e=-1;var o=n?n.length:0;if(typeof o=="number")for(;++eo(e,i)&&u.push(i)}return u}function z(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=-1;for(t=G(t,r);++o>>1,r(n[e])o(f,c))&&(r&&f.push(c),a.push(e))}return a}function W(n,t){return zt.fastBind||Nt&&2"']/g,it=/['\n\r\t\u2028\u2029\\]/g,at="[object Arguments]",ft="[object Array]",ct="[object Boolean]",lt="[object Date]",pt="[object Number]",st="[object Object]",vt="[object RegExp]",gt="[object String]",ht={"boolean":Q,"function":K,object:K,number:Q,string:Q,undefined:Q},yt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},mt=Array.prototype,Z=Object.prototype,_t=n._,bt=RegExp("^"+(Z.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),dt=Math.ceil,jt=n.clearTimeout,wt=mt.concat,At=Math.floor,xt=Z.hasOwnProperty,Ot=mt.push,Et=n.setTimeout,St=Z.toString,Nt=bt.test(Nt=St.bind)&&Nt,kt=bt.test(kt=Object.create)&&kt,Bt=bt.test(Bt=Array.isArray)&&Bt,Ft=n.isFinite,qt=n.isNaN,Rt=bt.test(Rt=Object.keys)&&Rt,Dt=Math.max,Mt=Math.min,Tt=Math.random,$t=mt.slice,Z=bt.test(n.attachEvent),It=Nt&&!/\n|true/.test(Nt+Z),zt={}; -!function(){var n={0:1,length:1};zt.fastBind=Nt&&!It,zt.spliceObjects=(mt.splice.call(n,0,1),!n[0])}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},kt||(f=function(n){if(w(n)){s.prototype=n;var t=new s;s.prototype=L}return t||{}}),p.prototype=u.prototype,g(arguments)||(g=function(n){return n?xt.call(n,"callee"):Q});var Ct=Bt||function(n){return n?typeof n=="object"&&St.call(n)==ft:Q},Pt=Rt?function(n){return w(n)?Rt(n):[]}:e,Ut={"&":"&","<":"<",">":">",'"':""","'":"'"},Vt=_(Ut); -j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==St.call(n)}),u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},u.bind=W,u.bindAll=function(n){for(var t=1o(i,a)){for(var f=r;--f;)if(0>o(t[f],a))continue n;i.push(a)}}return i},u.invert=_,u.invoke=function(n,t){var r=$t.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return B(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=Pt,u.map=F,u.max=q,u.memoize=function(n,t){var r={};return function(){var e=rt+(t?t.apply(this,arguments):arguments[0]);return xt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},u.min=function(n,t,r){var e=1/0,u=e,o=-1,i=n?n.length:0;if(t||typeof i!="number")t=G(t,r),B(n,function(n,r,o){r=t(n,r,o),ro(t,r)&&(e[r]=n) -}),e},u.once=function(n){var t,r;return function(){return t?r:(t=K,r=n.apply(this,arguments),n=L,r)}},u.pairs=function(n){for(var t=-1,r=Pt(n),e=r.length,u=Array(e);++tr?0:r);++tr?Dt(0,e+r):r||0}else if(r)return r=U(n,t),n[r]===t?r:-1;return n?o(n,t,r):-1},u.isArguments=g,u.isArray=Ct,u.isBoolean=function(n){return n===K||n===Q||St.call(n)==ct},u.isDate=function(n){return n?typeof n=="object"&&St.call(n)==lt:Q},u.isElement=function(n){return n?1===n.nodeType:Q},u.isEmpty=b,u.isEqual=d,u.isFinite=function(n){return Ft(n)&&!qt(parseFloat(n)) -},u.isFunction=j,u.isNaN=function(n){return A(n)&&n!=+n},u.isNull=function(n){return n===L},u.isNumber=A,u.isObject=w,u.isRegExp=function(n){return!(!n||!ht[typeof n])&&St.call(n)==vt},u.isString=x,u.isUndefined=function(n){return typeof n=="undefined"},u.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?Dt(0,e+r):Mt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=J,u.noConflict=function(){return n._=_t,this},u.random=function(n,t){n==L&&t==L&&(t=1),n=+n||0,t==L?(t=n,n=0):t=+t||0; -var r=Tt();return n%1||t%1?n+Mt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+At(r*(t-n+1))},u.reduce=D,u.reduceRight=M,u.result=function(n,t){var r=n?n[t]:L;return j(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Pt(n).length},u.some=T,u.sortedIndex=U,u.template=function(n,t,r){n||(n=""),r=y({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||ut).source+"|"+(r.interpolate||ut).source+"|"+(r.evaluate||ut).source+"|$","g"),function(t,r,u,i,a){return o+=n.slice(e,a).replace(it,l),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+t.length,t -}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var a=Function("_","return "+o)(u)}catch(f){throw f.source=o,f}return t?a(t):(a.source=o,a)},u.unescape=function(n){return n==L?"":(n+"").replace(et,v)},u.uniqueId=function(n){var t=++nt+"";return n?n+t:t},u.all=S,u.any=T,u.detect=k,u.foldl=D,u.foldr=M,u.include=E,u.inject=D,u.first=z,u.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&t!=L){var o=u;for(t=G(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return $t.call(n,Dt(0,u-e))}},u.take=z,u.head=z,u.VERSION="1.2.1",J(u),u.prototype.chain=function(){return this.__chain__=K,this},u.prototype.value=function(){return this.__wrapped__},B("pop push reverse shift sort splice unshift".split(" "),function(n){var t=mt[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!zt.spliceObjects&&0===n.length&&delete n[0],this}}),B(["concat","join","slice"],function(n){var t=mt[n]; -u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new p(n),n.__chain__=K),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=u, define(function(){return u})):X&&!X.nodeType?Y?(Y.exports=u)._=u:X._=u:n._=u}(this); \ No newline at end of file +;!function(n){function t(n){return n instanceof t?n:new l(n)}function r(n,t,r){r=(r||0)-1;for(var e=n.length;++rt||typeof n=="undefined")return 1;if(ne&&(e=r,u=n)}); +else for(;++ou&&(u=r);return u}function k(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;t=W(t,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=$t(n),u=i.length;return t=W(t,e,4),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=!1,n[a]):t(r,n[a],a,f) +}),r}function D(n,t,r){var e;t=W(t,r),r=-1;var u=n?n.length:0;if(typeof u=="number")for(;++rr(u,i)&&o.push(i)}return o}function $(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=W(t,r);++oe?Ft(0,u+e):e||0}else if(e)return e=P(n,t),n[e]===t?e:-1;return n?r(n,t,e):-1}function C(n,t,r){if(typeof t!="number"&&null!=t){var e=0,u=-1,o=n?n.length:0;for(t=W(t,r);++u>>1,r(n[e])o(l,c))&&(r&&l.push(c),a.push(e))}return a}function V(n,t){return Mt.fastBind||xt&&2"']/g,rt=/['\n\r\t\u2028\u2029\\]/g,et="[object Arguments]",ut="[object Array]",ot="[object Boolean]",it="[object Date]",at="[object Number]",ft="[object Object]",lt="[object RegExp]",ct="[object String]",pt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},st={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},vt=Array.prototype,L=Object.prototype,gt=n._,ht=RegExp("^"+(L.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=Math.ceil,mt=n.clearTimeout,_t=vt.concat,bt=Math.floor,dt=L.hasOwnProperty,jt=vt.push,wt=n.setTimeout,At=L.toString,xt=ht.test(xt=At.bind)&&xt,Ot=ht.test(Ot=Object.create)&&Ot,Et=ht.test(Et=Array.isArray)&&Et,St=n.isFinite,Nt=n.isNaN,Bt=ht.test(Bt=Object.keys)&&Bt,Ft=Math.max,kt=Math.min,qt=Math.random,Rt=vt.slice,L=ht.test(n.attachEvent),Dt=xt&&!/\n|true/.test(xt+L),Mt={}; +!function(){var n={0:1,length:1};Mt.fastBind=xt&&!Dt,Mt.spliceObjects=(vt.splice.call(n,0,1),!n[0])}(1),t.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Ot||(o=function(n){if(d(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}}),l.prototype=t.prototype,s(arguments)||(s=function(n){return n?dt.call(n,"callee"):!1});var Tt=Et||function(n){return n?typeof n=="object"&&At.call(n)==ut:!1},Et=function(n){var t,r=[];if(!n||!pt[typeof n])return r; +for(t in n)dt.call(n,t)&&r.push(t);return r},$t=Bt?function(n){return d(n)?Bt(n):[]}:Et,It={"&":"&","<":"<",">":">",'"':""","'":"'"},zt=y(It),Ct=function(n,t){var r;if(!n||!pt[typeof n])return n;for(r in n)if(t(n[r],r,n)===X)break;return n},Pt=function(n,t){var r;if(!n||!pt[typeof n])return n;for(r in n)if(dt.call(n,r)&&t(n[r],r,n)===X)break;return n};b(/x/)&&(b=function(n){return typeof n=="function"&&"[object Function]"==At.call(n)}),t.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},t.bind=V,t.bindAll=function(n){for(var t=1u(i,a)){for(var l=r;--l;)if(0>u(t[l],a))continue n;i.push(a)}}return i},t.invert=y,t.invoke=function(n,t){var r=Rt.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return N(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},t.keys=$t,t.map=B,t.max=F,t.memoize=function(n,t){var r={};return function(){var e=Y+(t?t.apply(this,arguments):arguments[0]);return dt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},t.min=function(n,t,r){var e=1/0,u=e,o=-1,i=n?n.length:0;if(t||typeof i!="number")t=W(t,r),N(n,function(n,r,o){r=t(n,r,o),rt(r,u)&&(e[u]=n) +}),e},t.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},t.pairs=function(n){for(var t=-1,r=$t(n),e=r.length,u=Array(e);++tr?0:r);++tr?Ft(0,e+r):kt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},t.mixin=H,t.noConflict=function(){return n._=gt,this},t.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=qt();return n%1||t%1?n+kt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+bt(r*(t-n+1)) +},t.reduce=q,t.reduceRight=R,t.result=function(n,t){var r=n?n[t]:null;return b(r)?n[t]():r},t.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:$t(n).length},t.some=D,t.sortedIndex=P,t.template=function(n,r,e){n||(n=""),e=g({},e,t.templateSettings);var u=0,o="__p+='",i=e.variable;n.replace(RegExp((e.escape||nt).source+"|"+(e.interpolate||nt).source+"|"+(e.evaluate||nt).source+"|$","g"),function(t,r,e,i,f){return o+=n.slice(u,f).replace(rt,a),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),e&&(o+="'+((__t=("+e+"))==null?'':__t)+'"),u=f+t.length,t +}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var f=Function("_","return "+o)(t)}catch(l){throw l.source=o,l}return r?f(r):(f.source=o,f)},t.unescape=function(n){return null==n?"":(n+"").replace(Z,p)},t.uniqueId=function(n){var t=++Q+"";return n?n+t:t},t.all=O,t.any=D,t.detect=S,t.foldl=q,t.foldr=R,t.include=x,t.inject=q,t.first=$,t.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t!="number"&&null!=t){var o=u;for(t=W(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return Rt.call(n,Ft(0,u-e))}},t.take=$,t.head=$,t.VERSION="1.2.1",H(t),t.prototype.chain=function(){return this.__chain__=!0,this},t.prototype.value=function(){return this.__wrapped__},N("pop push reverse shift sort splice unshift".split(" "),function(n){var r=vt[n];t.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),!Mt.spliceObjects&&0===n.length&&delete n[0],this +}}),N(["concat","join","slice"],function(n){var r=vt[n];t.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new l(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=t, define(function(){return t})):J&&!J.nodeType?K?(K.exports=t)._=t:J._=t:n._=t}(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 7d8f1347a..56e968971 100644 --- a/doc/README.md +++ b/doc/README.md @@ -217,7 +217,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3507 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3523 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -241,7 +241,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3537 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3553 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -266,7 +266,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3573 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3589 "View in source") [Ⓣ][1] This method is similar to `_.find`, except that it returns the index of the element that passes the callback check, instead of the element itself. @@ -294,7 +294,7 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3643 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3659 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, elements at the beginning of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -354,7 +354,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3705 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3721 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, `array` will only be flattened a single level. If `callback` is passed, each element of `array` is passed through a `callback` before flattening. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -397,7 +397,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3749 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3765 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. @@ -429,7 +429,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -486,7 +486,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3866 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -510,7 +510,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3934 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3950 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array). @@ -567,7 +567,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3975 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3991 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -596,7 +596,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4016 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4032 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -634,7 +634,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4111 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -694,7 +694,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4159 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4175 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -743,7 +743,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4207 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -767,7 +767,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4241 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4257 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through the `callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -814,7 +814,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4279 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4296 "View in source") [Ⓣ][1] The inverse of `_.zip`, this method splits groups of elements into arrays composed of elements from each group at their corresponding indexes. @@ -838,7 +838,7 @@ _.unzip([['moe', 30, true], ['larry', 40, false]]); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4322 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -863,7 +863,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4342 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -887,7 +887,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4364 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -978,7 +978,7 @@ _.isArray(squares.value()); ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5424 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5441 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -1008,7 +1008,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5441 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5458 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1029,7 +1029,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5458 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5475 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1060,7 +1060,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2511 "View in source") [Ⓣ][1] Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -1088,7 +1088,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2538 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2553 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1126,7 +1126,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2592 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2608 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1162,7 +1162,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2644 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2660 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1208,7 +1208,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2705 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2721 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1254,7 +1254,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2788 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1303,7 +1303,7 @@ _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2835 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1335,7 +1335,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2869 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2885 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1372,7 +1372,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2902 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2918 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1401,7 +1401,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2954 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2970 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1446,7 +1446,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3011 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3027 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1488,7 +1488,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3096 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1530,7 +1530,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3130 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3146 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1560,7 +1560,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3178 "View in source") [Ⓣ][1] Reduces a `collection` to a value which is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1598,7 +1598,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3221 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1629,7 +1629,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3281 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1672,7 +1672,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3286 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3302 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1696,7 +1696,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3319 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3335 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1726,7 +1726,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3382 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1772,7 +1772,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3422 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3438 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1809,7 +1809,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3473 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1833,7 +1833,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3489 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3505 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other. @@ -1870,7 +1870,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4387 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4404 "View in source") [Ⓣ][1] If `n` is greater than `0`, a function is created that is restricted to executing `func`, with the `this` binding and arguments of the created function, only after it is called `n` times. If `n` is less than `1`, `func` is executed immediately, without a `this` binding or additional arguments, and its result is returned. @@ -1898,7 +1898,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4437 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1929,7 +1929,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4451 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4468 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @@ -1960,7 +1960,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4497 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4514 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -2001,7 +2001,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4520 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4537 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -2028,7 +2028,7 @@ welcome('moe'); ### `_.createCallback([func=identity, thisArg, argCount=3])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4596 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name, the created callback will return the property value for a given element. If `func` is an object, the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. @@ -2082,7 +2082,7 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4655 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4672 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2115,7 +2115,7 @@ jQuery('#postbox').on('click', _.debounce(sendMail, 200, { ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4708 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4725 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -2140,7 +2140,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4751 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2167,7 +2167,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4758 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4775 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -2193,7 +2193,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4788 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4805 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2219,7 +2219,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4823 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4840 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. @@ -2246,7 +2246,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4854 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4871 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2283,7 +2283,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4887 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4904 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2315,7 +2315,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4969 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2351,7 +2351,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1252 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2389,7 +2389,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1307 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1321 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2436,7 +2436,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1432 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1446 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2482,7 +2482,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1456 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1470 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -2508,7 +2508,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1478 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1492 "View in source") [Ⓣ][1] This method is similar to `_.find`, except that it returns the key of the element that passes the callback check, instead of the element itself. @@ -2536,7 +2536,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1533 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2572,7 +2572,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1558 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2600,7 +2600,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1561 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2627,7 +2627,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1586 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1600 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2652,7 +2652,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1617 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2676,7 +2676,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1129 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2703,7 +2703,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1155 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2730,7 +2730,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1643 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2754,7 +2754,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1660 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2778,7 +2778,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1663 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1677 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2802,7 +2802,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1688 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1702 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2832,7 +2832,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1747 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1761 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -2877,7 +2877,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1942 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2915,7 +2915,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1945 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1959 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2939,7 +2939,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2022 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2974,7 +2974,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2044 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -3001,7 +3001,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2061 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3025,7 +3025,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1975 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1989 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -3055,7 +3055,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2075 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2089 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -3090,7 +3090,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2100 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2114 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3114,7 +3114,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2131 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3138,7 +3138,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3162,7 +3162,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1174 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1188 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -3186,7 +3186,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2207 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3242,7 +3242,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2302 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2316 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3273,7 +3273,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2336 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2351 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3297,7 +3297,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2374 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2389 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3328,7 +3328,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2428 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2443 "View in source") [Ⓣ][1] Transforms an `object` to an new `accumulator` object which is the result of running each of its elements through the `callback`, with each `callback` execution potentially mutating the `accumulator` object. The `callback`is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3365,7 +3365,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2461 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2476 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3396,7 +3396,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4976 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4993 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3420,7 +3420,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4994 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5011 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3445,7 +3445,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5037 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3475,7 +3475,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5049 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5066 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3495,7 +3495,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value [, radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5073 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5090 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0`, a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3522,7 +3522,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5096 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5113 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -3550,7 +3550,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5140 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5157 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey, then `undefined` is returned. @@ -3603,7 +3603,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5224 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5241 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3685,7 +3685,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5349 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5366 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3717,7 +3717,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5376 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5393 "View in source") [Ⓣ][1] The inverse of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3741,7 +3741,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5396 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5413 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3794,7 +3794,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5638 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5655 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index ba98b3342..7bc10572f 100644 --- a/lodash.js +++ b/lodash.js @@ -793,8 +793,9 @@ var bailout, index = -1, + indexOf = getIndexOf(), length = array.length, - isLarge = length >= largeArraySize, + isLarge = length >= largeArraySize && lodash.indexOf != indexOf, objCache = {}; var caches = { @@ -809,7 +810,7 @@ }; function basicContains(value) { - return basicIndexOf(array, value) > -1; + return indexOf(array, value) > -1; } function basicPush(value) { @@ -957,6 +958,19 @@ return '\\' + stringEscapes[match]; } + /** + * Gets the appropriate "indexOf" function. If the `_.indexOf` method is + * customized, this method returns the custom method, otherwise it returns + * the `basicIndexOf` function. + * + * @private + * @returns {Function} Returns the "indexOf" function. + */ + function getIndexOf(array, value, fromIndex) { + var result = (result = lodash.indexOf) == indexOf ? basicIndexOf : result; + return result; + } + /** * Checks if `value` is a DOM node in IE < 9. * @@ -2300,7 +2314,8 @@ * // => { 'name': 'moe' } */ function omit(object, callback, thisArg) { - var isFunc = typeof callback == 'function', + var indexOf = getIndexOf(), + isFunc = typeof callback == 'function', result = {}; if (isFunc) { @@ -2311,7 +2326,7 @@ forIn(object, function(value, key, object) { if (isFunc ? !callback(value, key, object) - : basicIndexOf(props, key) < 0 + : indexOf(props, key) < 0 ) { result[key] = value; } @@ -2537,6 +2552,7 @@ */ function contains(collection, target, fromIndex) { var index = -1, + indexOf = getIndexOf(), length = collection ? collection.length : 0, result = false; @@ -2544,7 +2560,7 @@ if (length && typeof length == 'number') { result = (isString(collection) ? collection.indexOf(target, fromIndex) - : basicIndexOf(collection, target, fromIndex) + : indexOf(collection, target, fromIndex) ) > -1; } else { basicEach(collection, function(value) { @@ -4240,6 +4256,7 @@ */ var uniq = overloadWrapper(function(array, isSorted, callback) { var index = -1, + indexOf = getIndexOf(), length = array ? array.length : 0, isLarge = !isSorted && length >= largeArraySize, result = [], @@ -4251,7 +4268,7 @@ if (isSorted ? !index || seen[seen.length - 1] !== computed - : (isLarge ? !seen.contains(computed) : basicIndexOf(seen, computed) < 0) + : (isLarge ? !seen.contains(computed) : indexOf(seen, computed) < 0) ) { if (callback || isLarge) { seen.push(computed); diff --git a/test/test.js b/test/test.js index d50c9ecf4..7403ed75e 100644 --- a/test/test.js +++ b/test/test.js @@ -72,6 +72,9 @@ undefined ]; + /** Used as the size when optimizations are enabled for large arrays */ + var largeArraySize = 75; + /** Used to set property descriptors */ var setDescriptor = (function() { try { @@ -1241,7 +1244,7 @@ stringObject = Object(stringLiteral), expected = [stringLiteral, stringObject]; - var array = _.times(100, function(count) { + var array = _.times(largeArraySize, function(count) { return count % 2 ? stringObject : stringLiteral; }); @@ -1354,6 +1357,68 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('custom `_.indexOf` methods'); + + (function() { + function custom(array, value, fromIndex) { + var index = (fromIndex || 0) - 1, + length = array.length; + + while (++index < length) { + var other = array[index]; + if (other === value || + (_.isObject(value) && other instanceof Foo) || + (other === 'x' && /[13]/.test(value))) { + return index; + } + } + return -1; + } + + function Foo() {} + + var array = [1, new Foo, 3, new Foo], + indexOf = _.indexOf; + + test('_.contains should work with a custom `_.indexOf` method', function() { + _.indexOf = custom; + ok(_.contains(array, new Foo)); + _.indexOf = indexOf; + }); + + test('_.difference should work with a custom `_.indexOf` method', function() { + _.indexOf = custom; + deepEqual(_.difference(array, [new Foo]), [1, 3]); + _.indexOf = indexOf; + }); + + test('_.intersection should work with a custom `_.indexOf` method', function() { + _.indexOf = custom; + deepEqual(_.intersection(array, [new Foo]), [array[1]]); + _.indexOf = indexOf; + }); + + test('_.omit should work with a custom `_.indexOf` method', function() { + _.indexOf = custom; + deepEqual(_.omit(array, ['x']), { '0': 1, '2': 3 }); + _.indexOf = indexOf; + }); + + test('_.uniq should work with a custom `_.indexOf` method', function() { + _.indexOf = custom; + deepEqual(_.uniq(array), array.slice(0, 3)); + + var largeArray = _.times(largeArraySize, function() { + return new Foo; + }); + + deepEqual(_.uniq(largeArray), [largeArray[0]]); + _.indexOf = indexOf; + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.initial'); (function() { @@ -3203,13 +3268,14 @@ test('should distinguish between numbers and numeric strings', function() { var array = [], - expected = ['2', 2, Object('2'), Object(2)]; + expected = ['2', 2, Object('2'), Object(2)], + count = Math.ceil(largeArraySize / expected.length); - _.times(50, function() { + _.times(count, function() { array.push.apply(array, expected); }); - deepEqual(_.uniq(expected), expected); + deepEqual(_.uniq(array), expected); }); _.each({