mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Allow deep clone if requested via include or plus with the underscore build.
Former-commit-id: e86dba41f7265700330e57346a112b578873b390
This commit is contained in:
26
build.js
26
build.js
@@ -950,6 +950,9 @@
|
||||
// flag used to specify if the build should include the "use strict" directive
|
||||
var useStrict = isStrict || !(isLegacy || isMobile);
|
||||
|
||||
// flag used to specify replacing Lo-Dash's `_.clone` with Underscore's
|
||||
var useUnderscoreClone = isUnderscore;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// names of methods to include in the build
|
||||
@@ -974,6 +977,11 @@
|
||||
(result = getDependencies(optionToMethodsArray(source, value)));
|
||||
});
|
||||
|
||||
// use Lo-Dash's clone if explicitly requested
|
||||
if (result && result.indexOf('clone') > -1) {
|
||||
useUnderscoreClone = false;
|
||||
}
|
||||
|
||||
// add method names required by Backbone and Underscore builds
|
||||
if (isBackbone && !result) {
|
||||
result = getDependencies(backboneDependencies);
|
||||
@@ -1038,7 +1046,6 @@
|
||||
}
|
||||
else if (isUnderscore) {
|
||||
// update dependencies
|
||||
dependencyMap.clone = ['extend', 'isArray'];
|
||||
dependencyMap.isEqual = ['isArray', 'isFunction'];
|
||||
dependencyMap.isEmpty = ['isArray'];
|
||||
|
||||
@@ -1051,13 +1058,16 @@
|
||||
source = removeVar(source, 'largeArraySize');
|
||||
|
||||
// replace `_.clone`
|
||||
source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [
|
||||
' function clone(value) {',
|
||||
' return value && objectTypes[typeof value]',
|
||||
' ? (isArray(value) ? slice.call(value) : extend({}, value))',
|
||||
' : value',
|
||||
' }'
|
||||
].join('\n'));
|
||||
if (useUnderscoreClone) {
|
||||
dependencyMap.clone = ['extend', 'isArray'];
|
||||
source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [
|
||||
' function clone(value) {',
|
||||
' return value && objectTypes[typeof value]',
|
||||
' ? (isArray(value) ? slice.call(value) : extend({}, value))',
|
||||
' : value',
|
||||
' }'
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
// replace `_.difference`
|
||||
source = source.replace(/( +)function difference[\s\S]+?\n\1}/, [
|
||||
|
||||
Reference in New Issue
Block a user