mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
lodash: Cleanup comments. [jddalton]
Former-commit-id: a891164706f758102f56f8a41272f2c4c1c14cc9
This commit is contained in:
18
lodash.js
18
lodash.js
@@ -245,7 +245,7 @@
|
|||||||
options = {},
|
options = {},
|
||||||
props = ['beforeLoop', 'loopExp', 'inLoop', 'afterLoop'];
|
props = ['beforeLoop', 'loopExp', 'inLoop', 'afterLoop'];
|
||||||
|
|
||||||
// use a while-loop to merge options objects because `extend` isn't defined yet
|
// use a while-loop to merge options because `extend` isn't defined yet
|
||||||
while (++index < arguments.length) {
|
while (++index < arguments.length) {
|
||||||
for (prop in arguments[index]) {
|
for (prop in arguments[index]) {
|
||||||
options[prop] = arguments[index][prop];
|
options[prop] = arguments[index][prop];
|
||||||
@@ -277,17 +277,17 @@
|
|||||||
'"use strict";' +
|
'"use strict";' +
|
||||||
// compile the arguments the function accepts
|
// compile the arguments the function accepts
|
||||||
'return function(' + args + '){\n' +
|
'return function(' + args + '){\n' +
|
||||||
// add code that goes at the top of the iteration method
|
// add code to the top of the iteration method
|
||||||
(options.top || '') + ';\n' +
|
(options.top || '') + ';\n' +
|
||||||
// assign the `result` variable an initial value
|
// assign the `result` variable an initial value
|
||||||
('var index, result' + (init ? '=' + init : '')) + ';\n' +
|
('var index, result' + (init ? '=' + init : '')) + ';\n' +
|
||||||
// if the first argument, e.g. `collection`, is nullish then exit early
|
// exit early if the first argument, e.g. `collection`, is nullish
|
||||||
'if(' + firstArg + '==undefined)return ' + (options.exits || 'result') + ';\n' +
|
'if(' + firstArg + '==undefined)return ' + (options.exits || 'result') + ';\n' +
|
||||||
// the following branch is for iterating arrays and array-like objects
|
// the following branch is for iterating arrays and array-like objects
|
||||||
(arrayBranch
|
(arrayBranch
|
||||||
// initialize `length` and `index` values
|
// initialize `length` and `index` variables
|
||||||
? 'var length=' + firstArg + '.length;\nindex=-1;\n' +
|
? 'var length=' + firstArg + '.length;\nindex=-1;\n' +
|
||||||
// check if the `collection` is array-like when also supporting object iteration
|
// check if the `collection` is array-like when there is an object iteration branch
|
||||||
((objectBranch ? 'if(length===+length){\n' : '') +
|
((objectBranch ? 'if(length===+length){\n' : '') +
|
||||||
// add code before the while-loop
|
// add code before the while-loop
|
||||||
(array.beforeLoop || '') + ';\n' +
|
(array.beforeLoop || '') + ';\n' +
|
||||||
@@ -302,15 +302,15 @@
|
|||||||
(objectBranch ? '\n}\n' : ''))
|
(objectBranch ? '\n}\n' : ''))
|
||||||
: ''
|
: ''
|
||||||
) +
|
) +
|
||||||
// the following branch is for iterating an object's own or inherited keys (configurable)
|
// the following branch is for iterating an object's own/inherited properties
|
||||||
(objectBranch
|
(objectBranch
|
||||||
// begin the else-statement when also supporting array-like iteration
|
// begin the else-statement when there is an array-like iteration branch
|
||||||
? ((arrayBranch ? 'else{\n' : '') +
|
? ((arrayBranch ? 'else{\n' : '') +
|
||||||
// add code before the for-in loop
|
// add code before the for-in loop
|
||||||
(object.beforeLoop || '') + ';\n' +
|
(object.beforeLoop || '') + ';\n' +
|
||||||
// add a custom loop expression
|
// add a custom loop expression
|
||||||
'for(' + (object.loopExp || 'index in ' + firstArg) + '){\n' +
|
'for(' + (object.loopExp || 'index in ' + firstArg) + '){\n' +
|
||||||
// when `options.useHas` is `true` compile in `hasOwnProperty` checks
|
// compile in `hasOwnProperty` checks when `options.useHas` is not `false`
|
||||||
(useHas ? 'if(hasOwnProperty.call(' + /\S+$/.exec(object.loopExp || firstArg)[0] + ',index)){\n' : '') +
|
(useHas ? 'if(hasOwnProperty.call(' + /\S+$/.exec(object.loopExp || firstArg)[0] + ',index)){\n' : '') +
|
||||||
// add code inside the for-in loop
|
// add code inside the for-in loop
|
||||||
object.inLoop +
|
object.inLoop +
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
(arrayBranch ? '\n}\n' : ''))
|
(arrayBranch ? '\n}\n' : ''))
|
||||||
: ''
|
: ''
|
||||||
) +
|
) +
|
||||||
// add code that goes at the bottom of the iteration method
|
// add code to the bottom of the iteration method
|
||||||
(options.bottom || '') + ';\n' +
|
(options.bottom || '') + ';\n' +
|
||||||
// finally, return the `result`
|
// finally, return the `result`
|
||||||
'return ' + (options.returns || 'result') +
|
'return ' + (options.returns || 'result') +
|
||||||
|
|||||||
Reference in New Issue
Block a user