mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +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
|
||||
source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [
|
||||
' function clone(value) {',
|
||||
' if (value == null) {',
|
||||
' return value;',
|
||||
' }',
|
||||
' var isObj = objectTypes[typeof value];',
|
||||
' if (isObj && value.clone && isFunction(value.clone)) {',
|
||||
' return value.clone(deep);',
|
||||
' }',
|
||||
' if (isObj) {',
|
||||
' if (value && objectTypes[typeof value]) {',
|
||||
' var className = toString.call(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',
|
||||
' ? (isArr ? slice.call(value) : extend({}, value))',
|
||||
' : value;',
|
||||
' return value',
|
||||
' }'
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user