mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Cleanup iteratorTemplate and remove more code from the "underscore" build.
Former-commit-id: 3f4c283f0aa205dbcce1940f7222b594284263c4
This commit is contained in:
17
build.js
17
build.js
@@ -23,8 +23,11 @@
|
||||
/** Flag used to specify a legacy build */
|
||||
var isLegacy = process.argv.indexOf('legacy') > -1;
|
||||
|
||||
/** Flag used to specify an Underscore build */
|
||||
var isUnderscore = process.argv.indexOf('underscore') > -1;
|
||||
|
||||
/** Flag used to specify a mobile build */
|
||||
var isMobile = !isLegacy && (isCSP || process.argv.indexOf('mobile') > -1);
|
||||
var isMobile = !isLegacy && (isCSP || isUnderscore || process.argv.indexOf('mobile') > -1);
|
||||
|
||||
/**
|
||||
* Flag used to specify `_.bindAll`, `_.extend`, and `_.defaults` are
|
||||
@@ -32,9 +35,6 @@
|
||||
*/
|
||||
var isStrict = process.argv.indexOf('strict') > -1;
|
||||
|
||||
/** Flag used to specify an Underscore build */
|
||||
var isUnderscore = process.argv.indexOf('underscore') > -1;
|
||||
|
||||
/** Flag used to specify if the build should include the "use strict" directive */
|
||||
var useStrict = isStrict || !(isLegacy || isMobile);
|
||||
|
||||
@@ -56,14 +56,19 @@
|
||||
source = setUseStrictOption(source, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (isLegacy) {
|
||||
source = replaceVar(source, 'noArgsClass', 'true');
|
||||
['isBindFast', 'isKeysFast', 'isStrictFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) {
|
||||
source = replaceVar(source, varName, 'false');
|
||||
});
|
||||
}
|
||||
else if (isMobile) {
|
||||
else if (isUnderscore) {
|
||||
// remove `prototype` [[Enumerable]] fix from `iteratorTemplate`
|
||||
source = source
|
||||
.replace(/(?: *\/\/.*\n)*\s*' *(?:<% *)?if *\(!hasDontEnumBug *(?:&&|\))[\s\S]+?<% *} *(?:%>|').+/g, '')
|
||||
.replace(/!hasDontEnumBug *\|\|/g, '');
|
||||
}
|
||||
if (isMobile) {
|
||||
source = replaceVar(source, 'isKeysFast', 'false');
|
||||
}
|
||||
vm.runInNewContext(source, sandbox);
|
||||
|
||||
31
lodash.js
31
lodash.js
@@ -162,7 +162,6 @@
|
||||
|
||||
function ctor() { this.x = 1; }
|
||||
ctor.prototype = { 'valueOf': 1, 'y': 1 };
|
||||
|
||||
for (var prop in new ctor) { props.push(prop); }
|
||||
for (prop in arguments) { noArgsEnum = !prop; }
|
||||
|
||||
@@ -417,6 +416,12 @@
|
||||
' } else {' +
|
||||
' <% } %>' +
|
||||
|
||||
// Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
|
||||
// (if the prototype or a property on the prototype has been set)
|
||||
// incorrectly sets a function's `prototype` property [[Enumerable]]
|
||||
// value to `true`. Because of this Lo-Dash standardizes on skipping
|
||||
// the the `prototype` property of functions regardless of its
|
||||
// [[Enumerable]] value.
|
||||
' <% if (!hasDontEnumBug) { %>\n' +
|
||||
' var skipProto = typeof iteratee == \'function\' && \n' +
|
||||
' propertyIsEnumerable.call(iteratee, \'prototype\');\n' +
|
||||
@@ -440,25 +445,15 @@
|
||||
' <% } else { %>\n' +
|
||||
' <%= objectBranch.beforeLoop %>;\n' +
|
||||
' for (index in iteratee) {' +
|
||||
' <% if (hasDontEnumBug) { %>\n' +
|
||||
' <% if (useHas) { %>if (hasOwnProperty.call(iteratee, index)) {\n <% } %>' +
|
||||
' <% if (!hasDontEnumBug || useHas) { %>\n if (<%' +
|
||||
' if (!hasDontEnumBug) { %>!(skipProto && index == \'prototype\')<% }' +
|
||||
' if (!hasDontEnumBug && useHas) { %> && <% }' +
|
||||
' if (useHas) { %>hasOwnProperty.call(iteratee, index)<% }' +
|
||||
' %>) {' +
|
||||
' <% } %>\n' +
|
||||
' value = iteratee[index];\n' +
|
||||
' <%= objectBranch.inLoop %>;\n' +
|
||||
' <% if (useHas) { %>}<% } %>' +
|
||||
|
||||
// Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
|
||||
// (if the prototype or a property on the prototype has been set)
|
||||
// incorrectly sets a function's `prototype` property [[Enumerable]]
|
||||
// value to `true`. Because of this Lo-Dash standardizes on skipping
|
||||
// the the `prototype` property of functions regardless of its
|
||||
// [[Enumerable]] value.
|
||||
' <% } else { %>\n' +
|
||||
' if (!(skipProto && index == \'prototype\')<% if (useHas) { %> &&\n' +
|
||||
' hasOwnProperty.call(iteratee, index)<% } %>) {\n' +
|
||||
' value = iteratee[index];\n' +
|
||||
' <%= objectBranch.inLoop %>\n' +
|
||||
' }' +
|
||||
' <% } %>\n' +
|
||||
' <% if (!hasDontEnumBug || useHas) { %>}\n<% } %>' +
|
||||
' }' +
|
||||
' <% } %>' +
|
||||
|
||||
|
||||
Reference in New Issue
Block a user