mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Simplify the lodash wrapper.
Former-commit-id: 389c9ca8aa8414b04f7f99caf955862a1925d42e
This commit is contained in:
37
build.js
37
build.js
@@ -1144,6 +1144,25 @@
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all `lodashWrapper` references from `source`.
|
||||
*
|
||||
* @private
|
||||
* @param {String} source The source to process.
|
||||
* @returns {String} Returns the modified source.
|
||||
*/
|
||||
function removeLodashWrapper(source) {
|
||||
source = removeFunction(source, 'lodashWrapper');
|
||||
|
||||
// remove `lodashWrapper.prototype` assignment
|
||||
source = source.replace(/(?:\s*\/\/.*)*\n *lodashWrapper\.prototype *=.+/, '');
|
||||
|
||||
// replace `new lodashWrapper` with `new lodash`
|
||||
source = source.replace(/\bnew lodashWrapper\b/g, 'new lodash');
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all `noArgsClass` references from `source`.
|
||||
*
|
||||
@@ -2017,13 +2036,9 @@
|
||||
// replace `lodash`
|
||||
source = replaceFunction(source, 'lodash', [
|
||||
'function lodash(value) {',
|
||||
' if (!(this instanceof lodash)) {',
|
||||
' return new lodash(value);',
|
||||
' }',
|
||||
' if (value instanceof lodash) {',
|
||||
' return value;',
|
||||
' }',
|
||||
' this.__wrapped__ = value;',
|
||||
' return (value instanceof lodash)',
|
||||
' ? value',
|
||||
' : new lodashWrapper(value)',
|
||||
'}'
|
||||
].join('\n'));
|
||||
|
||||
@@ -2286,7 +2301,7 @@
|
||||
if (isLegacy) {
|
||||
source = removeSetImmediate(source);
|
||||
|
||||
_.each(['isBindFast', 'isIeOpera', 'isV8', 'nativeBind', 'nativeIsArray', 'nativeCreate', 'nativeKeys', 'reNative'], function(varName) {
|
||||
_.each(['isBindFast', 'isIeOpera', 'isV8', 'nativeBind', 'nativeIsArray', 'nativeKeys', 'reNative'], function(varName) {
|
||||
source = removeVar(source, varName);
|
||||
});
|
||||
|
||||
@@ -2295,11 +2310,6 @@
|
||||
return match.replace(/(?:\s*\/\/.*)*\s*return isBindFast[^:]+:\s*/, 'return ');
|
||||
});
|
||||
|
||||
// remove native `Object.create` branch in `createObject`
|
||||
source = source.replace(matchFunction(source, 'createObject'), function(match) {
|
||||
return match.replace(/nativeCreate * \|\|\s*/, '');
|
||||
});
|
||||
|
||||
// remove native `Array.isArray` branch in `_.isArray`
|
||||
source = source.replace(matchFunction(source, 'isArray'), function(match) {
|
||||
return match.replace(/nativeIsArray * \|\|\s*/, '');
|
||||
@@ -2534,6 +2544,7 @@
|
||||
}
|
||||
if (isRemoved(source, 'value')) {
|
||||
source = removeHasObjectSpliceBug(source);
|
||||
source = removeLodashWrapper(source);
|
||||
|
||||
// simplify the `lodash` function
|
||||
source = replaceFunction(source, 'lodash', [
|
||||
|
||||
Reference in New Issue
Block a user