Cleanup the inlined iteratorTemplate.

Former-commit-id: 0964f0fda4a21a2009ebfd022e9d9c33bd78bbee
This commit is contained in:
John-David Dalton
2013-03-07 23:44:33 -08:00
parent fc39e4a225
commit 4f1d03e1d4
4 changed files with 40 additions and 40 deletions

View File

@@ -2495,9 +2495,10 @@
.replace(/function print[^}]+}/, '')
.replace(/'(?:\\n|\s)+'/g, "''")
.replace(/__p *\+= *' *';/g, '')
.replace(/\s*\+\s*'';/g, ';')
.replace(/(__p *\+= *)' *' *\+/g, '$1')
.replace(/({) *;|; *(})/g, '$1$2')
.replace(/\(\(__t *= *\( *([^)]+) *\)\) *== *null *\? *'' *: *__t\)/g, '($1)');
.replace(/(?:; *)([{}])|([{}])(?: *;)/g, '$1$2')
.replace(/\(\(__t *= *\( *([^)]+?) *\)\) *== *null *\? *'' *: *__t\)/g, '($1)');
// remove the with-statement
snippet = snippet.replace(/ *with *\(.+?\) *{/, '\n').replace(/}([^}]*}[^}]*$)/, '$1');

47
dist/lodash.compat.js vendored
View File

@@ -455,41 +455,40 @@
var iteratorTemplate = function(obj) {
var __p = 'var index, iterable = ' +
(obj.firstArg ) +
(obj.firstArg) +
', result = iterable;\nif (!iterable) return result;\n' +
(obj.top ) +
(obj.top) +
';\n';
if (obj.arrays) {
__p += 'var length = iterable.length; index = -1;\nif (' +
(obj.arrays ) +
(obj.arrays) +
') { ';
if (support.unindexedChars) {
__p += '\n if (isString(iterable)) {\n iterable = iterable.split(\'\')\n } ';
} ;
}
__p += '\n while (++index < length) {\n ' +
(obj.loop ) +
(obj.loop) +
'\n }\n}\nelse { ';
} else if (support.nonEnumArgs) {
__p += '\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += \'\';\n ' +
(obj.loop ) +
(obj.loop) +
'\n }\n } else { ';
} ;
}
if (support.enumPrototypes) {
__p += '\n var skipProto = typeof iterable == \'function\';\n ';
} ;
}
if (support.fastKeys && obj.useHas) {
__p += '\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] ? nativeKeys(iterable) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n ';
if (support.enumPrototypes) {
__p += 'if (!(skipProto && index == \'prototype\')) {\n ';
} ;
}
__p +=
(obj.loop ) +
'';
(obj.loop);
if (support.enumPrototypes) {
__p += '}\n';
} ;
}
__p += ' } ';
} else {
__p += '\n for (index in iterable) {';
@@ -501,39 +500,39 @@
__p += ' && ';
} if (obj.useHas) {
__p += 'hasOwnProperty.call(iterable, index)';
} ;
}
__p += ') { ';
} ;
}
__p +=
(obj.loop ) +
(obj.loop) +
'; ';
if (support.enumPrototypes || obj.useHas) {
__p += '\n }';
} ;
}
__p += '\n } ';
} ;
}
if (support.nonEnumShadows) {
__p += '\n\n var ctor = iterable.constructor;\n ';
for (var k = 0; k < 7; k++) {
__p += '\n index = \'' +
(obj.shadowedProps[k] ) +
(obj.shadowedProps[k]) +
'\';\n if (';
if (obj.shadowedProps[k] == 'constructor') {
__p += '!(ctor && ctor.prototype === iterable) && ';
} ;
}
__p += 'hasOwnProperty.call(iterable, index)) {\n ' +
(obj.loop ) +
(obj.loop) +
'\n } ';
} ;
}
} ;
}
if (obj.arrays || support.nonEnumArgs) {
__p += '\n}';
} ;
}
__p +=
(obj.bottom ) +
(obj.bottom) +
';\nreturn result';
return __p

View File

@@ -5,7 +5,7 @@
* Underscore.js 1.4.4 underscorejs.org/LICENSE
*/
;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&Vt.call(n,"__wrapped__")?n:new L(n)}function B(n,t,e){t||(t=0);var r=n.length,u=r-t>=(e||f);if(u){var a={};for(e=t-1;++e<r;){var o=n[e]+"";(Vt.call(a,o)?a[o]:a[o]=[]).push(n[e])}}return function(e){if(u){var r=e+"";return Vt.call(a,r)&&-1<mt(a[r],e)}return-1<mt(n,e,t)}}function F(n){return n.charCodeAt(0)}function q(n,t){var e=n.b,r=t.b;if(n=n.a,t=t.a,n!==t){if(n>t||typeof n=="undefined")return 1;if(n<t||typeof t=="undefined")return-1
}return e<r?-1:1}function R(n,t,e,r){function u(){var f=arguments,c=o?this:t;return a||(n=t[i]),e.length&&(f=f.length?(f=U(f),r?f.concat(e):e.concat(f)):e),this instanceof u?(M.prototype=n.prototype,c=new M,M.prototype=null,f=n.apply(c,f),nt(f)?f:c):n.apply(c,f)}var a=Z(n),o=!e,i=t;return o&&(e=t),a||(t=n),u}function T(){for(var n,t={f:_,b:"k(m)",c:"",e:"",g:"",h:!0},e=0;n=arguments[e];e++)for(var r in n)t[r]=n[r];if(n=t.a,t.d=/^[^,]+/.exec(n)[0],e=It,r="var i,m="+t.d+",u=m;if(!m)return u;"+t.g+";",t.b?(r+="var n=m.length;i=-1;if("+t.b+"){",ce.unindexedChars&&(r+="if(l(m)){m=m.split('')}"),r+="while(++i<n){"+t.e+"}}else{"):ce.nonEnumArgs&&(r+="var n=m.length;i=-1;if(n&&j(m)){while(++i<n){i+='';"+t.e+"}}else{"),ce.enumPrototypes&&(r+="var v=typeof m=='function';"),ce.fastKeys&&t.h?(r+="var s=-1,t=r[typeof m]?p(m):[],n=t.length;while(++s<n){i=t[s];",ce.enumPrototypes&&(r+="if(!(v&&i=='prototype')){"),r+=t.e+"",ce.enumPrototypes&&(r+="}")):(r+="for(i in m){",(ce.enumPrototypes||t.h)&&(r+="if(",ce.enumPrototypes&&(r+="!(v&&i=='prototype')"),ce.enumPrototypes&&t.h&&(r+="&&"),t.h&&(r+="h.call(m,i)"),r+="){"),r+=t.e+";",(ce.enumPrototypes||t.h)&&(r+="}")),r+="}",ce.nonEnumShadows){r+="var f=m.constructor;";
}return e<r?-1:1}function R(n,t,e,r){function u(){var f=arguments,c=o?this:t;return a||(n=t[i]),e.length&&(f=f.length?(f=U(f),r?f.concat(e):e.concat(f)):e),this instanceof u?(M.prototype=n.prototype,c=new M,M.prototype=null,f=n.apply(c,f),nt(f)?f:c):n.apply(c,f)}var a=Z(n),o=!e,i=t;return o&&(e=t),a||(t=n),u}function T(){for(var n,t={f:_,b:"k(m)",c:"",e:"",g:"",h:!0},e=0;n=arguments[e];e++)for(var r in n)t[r]=n[r];if(n=t.a,t.d=/^[^,]+/.exec(n)[0],e=It,r="var i,m="+t.d+",u=m;if(!m)return u;"+t.g+";",t.b?(r+="var n=m.length;i=-1;if("+t.b+"){",ce.unindexedChars&&(r+="if(l(m)){m=m.split('')}"),r+="while(++i<n){"+t.e+"}}else{"):ce.nonEnumArgs&&(r+="var n=m.length;i=-1;if(n&&j(m)){while(++i<n){i+='';"+t.e+"}}else{"),ce.enumPrototypes&&(r+="var v=typeof m=='function';"),ce.fastKeys&&t.h?(r+="var s=-1,t=r[typeof m]?p(m):[],n=t.length;while(++s<n){i=t[s];",ce.enumPrototypes&&(r+="if(!(v&&i=='prototype')){"),r+=t.e,ce.enumPrototypes&&(r+="}")):(r+="for(i in m){",(ce.enumPrototypes||t.h)&&(r+="if(",ce.enumPrototypes&&(r+="!(v&&i=='prototype')"),ce.enumPrototypes&&t.h&&(r+="&&"),t.h&&(r+="h.call(m,i)"),r+="){"),r+=t.e+";",(ce.enumPrototypes||t.h)&&(r+="}")),r+="}",ce.nonEnumShadows){r+="var f=m.constructor;";
for(var u=0;7>u;u++)r+="i='"+t.f[u]+"';if(","constructor"==t.f[u]&&(r+="!(f&&f.prototype===m)&&"),r+="h.call(m,i)){"+t.e+"}"}return(t.b||ce.nonEnumArgs)&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,r,p","return function("+n+"){"+r+"}")(Vt,G,ve,et,a,P,ne)}function D(n){return"\\"+N[n]}function z(n){return ye[n]}function K(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function L(n){this.__wrapped__=n}function M(){}function U(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;
e=e-t||0;for(var u=Et(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function V(n){return he[n]}function G(n){return Qt.call(n)==w}function H(n){var t=!1;if(!n||typeof n!="object"||G(n))return t;var e=n.constructor;return!Z(e)&&(ce.nodeClass||!K(n))||e instanceof e?ce.ownLast?(pe(n,function(n,e,r){return t=Vt.call(r,e),!1}),!0===t):(pe(n,function(n,e){t=e}),!1===t||Vt.call(n,t)):t}function J(n){var t=[];return se(n,function(n,e){t.push(e)}),t}function Q(n,t,r,u,o,i){var f=n;if(typeof t=="function"&&(u=r,r=t,t=!1),typeof r=="function"){if(r=typeof u=="undefined"?r:a.createCallback(r,u,1),f=r(f),typeof f!="undefined")return f;
f=n}if(u=nt(f)){var c=Qt.call(f);if(!I[c]||!ce.nodeClass&&K(f))return f;var l=ve(f)}if(!u||!t)return u?l?U(f):me({},f):f;switch(u=fe[c],c){case C:case k:return new u(+f);case O:case A:return new u(f);case S:return u(f.source,v.exec(f))}for(o||(o=[]),i||(i=[]),c=o.length;c--;)if(o[c]==n)return i[c];return f=l?u(f.length):{},l&&(Vt.call(n,"index")&&(f.index=n.index),Vt.call(n,"input")&&(f.input=n.input)),o.push(n),i.push(f),(l?ct:se)(n,function(n,u){f[u]=Q(n,t,r,e,o,i)}),f}function W(n){var t=[];return pe(n,function(n,e){Z(n)&&t.push(e)

26
dist/lodash.js vendored
View File

@@ -340,21 +340,21 @@
var iteratorTemplate = function(obj) {
var __p = 'var index, iterable = ' +
(obj.firstArg ) +
(obj.firstArg) +
', result = iterable;\nif (!iterable) return result;\n' +
(obj.top ) +
(obj.top) +
';\n';
if (obj.arrays) {
__p += 'var length = iterable.length; index = -1;\nif (' +
(obj.arrays ) +
(obj.arrays) +
') {\n while (++index < length) {\n ' +
(obj.loop ) +
(obj.loop) +
'\n }\n}\nelse { ';
} ;
}
if (support.fastKeys && obj.useHas) {
__p += '\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] ? nativeKeys(iterable) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n ' +
(obj.loop ) +
(obj.loop) +
'\n } ';
} else {
__p += '\n for (index in iterable) {';
@@ -362,23 +362,23 @@
__p += '\n if (';
if (obj.useHas) {
__p += 'hasOwnProperty.call(iterable, index)';
} ;
}
__p += ') { ';
} ;
}
__p +=
(obj.loop ) +
(obj.loop) +
'; ';
if (obj.useHas) {
__p += '\n }';
} ;
}
__p += '\n } ';
} ;
}
if (obj.arrays) {
__p += '\n}';
} ;
}
__p +=
(obj.bottom ) +
(obj.bottom) +
';\nreturn result';
return __p