mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Reduce iteratorTemplate.
Former-commit-id: 586e08c796462e1e0ff59a14a9cde07723abd771
This commit is contained in:
21
lodash.js
21
lodash.js
@@ -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' +
|
||||
|
||||
Reference in New Issue
Block a user