mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Remove deep clone from "underscore" build and fix how invalidArgs are detected in build.js.
Former-commit-id: 5038d1541fa7d0c062e5a48004a60fb9140778d7
This commit is contained in:
64
build.js
64
build.js
@@ -66,6 +66,29 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (isUnderscore) {
|
else if (isUnderscore) {
|
||||||
|
// 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) {',
|
||||||
|
' var className = toString.call(value);',
|
||||||
|
' if (!cloneableClasses[className] || (noArgsClass && isArguments(value))) {',
|
||||||
|
' return value;',
|
||||||
|
' }',
|
||||||
|
' var isArr = className == arrayClass;',
|
||||||
|
' }',
|
||||||
|
' return isObj',
|
||||||
|
' ? (isArr ? slice.call(value) : extend({}, value))',
|
||||||
|
' : value;',
|
||||||
|
' }'
|
||||||
|
].join('\n'));
|
||||||
|
|
||||||
// remove `prototype` [[Enumerable]] fix from `iteratorTemplate`
|
// remove `prototype` [[Enumerable]] fix from `iteratorTemplate`
|
||||||
source = source
|
source = source
|
||||||
.replace(/(?: *\/\/.*\n)*\s*' *(?:<% *)?if *\(!hasDontEnumBug *(?:&&|\))[\s\S]+?<% *} *(?:%>|').+/g, '')
|
.replace(/(?: *\/\/.*\n)*\s*' *(?:<% *)?if *\(!hasDontEnumBug *(?:&&|\))[\s\S]+?<% *} *(?:%>|').+/g, '')
|
||||||
@@ -258,21 +281,21 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Used to report invalid arguments */
|
/** Used to report invalid arguments */
|
||||||
var invalidArgs = lodash.without.apply(lodash, [argv.slice(2)].concat([
|
var invalidArgs = lodash.reject(argv.slice(2), function(value) {
|
||||||
'backbone',
|
if (/^(?:category|exclude|include)=(?:.*)$/.test(value)) {
|
||||||
'csp',
|
return true;
|
||||||
'legacy',
|
}
|
||||||
'mobile',
|
return [
|
||||||
'strict',
|
'backbone',
|
||||||
'underscore',
|
'csp',
|
||||||
'category',
|
'legacy',
|
||||||
'exclude',
|
'mobile',
|
||||||
'include',
|
'strict',
|
||||||
'-h',
|
'underscore',
|
||||||
'--help',
|
'-h', '--help',
|
||||||
'-V',
|
'-V', '--version'
|
||||||
'--version'
|
].indexOf(value) > -1;
|
||||||
]));
|
});
|
||||||
|
|
||||||
/** Used to inline `iteratorTemplate` */
|
/** Used to inline `iteratorTemplate` */
|
||||||
var iteratorOptions = [
|
var iteratorOptions = [
|
||||||
@@ -1128,7 +1151,10 @@
|
|||||||
if (isRemoved(source, 'toArray')) {
|
if (isRemoved(source, 'toArray')) {
|
||||||
source = removeVar(source, 'noArraySliceOnStrings');
|
source = removeVar(source, 'noArraySliceOnStrings');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'clone', 'merge')) {
|
if (isUnderscore
|
||||||
|
? isRemoved(source, 'merge')
|
||||||
|
: isRemoved(source, 'clone', 'merge')
|
||||||
|
) {
|
||||||
source = removeFunction(source, 'isPlainObject');
|
source = removeFunction(source, 'isPlainObject');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'clone', 'isArguments', 'isEmpty', 'isEqual')) {
|
if (isRemoved(source, 'clone', 'isArguments', 'isEmpty', 'isEqual')) {
|
||||||
@@ -1149,12 +1175,12 @@
|
|||||||
if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'keys')) {
|
if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'keys')) {
|
||||||
source = removeVar(source, 'reNative');
|
source = removeVar(source, 'reNative');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'clone', 'merge')) {
|
|
||||||
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
|
|
||||||
}
|
|
||||||
if (isRemoved(source, 'createIterator', 'isEqual')) {
|
if (isRemoved(source, 'createIterator', 'isEqual')) {
|
||||||
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, '');
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, '');
|
||||||
}
|
}
|
||||||
|
if (isRemoved(source, 'createIterator', 'isPlainObject')) {
|
||||||
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
|
||||||
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'keys')) {
|
if (isRemoved(source, 'createIterator', 'keys')) {
|
||||||
source = removeVar(source, 'nativeKeys');
|
source = removeVar(source, 'nativeKeys');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user