Simplify _.bindAll iterator options.

Former-commit-id: e9abbcc940f333e053d1ab5c35c7f4ae2d96d381
This commit is contained in:
John-David Dalton
2012-10-14 14:51:57 -07:00
parent d6ca0199b7
commit b5f2295f37
3 changed files with 52 additions and 55 deletions

View File

@@ -434,7 +434,7 @@
'inLoop': 'if (!callback(value, index, collection)) return !result'
};
/** Reusable iterator options for `defaults` and `extend` */
/** Reusable iterator options for `bindAll`, `defaults`, and `extend` */
var extendIteratorOptions = {
'useHas': false,
'useStrict': false,
@@ -3186,22 +3186,20 @@
* jQuery('#lodash_button').on('click', buttonView.onClick);
* // => When the button is clicked, `this.label` will have the correct value
*/
var bindAll = createIterator({
'useHas': false,
'useStrict': false,
'args': 'object',
var bindAll = createIterator(extendIteratorOptions, {
'top':
'var funcs = arguments,\n' +
' index = 0,\n' +
' length = funcs.length;\n' +
'if (length > 1) {\n' +
' while (++index < length) {\n' +
' result[funcs[index]] = bind(result[funcs[index]], result)\n' +
' while (--length) {\n' +
' index = funcs[length];\n' +
' result[index] = bind(result[index], result)\n' +
' }\n' +
' return result\n' +
'}',
'inLoop':
'if (isFunction(value)) result[index] = bind(value, result)'
'if (isFunction(value)) result[index] = bind(value, result)',
'bottom': false
});
/**