From 6af46521619c8bf45b704d9592bfb3ac3b4ed4cc Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 30 Jun 2012 03:06:21 -0400 Subject: [PATCH] Optimize inlining the `iteratorTemplate` for builds. Former-commit-id: 8b7ac4622e51dbe5c0364f3c6781aa474dcfa96e --- build.js | 86 ++++++++++++++++++++++++++++++++++---------- build/pre-compile.js | 6 ++-- lodash.min.js | 54 ++++++++++++++-------------- 3 files changed, 97 insertions(+), 49 deletions(-) diff --git a/build.js b/build.js index 19223a1a9..b1dd642c7 100755 --- a/build.js +++ b/build.js @@ -185,6 +185,28 @@ 'zipObject': [] }; + /** Used to `iteratorTemplate` */ + var iteratorOptions = [ + 'args', + 'array', + 'arrayBranch', + 'beforeLoop', + 'bottom', + 'exit', + 'firstArg', + 'hasExp', + 'hasDontEnumBug', + 'inLoop', + 'init', + 'iteratedObject', + 'loopExp', + 'object', + 'objectBranch', + 'shadowed', + 'top', + 'useHas' + ]; + /** Collections of method names */ var excludeMethods, includeMethods, @@ -271,6 +293,23 @@ }, [])); } + /** + * Gets the formatted source of the given function. + * + * @private + * @param {Function} func The function to process. + * @returns {String} Returns the formatted source. + */ + function getFunctionSource(func) { + var source = (func + ''); + return source.replace(/\n(?:.*)/g, function(match, index) { + match = match.slice(1); + return ( + match == '}' && source.indexOf('}', index + 2) == -1 ? '\n ' : '\n ' + ) + match; + }); + } + /** * Gets the `_.isArguments` fallback snippet from `source`. * @@ -662,13 +701,8 @@ if (!reFunc.test(source)) { return; } - // extract and format the function's code - var code = (lodash[funcName] + '').replace(/\n(?:.*)/g, function(match) { - match = match.slice(1); - return (match == '}' ? '\n ' : '\n ') + match; - }); - - source = source.replace(reFunc, '$1' + code + ';\n'); + // extract, format, and inject the compiled function's source code + source = source.replace(reFunc, '$1' + getFunctionSource(lodash[funcName]) + ';\n'); }); source = removeIsArgumentsFallback(source); @@ -687,20 +721,34 @@ else { // inline `iteratorTemplate` template source = source.replace(/(( +)var iteratorTemplate *= *)([\s\S]+?\n\2.+?);\n/, (function() { - // extract `iteratorTemplate` code - var code = /^function[^{]+{([\s\S]+?)}$/.exec(lodash._iteratorTemplate)[1]; + var code = getFunctionSource(lodash._iteratorTemplate.source); - code = removeWhitespace(code) - // remove unnecessary code - .replace(/\|\|\{\}|,__t,__j=Array.prototype.join|function print[^}]+}|\+''/g, '') - .replace(/(\{);|;(\})/g, '$1$2') - .replace(/\(\(__t=\(([^)]+)\)\)==null\?'':__t\)/g, '$1') - // ensure escaped characters are interpreted correctly in the string literal - .replace(/\\/g, '\\\\'); + // expand properties to avoid having to use a with-statement + iteratorOptions.forEach(function(property) { + code = code.replace(RegExp('([^\\w.])\\b' + property + '\\b', 'g'), '$1obj.' + property); + }); - // add `code` to `Function()` as a string literal to avoid strict mode - // errors caused by the required with-statement - return '$1Function(\'obj\',\n$2 "' + code + '"\n$2);\n'; + // remove unnecessary code + code = code + .replace(/, *__t, *__j *= *Array.prototype.join|function print[^}]+}/g, '') + .replace(/'(?:\\n|\s)+'/g, "''") + .replace(/__p *\+= *' *';/g, '') + .replace(/(__p *\+= *)' *' *\+/g, '$1') + .replace(/\+\s*' *';/g, ';') + .replace(/';(?:\\n|\s)*} *'/g, "'}'") + .replace(/(\{) *;|; *(\})/g, '$1$2') + .replace(/\(\(__t *= *\( *([^)]+) *\)\) *== *null *\? *'' *: *__t\)/g, '$1'); + + // remove the with-statement + code = code.replace(/ *with *\([^)]+\) *{/, '\n').replace(/\s*}(\s*)return /, '$1return '); + + // minor cleanup + code = code.replace(/var __p;\s*__p/, 'var __p'); + + // remove comments, including sourceURLs + code = code.replace(/\s*\/\/.*(?:\n|$)/g, ''); + + return '$1' + code + ';\n'; }())); } diff --git a/build/pre-compile.js b/build/pre-compile.js index 91c9a3996..f9ec451c8 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -253,13 +253,13 @@ var snippets = source.match( RegExp([ // match the `iteratorTemplate` - 'var iteratorTemplate\\b[\\s\\S]+?\\);\\n', + '( +)var iteratorTemplate\\b[\\s\\S]+?\\n\\1}', // match methods created by `createIterator` calls 'createIterator\\((?:{|[a-zA-Z]+)[\\s\\S]+?\\);\\n', // match variables storing `createIterator` options - '( +)var [a-zA-Z]+IteratorOptions\\b[\\s\\S]+?\\n\\1}', + '( +)var [a-zA-Z]+IteratorOptions\\b[\\s\\S]+?\\n\\2}', // match the the `createIterator` function - '( +)function createIterator\\b[\\s\\S]+?\\n\\2}' + '( +)function createIterator\\b[\\s\\S]+?\\n\\3}' ].join('|'), 'g') ); diff --git a/lodash.min.js b/lodash.min.js index cf4ef1491..7aa10978e 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,30 +3,30 @@ Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ ;(function(e,t){"use strict";function s(e){return new o(e)}function o(e){if(e&&e._wrapped)return e;this._wrapped=e}function u(){for(var e,t,n,s=-1,o=arguments.length,u={e:"",f:"",k:"",q:"",c:{d:"",m:"++ln?1:0}function f(e,t){return I[t]}function l(e){return"\\"+U[e]}function c(e){return q[e]}function h(e,t){return function(n,r,i){return e.call(t,n,r,i)}}function p(){}function d(e,t){var n=I.length;return I[n]="'+_.escape("+t+")+'",F+n}function v(e,t){var n=I.length;return I[n]="'+((__t=("+ -t+"))==null?'':__t)+'",F+n}function m(e,t){var n=I.length;return I[n]="';"+t+";__p+='",F+n}function g(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=h(t,r));if(i===i>>>0){for(i&&s&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}var o=Ot(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function y(e,t,n){if(e)return t==r||n?e[0]:tt.call(e,0,t)}function b(e,t){var n=[];if(!e)return n;for(var r,i=-1,s=e.length;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=h(t,n));++sr&&(r=n,i=e[s]);return i}function S(e,t,n){return e?tt.call(e,t==r||n?1:t):[]}function x(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=N(n,r));for(t=n( -t);i>>1,n(e[r])>>1,e[r]w(a,r))a.push(r),s.push(e[o]);return s}function N(e,t){function n(){var u=arguments,a=t;return s||(e=t[i]),o.length&&(u=u.length?Y.apply(o,u):o),this instanceof n?(p.prototype=e.prototype,a=new p,u=e.apply(a,u),R[typeof u]&&u!==r?u:a -):e.apply(a,u)}var i,s=nt.call(e)==V;if(s){if(rt)return rt.call.apply(rt,arguments)}else i=t,t=e;var o=tt.call(arguments,2);return n}function C(e,t,s){s||(s=[]);if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&nt.call(e.isEqual)==V)return e.isEqual(t);if(t.isEqual&&nt.call(t.isEqual)==V)return t.isEqual(e);var o=nt.call(e);if(o!=nt.call(t))return i;switch(o){case K:return e==""+t;case $:return e!=+e?t!=+t:0==e?1/e==1/t:e==+ -t;case W:case X:return+e==+t;case J:return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return i;for(var u=s.length;u--;)if(s[u]==e)return n;var u=-1,a=n,f=0;s.push(e);if(o==z){if(f=e.length,a=f==t.length)for(;f--&&(a=C(e[f],t[f],s)););}else{if("constructor"in e!="constructor"in t||e.constructor!=t.constructor)return i;for(var l in e)if(Z.call(e,l)&&(f++,!(a=Z.call(t,l)&&C(e[l],t[l],s))))break;if(a){for(l in -t)if(Z.call(t,l)&&!(f--))break;a=!f}if(a&&O)for(;7>++u&&(l=j[u],!Z.call(e,l)||!!(a=Z.call(t,l)&&C(e[l],t[l],s))););}return s.pop(),a}function k(e){return e}function L(e){wt(Lt(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&et.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,A="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),O=!{valueOf -:0}.propertyIsEnumerable("valueOf"),M=0,_=e._,D=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),P=/__token__(\d+)/g,H=/[&<"']/g,B=/['\n\r\t\u2028\u2029\\]/g,j="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),F="__token__",I=[],q={"&":"&","<":"<",'"':""","'":"'"},R={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},U={"\\":"\\","'":"'","\n":"n" -,"\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},z="[object Array]",W="[object Boolean]",X="[object Date]",V="[object Function]",$="[object Number]",J="[object RegExp]",K="[object String]",Q=Array.prototype,G=Object.prototype,Y=Q.concat,Z=G.hasOwnProperty,et=Q.push,tt=Q.slice,nt=G.toString,rt=D.test(rt=tt.bind)&&/\n|Opera/.test(rt+nt.call(e.opera))&&rt,it=D.test(it=Array.isArray)&&it,st=e.isFinite,ot=D.test(ot=Object.keys)&&ot,ut=e.clearTimeout,at=e.setTimeout;s.templateSettings={escape:/<%-([\s\S]+?)%>/g -,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var ft=Function("obj","var __p;with(obj){__p='var l,v';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var o='+g+'.length;l=-1;';if(o){__p+='if(o===o>>>0){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var w=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(w&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var h='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(h&&h.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return v'}return __p" -),lt={a:"f,d,C",k:"f",q:"if(!d){d=k}else if(C)d=n(d,C)",j:"d(f[l],l,f)"},ct={k:"true",j:"if(!d(f[l],l,f))return!v"},ht={a:"r",k:"r",q:"for(var y,z=1,o=arguments.length;ze?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=N,s.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Lt(e));for(var r=t.length;nw(i,e[n],r)&&t.push(e[n]);return t},s.escape=function(e){return e==r?"":(e+"").replace(H,c)},s.every=yt,s.extend=kt,s.filter=G,s.find=bt,s.first=y,s.flatten=b,s.forEach=wt,s.forIn=ht,s.forOwn=lt,s.functions=Lt,s.groupBy=Et,s.has=function(e,t){return Z.call(e,t)},s.identity=k,s.indexOf=w,s.initial=function(e,t,n){return e?tt.call(e,0,-(t==r||n?1:t)):[]},s.intersection= -function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=tt.call(arguments,1);++rw(t,n)&&yt(s,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=xt,s.max=E,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Z.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.min=function(e,t,n) -{var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0?e.length:Ot(e).length},s.some=ct,s.sortBy=mt,s.sortedIndex=x,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var i,o,u=s.templateSettings,a=n.escape,c=n.evaluate,h=n.interpolate,n=n.variable;return a==r&&(a=u.escape),c==r&&(c=u.evaluate),h==r&&(h=u.interpolate),a&&(e=e.replace(a,d)),h&&(o=e!=(e=e.replace(h,v))),c&&(i=e!=(e=e.replace(c,m))),e="__p='"+e.replace -(B,l).replace(P,f)+"';",I.length=0,n||(n=u.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p"+(o?",__t":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+e+"return __p}",i=Function("_","return "+e)(s),t?i(t):(i.source=e,i)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=at(n,f)),s}},s.times=function(e,t,n){var r=-1 -;if(n)for(;++r>>0?tt.call(e):Mt(e)},s.union=function(){for(var e=-1,t=[],n=Y.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},s.uniq=T,s.uniqueId=function(e){var t=M++;return e?e+t:t},s.values=Mt,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nw(arguments,e[n],1)&&t.push(e[n]);return t} -,s.wrap=function(e,t){return function(){var n=[e];return arguments.length&&et.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=E(Tt(arguments,"length")),r=Array(n);++t>>0){"),t+=u.c.d+";while("+u.c.m+"){"+u.c.j+"}",u.o&&(t+="}"));if(u.o){u.c&&(t+="else{"),u.i||(t+="var w=typeof "+u.l+"=='function';"),t+=u.o.d+";for("+u.o.m+"){",u.i?(u.r&&(t+="if("+u.h+"){"),t+=u.o.j+";",u.r&&(t+="}")):(t+="if(!(w&&l=='prototype')",u.r&&(t+="&&"+u.h),t+="){"+u.o.j+"}"),t+="}";if(u.i){t+="var h="+u.l+".constructor;";for(n=0;7>n; +n++)t+="l='"+u.p[n]+"';if(","constructor"==u.p[n]&&(t+="!(h&&h.prototype==="+u.l+")&&"),t+=u.h+"){"+u.o.j+"}"}u.c&&(t+="}")}return t+=u.e+";return v",Function("c,g,i,j,k,n,s,x,A,D",'"use strict";return function('+e+"){"+t+"}")(z,a,V,Z,k,h,R,tt,K,nt)}function a(e,n){return e=e.a,n=n.a,e===t?1:n===t?-1:en?1:0}function f(e,t){return I[t]}function l(e){return"\\"+U[e]}function c(e){return q[e]}function h(e,t){return function(n,r,i){return e.call(t,n,r,i)}}function p(){}function d(e,t){var n=I +.length;return I[n]="'+_.escape("+t+")+'",F+n}function v(e,t){var n=I.length;return I[n]="'+((__t=("+t+"))==null?'':__t)+'",F+n}function m(e,t){var n=I.length;return I[n]="';"+t+";__p+='",F+n}function g(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=h(t,r));if(i===i>>>0){for(i&&s&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}var o=At(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function y(e,t,n){if(e)return t==r||n?e[0]:tt.call(e,0,t)}function b(e,t){var n= +[];if(!e)return n;for(var r,i=-1,s=e.length;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=h(t,n));++sr&&(r=n,i=e[s]);return i}function S(e,t,n){return e?tt.call +(e,t==r||n?1:t):[]}function x(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=N(n,r));for(t=n(t);i>>1,n(e[r])>>1,e[r]w(a,r))a.push(r),s.push(e[o]);return s}function N(e,t){function n(){var u=arguments,a=t;return s||(e=t[i]),o.length&&(u=u.length?Y.apply +(o,u):o),this instanceof n?(p.prototype=e.prototype,a=new p,u=e.apply(a,u),R[typeof u]&&u!==r?u:a):e.apply(a,u)}var i,s=nt.call(e)==V;if(s){if(rt)return rt.call.apply(rt,arguments)}else i=t,t=e;var o=tt.call(arguments,2);return n}function C(e,t,s){s||(s=[]);if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&nt.call(e.isEqual)==V)return e.isEqual(t);if(t.isEqual&&nt.call(t.isEqual)==V)return t.isEqual(e);var o=nt.call(e);if(o!= +nt.call(t))return i;switch(o){case K:return e==""+t;case $:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case W:case X:return+e==+t;case J:return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return i;for(var u=s.length;u--;)if(s[u]==e)return n;var u=-1,a=n,f=0;s.push(e);if(o==z){if(f=e.length,a=f==t.length)for(;f--&&(a=C(e[f],t[f],s)););}else{if("constructor"in e!="constructor"in t||e.constructor!=t.constructor)return i +;for(var l in e)if(Z.call(e,l)&&(f++,!(a=Z.call(t,l)&&C(e[l],t[l],s))))break;if(a){for(l in t)if(Z.call(t,l)&&!(f--))break;a=!f}if(a&&O)for(;7>++u&&(l=j[u],!Z.call(e,l)||!!(a=Z.call(t,l)&&C(e[l],t[l],s))););}return s.pop(),a}function k(e){return e}function L(e){bt(kt(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&et.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,A="object"==typeof exports&&exports&& +("object"==typeof global&&global&&global==global.global&&(e=global),exports),O=!{valueOf:0}.propertyIsEnumerable("valueOf"),M=0,_=e._,D=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),P=/__token__(\d+)/g,H=/[&<"']/g,B=/['\n\r\t\u2028\u2029\\]/g,j="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),F="__token__",I=[],q={"&":"&","<":"<",'"':""","'":"'"},R={"boolean" +:i,"function":n,object:n,number:i,string:i,"undefined":i},U={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},z="[object Array]",W="[object Boolean]",X="[object Date]",V="[object Function]",$="[object Number]",J="[object RegExp]",K="[object String]",Q=Array.prototype,G=Object.prototype,Y=Q.concat,Z=G.hasOwnProperty,et=Q.push,tt=Q.slice,nt=G.toString,rt=D.test(rt=tt.bind)&&/\n|Opera/.test(rt+nt.call(e.opera))&&rt,it=D.test(it=Array.isArray)&&it,st=e.isFinite,ot=D.test +(ot=Object.keys)&&ot,ut=e.clearTimeout,at=e.setTimeout;s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var ft={a:"f,d,C",k:"f",q:"if(!d){d=k}else if(C)d=n(d,C)",j:"d(f[l],l,f)"},lt={k:"true",j:"if(!d(f[l],l,f))return!v"},ct={a:"r",k:"r",q:"for(var y,z=1,o=arguments.length;ze?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=N,s.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=kt(e));for(var r=t.length;nw(i,e[n],r)&&t.push(e[n]);return t},s.escape=function(e){return e==r?"":(e+"").replace(H,c)},s.every=gt,s.extend=Ct,s.filter=G,s.find=yt,s.first=y,s.flatten=b,s.forEach=bt,s.forIn=ct,s.forOwn=ft,s.functions=kt,s.groupBy= +wt,s.has=function(e,t){return Z.call(e,t)},s.identity=k,s.indexOf=w,s.initial=function(e,t,n){return e?tt.call(e,0,-(t==r||n?1:t)):[]},s.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=tt.call(arguments,1);++rw(t,n)&>(s,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=St,s.max=E,s.memoize=function(e,t){var n= +{};return function(){var r=t?t.apply(this,arguments):arguments[0];return Z.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0?e.length:At(e).length},s.some=lt,s.sortBy=vt,s.sortedIndex=x,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var i,o,u=s.templateSettings,a=n.escape,c=n.evaluate,h=n.interpolate,n=n.variable;return a==r&&(a=u.escape),c==r&& +(c=u.evaluate),h==r&&(h=u.interpolate),a&&(e=e.replace(a,d)),h&&(o=e!=(e=e.replace(h,v))),c&&(i=e!=(e=e.replace(c,m))),e="__p='"+e.replace(B,l).replace(P,f)+"';",I.length=0,n||(n=u.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p"+(o?",__t":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+e+"return __p}",i=Function("_","return "+e)(s),t?i(t):(i.source=e,i)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function( +){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=at(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?tt.call(e):Ot(e)},s.union=function(){for(var e=-1,t=[],n=Y.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},s.uniq=T,s.uniqueId=function(e){var t=M++;return e?e+t:t},s.values= +Ot,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nw(arguments,e[n],1)&&t.push(e[n]);return t},s.wrap=function(e,t){return function(){var n=[e];return arguments.length&&et.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=E(xt(arguments,"length")),r=Array(n);++t