Reduce iteratorTemplate.

Former-commit-id: 586e08c796462e1e0ff59a14a9cde07723abd771
This commit is contained in:
John-David Dalton
2012-10-22 23:41:19 -07:00
parent 04e9e8f9d8
commit 06c2ac2724
3 changed files with 139 additions and 142 deletions

View File

@@ -313,10 +313,10 @@
// add code before the iteration branches
'<%= top %>;\n' +
// the following branch is for iterating arrays and array-like objects
// array-like iteration:
'<% if (arrayLoop) { %>' +
'var length = iteratee.length; index = -1;' +
' <% if (objectLoop) { %>\nif (typeof length == \'number\') {<% } %>' +
'var length = iteratee.length; index = -1;\n' +
'if (typeof length == \'number\') {' +
// add support for accessing string characters by index if needed
' <% if (noCharByIndex) { %>\n' +
@@ -325,17 +325,15 @@
' }' +
' <% } %>\n' +
// iterate over the array-like value
' while (++index < length) {\n' +
' value = iteratee[index];\n' +
' <%= arrayLoop %>\n' +
' }' +
' <% if (objectLoop) { %>\n}<% } %>' +
'<% } %>' +
// the following branch is for iterating an object's own/inherited properties
'<% if (objectLoop) { %>' +
' <% if (arrayLoop) { %>\nelse {' +
' }\n' +
'}\n' +
'else {' +
// object iteration:
// add support for iterating over `arguments` objects if needed
' <% } else if (noArgsEnum) { %>\n' +
' var length = iteratee.length; index = -1;\n' +
@@ -403,8 +401,7 @@
' }' +
' <% } %>' +
' <% } %>' +
' <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>' +
'<% } %>\n' +
' <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n' +
// add code to the bottom of the iteration function
'<%= bottom %>;\n' +