From 883d5917f591d687111ae12298276e8c938c317c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 13 Apr 2013 14:22:29 -0700 Subject: [PATCH] Fix build. Former-commit-id: 99b283a2f26a9f5973799ad6757bfdc57d0a0404 --- build.js | 9 ++++--- dist/lodash.underscore.js | 54 +++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build.js b/build.js index 79529345f..c1c4c7c3f 100755 --- a/build.js +++ b/build.js @@ -402,10 +402,10 @@ ].join('\n')); // replace wrapper `Array` method assignments - source = source.replace(/^(?: *\/\/.*\n)*( *)each\(\['[\s\S]+?\n\1}$/m, function(match, indent) { + source = source.replace(/^(?:(?: *\/\/.*\n)*(?: *if *\(.+\n)?( *)(each|forEach)\(\['[\s\S]+?\n\1}\);(?:\n *})?\n+)+/m, function(match, indent, funcName) { return indent + [ '// add `Array` mutator functions to the wrapper', - "each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {", + funcName + "(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {", ' var func = arrayRef[methodName];', ' lodash.prototype[methodName] = function() {', ' var value = this.__wrapped__;', @@ -421,7 +421,7 @@ '});', '', '// add `Array` accessor functions to the wrapper', - "each(['concat', 'join', 'slice'], function(methodName) {", + funcName + "(['concat', 'join', 'slice'], function(methodName) {", ' var func = arrayRef[methodName];', ' lodash.prototype[methodName] = function() {', ' var value = this.__wrapped__,', @@ -433,7 +433,8 @@ ' }', ' return result;', ' };', - '});' + '});', + '' ].join('\n' + indent); }); diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index f356df166..51202f079 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -4357,36 +4357,36 @@ lodash.prototype.chain = wrapperChain; lodash.prototype.value = wrapperValueOf; - // add `Array` mutator functions to the wrapper - forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { - var func = arrayRef[methodName]; - lodash.prototype[methodName] = function() { - var value = this.__wrapped__; - func.apply(value, arguments); + // add `Array` mutator functions to the wrapper + forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { + var func = arrayRef[methodName]; + lodash.prototype[methodName] = function() { + var value = this.__wrapped__; + func.apply(value, arguments); - // avoid array-like object bugs with `Array#shift` and `Array#splice` - // in Firefox < 10 and IE < 9 - if (!support.spliceObjects && value.length === 0) { - delete value[0]; - } - return this; - }; - }); + // avoid array-like object bugs with `Array#shift` and `Array#splice` + // in Firefox < 10 and IE < 9 + if (!support.spliceObjects && value.length === 0) { + delete value[0]; + } + return this; + }; + }); - // add `Array` accessor functions to the wrapper - forEach(['concat', 'join', 'slice'], function(methodName) { - var func = arrayRef[methodName]; - lodash.prototype[methodName] = function() { - var value = this.__wrapped__, - result = func.apply(value, arguments); + // add `Array` accessor functions to the wrapper + forEach(['concat', 'join', 'slice'], function(methodName) { + var func = arrayRef[methodName]; + lodash.prototype[methodName] = function() { + var value = this.__wrapped__, + result = func.apply(value, arguments); - if (this.__chain__) { - result = new lodashWrapper(result); - result.__chain__ = true; - } - return result; - }; - }); + if (this.__chain__) { + result = new lodashWrapper(result); + result.__chain__ = true; + } + return result; + }; + }); /*--------------------------------------------------------------------------*/