mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Simplify "underscore" build of _.clone.
Former-commit-id: 32975bb5966f1ded4f007eb76dcf2d4677478e7d
This commit is contained in:
19
build.js
19
build.js
@@ -826,23 +826,16 @@
|
|||||||
// remove `deep` clone functionality
|
// remove `deep` clone functionality
|
||||||
source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [
|
source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [
|
||||||
' function clone(value) {',
|
' function clone(value) {',
|
||||||
' if (value == null) {',
|
' if (value && objectTypes[typeof value]) {',
|
||||||
' return value;',
|
|
||||||
' }',
|
|
||||||
' var isObj = objectTypes[typeof value];',
|
|
||||||
' if (isObj && value.clone && isFunction(value.clone)) {',
|
|
||||||
' return value.clone(deep);',
|
|
||||||
' }',
|
|
||||||
' if (isObj) {',
|
|
||||||
' var className = toString.call(value);',
|
' var className = toString.call(value);',
|
||||||
' if (!cloneableClasses[className] || (noArgsClass && isArguments(value))) {',
|
' if (!cloneableClasses[className] || (noArgsClass && isArguments(value))) {',
|
||||||
' return value;',
|
' return value',
|
||||||
' }',
|
' }',
|
||||||
' var isArr = className == arrayClass;',
|
' return className == arrayClass',
|
||||||
|
' ? slice.call(value)',
|
||||||
|
' : extend({}, value)',
|
||||||
' }',
|
' }',
|
||||||
' return isObj',
|
' return value',
|
||||||
' ? (isArr ? slice.call(value) : extend({}, value))',
|
|
||||||
' : value;',
|
|
||||||
' }'
|
' }'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user