mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Rename basicXYZ functions to baseXYZ, extract _.clone, _.merge, _.isEqual functions into their own baseXYZ functions, and rework createBound to flatten multiple calls.
Former-commit-id: 8efa6004d747103e9ec6507755fa6ffceb01b16f
This commit is contained in:
371
build.js
371
build.js
@@ -92,38 +92,38 @@
|
|||||||
// public functions
|
// public functions
|
||||||
'after': [],
|
'after': [],
|
||||||
'assign': ['createCallback', 'createIterator'],
|
'assign': ['createCallback', 'createIterator'],
|
||||||
'at': ['basicFlatten', 'isString'],
|
'at': ['baseFlatten', 'isString'],
|
||||||
'bind': ['createBound'],
|
'bind': ['createBound'],
|
||||||
'bindAll': ['basicFlatten', 'bind', 'functions'],
|
'bindAll': ['baseFlatten', 'bind', 'functions'],
|
||||||
'bindKey': ['createBound'],
|
'bindKey': ['createBound'],
|
||||||
'clone': ['assign', 'createCallback', 'forEach', 'forOwn', 'getArray', 'isArray', 'isObject', 'isNode', 'releaseArray', 'slice'],
|
'clone': ['baseClone', 'createCallback'],
|
||||||
'cloneDeep': ['clone'],
|
'cloneDeep': ['clone'],
|
||||||
'compact': [],
|
'compact': [],
|
||||||
'compose': [],
|
'compose': [],
|
||||||
'contains': ['basicEach', 'getIndexOf', 'isString'],
|
'contains': ['baseEach', 'getIndexOf', 'isString'],
|
||||||
'countBy': ['createCallback', 'forEach'],
|
'countBy': ['createCallback', 'forEach'],
|
||||||
'createCallback': ['identity', 'isEqual', 'isObject', 'keys'],
|
'createCallback': ['hasThis', 'identity', 'isEqual', 'isObject', 'keys'],
|
||||||
'debounce': ['isObject'],
|
'debounce': ['isObject'],
|
||||||
'defaults': ['createCallback', 'createIterator'],
|
'defaults': ['createCallback', 'createIterator'],
|
||||||
'defer': ['bind'],
|
'defer': ['bind'],
|
||||||
'delay': [],
|
'delay': [],
|
||||||
'difference': ['basicFlatten', 'cacheIndexOf', 'createCache', 'getIndexOf', 'releaseObject'],
|
'difference': ['baseFlatten', 'cacheIndexOf', 'createCache', 'getIndexOf', 'releaseObject'],
|
||||||
'escape': ['escapeHtmlChar', 'keys'],
|
'escape': ['escapeHtmlChar', 'keys'],
|
||||||
'every': ['basicEach', 'createCallback', 'isArray'],
|
'every': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'filter': ['basicEach', 'createCallback', 'isArray'],
|
'filter': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'find': ['basicEach', 'createCallback', 'isArray'],
|
'find': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'findIndex': ['createCallback'],
|
'findIndex': ['createCallback'],
|
||||||
'findKey': ['createCallback', 'forOwn'],
|
'findKey': ['createCallback', 'forOwn'],
|
||||||
'first': ['createCallback', 'slice'],
|
'first': ['createCallback', 'slice'],
|
||||||
'flatten': ['basicFlatten', 'map'],
|
'flatten': ['baseFlatten', 'map'],
|
||||||
'forEach': ['basicEach', 'createCallback', 'isArray'],
|
'forEach': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'forIn': ['createIterator'],
|
'forIn': ['createIterator'],
|
||||||
'forOwn': ['createIterator'],
|
'forOwn': ['createIterator'],
|
||||||
'functions': ['forIn', 'isFunction'],
|
'functions': ['forIn', 'isFunction'],
|
||||||
'groupBy': ['createCallback', 'forEach'],
|
'groupBy': ['createCallback', 'forEach'],
|
||||||
'has': [],
|
'has': [],
|
||||||
'identity': [],
|
'identity': [],
|
||||||
'indexOf': ['basicIndexOf', 'sortedIndex'],
|
'indexOf': ['baseIndexOf', 'sortedIndex'],
|
||||||
'initial': ['createCallback', 'slice'],
|
'initial': ['createCallback', 'slice'],
|
||||||
'intersection': ['cacheIndexOf', 'createCache', 'getArray', 'getIndexOf', 'releaseArray', 'releaseObject'],
|
'intersection': ['cacheIndexOf', 'createCache', 'getArray', 'getIndexOf', 'releaseArray', 'releaseObject'],
|
||||||
'invert': ['keys'],
|
'invert': ['keys'],
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
'isDate': [],
|
'isDate': [],
|
||||||
'isElement': [],
|
'isElement': [],
|
||||||
'isEmpty': ['forOwn', 'isArguments', 'isFunction'],
|
'isEmpty': ['forOwn', 'isArguments', 'isFunction'],
|
||||||
'isEqual': ['createCallback', 'forIn', 'getArray', 'isArguments', 'isFunction', 'isNode', 'releaseArray'],
|
'isEqual': ['baseIsEqual', 'createCallback'],
|
||||||
'isFinite': [],
|
'isFinite': [],
|
||||||
'isFunction': [],
|
'isFunction': [],
|
||||||
'isNaN': ['isNumber'],
|
'isNaN': ['isNumber'],
|
||||||
@@ -148,24 +148,24 @@
|
|||||||
'keys': ['isArguments', 'isObject', 'shimKeys'],
|
'keys': ['isArguments', 'isObject', 'shimKeys'],
|
||||||
'last': ['createCallback', 'slice'],
|
'last': ['createCallback', 'slice'],
|
||||||
'lastIndexOf': [],
|
'lastIndexOf': [],
|
||||||
'map': ['basicEach', 'createCallback', 'isArray'],
|
'map': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'max': ['basicEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'],
|
'max': ['baseEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'],
|
||||||
'memoize': [],
|
'memoize': [],
|
||||||
'merge': ['createCallback', 'forEach', 'forOwn', 'getArray', 'isArray', 'isObject', 'isPlainObject', 'releaseArray'],
|
'merge': ['baseMerge', 'createCallback', 'getArray', 'releaseArray'],
|
||||||
'min': ['basicEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'],
|
'min': ['baseEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'],
|
||||||
'mixin': ['forEach', 'functions', 'isFunction'],
|
'mixin': ['forEach', 'functions', 'isFunction'],
|
||||||
'noConflict': [],
|
'noConflict': [],
|
||||||
'omit': ['basicFlatten', 'createCallback', 'forIn', 'getIndexOf'],
|
'omit': ['baseFlatten', 'createCallback', 'forIn', 'getIndexOf'],
|
||||||
'once': [],
|
'once': [],
|
||||||
'pairs': ['keys'],
|
'pairs': ['keys'],
|
||||||
'parseInt': ['isString'],
|
'parseInt': ['isString'],
|
||||||
'partial': ['createBound'],
|
'partial': ['createBound'],
|
||||||
'partialRight': ['createBound'],
|
'partialRight': ['createBound'],
|
||||||
'pick': ['basicFlatten', 'createCallback', 'forIn', 'isObject'],
|
'pick': ['baseFlatten', 'createCallback', 'forIn', 'isObject'],
|
||||||
'pluck': ['map'],
|
'pluck': ['map'],
|
||||||
'random': [],
|
'random': [],
|
||||||
'range': [],
|
'range': [],
|
||||||
'reduce': ['basicEach', 'createCallback', 'isArray'],
|
'reduce': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'reduceRight': ['createCallback', 'forEach', 'isString', 'keys'],
|
'reduceRight': ['createCallback', 'forEach', 'isString', 'keys'],
|
||||||
'reject': ['createCallback', 'filter'],
|
'reject': ['createCallback', 'filter'],
|
||||||
'rest': ['createCallback', 'slice'],
|
'rest': ['createCallback', 'slice'],
|
||||||
@@ -173,7 +173,7 @@
|
|||||||
'runInContext': ['defaults', 'pick'],
|
'runInContext': ['defaults', 'pick'],
|
||||||
'shuffle': ['forEach'],
|
'shuffle': ['forEach'],
|
||||||
'size': ['keys'],
|
'size': ['keys'],
|
||||||
'some': ['basicEach', 'createCallback', 'isArray'],
|
'some': ['baseEach', 'createCallback', 'isArray'],
|
||||||
'sortBy': ['compareAscending', 'createCallback', 'forEach', 'getObject', 'releaseObject'],
|
'sortBy': ['compareAscending', 'createCallback', 'forEach', 'getObject', 'releaseObject'],
|
||||||
'sortedIndex': ['createCallback', 'identity'],
|
'sortedIndex': ['createCallback', 'identity'],
|
||||||
'tap': ['value'],
|
'tap': ['value'],
|
||||||
@@ -183,10 +183,10 @@
|
|||||||
'toArray': ['isString', 'slice', 'values'],
|
'toArray': ['isString', 'slice', 'values'],
|
||||||
'transform': ['createCallback', 'createObject', 'forOwn', 'isArray'],
|
'transform': ['createCallback', 'createObject', 'forOwn', 'isArray'],
|
||||||
'unescape': ['keys', 'unescapeHtmlChar'],
|
'unescape': ['keys', 'unescapeHtmlChar'],
|
||||||
'union': ['basicFlatten', 'basicUniq'],
|
'union': ['baseFlatten', 'baseUniq'],
|
||||||
'uniq': ['basicUniq', 'createCallback'],
|
'uniq': ['baseUniq', 'createCallback'],
|
||||||
'uniqueId': [],
|
'uniqueId': [],
|
||||||
'value': ['basicEach', 'forOwn', 'isArray', 'lodash', 'mixin', 'wrapperValueOf', 'lodashWrapper'],
|
'value': ['baseEach', 'forOwn', 'isArray', 'lodash', 'mixin', 'wrapperValueOf', 'lodashWrapper'],
|
||||||
'values': ['keys'],
|
'values': ['keys'],
|
||||||
'where': ['filter'],
|
'where': ['filter'],
|
||||||
'without': ['difference'],
|
'without': ['difference'],
|
||||||
@@ -195,23 +195,27 @@
|
|||||||
'zipObject': [],
|
'zipObject': [],
|
||||||
|
|
||||||
// private functions
|
// private functions
|
||||||
'basicEach': ['createIterator'],
|
'baseClone': ['assign', 'forEach', 'forOwn', 'getArray', 'isArray', 'isObject', 'isNode', 'releaseArray', 'slice'],
|
||||||
'basicFlatten': ['isArguments', 'isArray'],
|
'baseEach': ['createIterator'],
|
||||||
'basicIndexOf': [],
|
'baseFlatten': ['isArguments', 'isArray'],
|
||||||
'basicUniq': ['cacheIndexOf', 'createCache', 'getArray', 'getIndexOf', 'releaseArray', 'releaseObject'],
|
'baseIndexOf': [],
|
||||||
'cacheIndexOf': ['basicIndexOf'],
|
'baseIsEqual': ['forIn', 'getArray', 'isArguments', 'isFunction', 'isNode', 'releaseArray'],
|
||||||
|
'baseMerge': ['forEach', 'forOwn', 'isArray', 'isObject', 'isPlainObject'],
|
||||||
|
'baseUniq': ['cacheIndexOf', 'createCache', 'getArray', 'getIndexOf', 'releaseArray', 'releaseObject'],
|
||||||
|
'cacheIndexOf': ['baseIndexOf'],
|
||||||
'cachePush': [],
|
'cachePush': [],
|
||||||
'charAtCallback': [],
|
'charAtCallback': [],
|
||||||
'compareAscending': [],
|
'compareAscending': [],
|
||||||
'createBound': ['createObject', 'isFunction', 'isObject'],
|
'createBound': ['createObject', 'isFunction', 'isObject', 'setBindData'],
|
||||||
'createCache': ['cachePush', 'getObject', 'releaseObject'],
|
'createCache': ['cachePush', 'getObject', 'releaseObject'],
|
||||||
'createIterator': ['getObject', 'isArguments', 'isArray', 'isString', 'keys', 'iteratorTemplate', 'lodash', 'releaseObject'],
|
'createIterator': ['getObject', 'isArguments', 'isArray', 'isString', 'keys', 'iteratorTemplate', 'lodash', 'releaseObject'],
|
||||||
'createObject': [ 'isObject', 'noop'],
|
'createObject': [ 'isObject', 'noop'],
|
||||||
'escapeHtmlChar': [],
|
'escapeHtmlChar': [],
|
||||||
'escapeStringChar': [],
|
'escapeStringChar': [],
|
||||||
'getArray': [],
|
'getArray': [],
|
||||||
'getIndexOf': ['basicIndexOf', 'indexOf'],
|
'getIndexOf': ['baseIndexOf', 'indexOf'],
|
||||||
'getObject': [],
|
'getObject': [],
|
||||||
|
'hasThis': ['setBindData'],
|
||||||
'isNode': [],
|
'isNode': [],
|
||||||
'iteratorTemplate': [],
|
'iteratorTemplate': [],
|
||||||
'lodash': ['lodashWrapper'],
|
'lodash': ['lodashWrapper'],
|
||||||
@@ -219,6 +223,7 @@
|
|||||||
'noop': [],
|
'noop': [],
|
||||||
'releaseArray': [],
|
'releaseArray': [],
|
||||||
'releaseObject': [],
|
'releaseObject': [],
|
||||||
|
'setBindData': [],
|
||||||
'shimIsPlainObject': ['forIn', 'isArguments', 'isFunction', 'isNode'],
|
'shimIsPlainObject': ['forIn', 'isArguments', 'isFunction', 'isNode'],
|
||||||
'shimKeys': ['createIterator'],
|
'shimKeys': ['createIterator'],
|
||||||
'slice': [],
|
'slice': [],
|
||||||
@@ -242,6 +247,7 @@
|
|||||||
'at': ['support'],
|
'at': ['support'],
|
||||||
'bind': ['support'],
|
'bind': ['support'],
|
||||||
'clone': ['support'],
|
'clone': ['support'],
|
||||||
|
'createBound': ['support'],
|
||||||
'isArguments': ['support'],
|
'isArguments': ['support'],
|
||||||
'isEmpty': ['support'],
|
'isEmpty': ['support'],
|
||||||
'isEqual': ['support'],
|
'isEqual': ['support'],
|
||||||
@@ -256,9 +262,8 @@
|
|||||||
|
|
||||||
/** Used to track variable dependencies of identifiers */
|
/** Used to track variable dependencies of identifiers */
|
||||||
var varDependencyMap = {
|
var varDependencyMap = {
|
||||||
|
'baseIsEqual': ['objectTypes'],
|
||||||
'bind': ['reNative'],
|
'bind': ['reNative'],
|
||||||
'bindKey': ['indicatorObject'],
|
|
||||||
'createCallback': ['indicatorObject'],
|
|
||||||
'createIterator': ['indicatorObject', 'objectTypes'],
|
'createIterator': ['indicatorObject', 'objectTypes'],
|
||||||
'createObject': ['reNative'],
|
'createObject': ['reNative'],
|
||||||
'defer': ['objectTypes', 'reNative'],
|
'defer': ['objectTypes', 'reNative'],
|
||||||
@@ -266,13 +271,10 @@
|
|||||||
'escapeHtmlChar': ['htmlEscapes'],
|
'escapeHtmlChar': ['htmlEscapes'],
|
||||||
'htmlUnescapes': ['htmlEscapes'],
|
'htmlUnescapes': ['htmlEscapes'],
|
||||||
'isArray': ['reNative'],
|
'isArray': ['reNative'],
|
||||||
'isEqual': ['indicatorObject', 'objectTypes'],
|
|
||||||
'isObject': ['objectTypes'],
|
'isObject': ['objectTypes'],
|
||||||
'isPlainObject': ['reNative'],
|
'isPlainObject': ['reNative'],
|
||||||
'isRegExp': ['objectTypes'],
|
'isRegExp': ['objectTypes'],
|
||||||
'keys': ['reNative'],
|
'keys': ['reNative'],
|
||||||
'merge': ['indicatorObject'],
|
|
||||||
'partialRight': ['indicatorObject'],
|
|
||||||
'reEscapedHtml': ['htmlUnescapes'],
|
'reEscapedHtml': ['htmlUnescapes'],
|
||||||
'reUnescapedHtml': ['htmlEscapes'],
|
'reUnescapedHtml': ['htmlEscapes'],
|
||||||
'support': ['reNative'],
|
'support': ['reNative'],
|
||||||
@@ -519,10 +521,13 @@
|
|||||||
|
|
||||||
/** List of private functions */
|
/** List of private functions */
|
||||||
var privateFuncs = [
|
var privateFuncs = [
|
||||||
'basicEach',
|
'baseClone',
|
||||||
'basicFlatten',
|
'baseEach',
|
||||||
'basicIndex',
|
'baseFlatten',
|
||||||
'basicUniq',
|
'baseIndexOf',
|
||||||
|
'baseIsEqual',
|
||||||
|
'baseMerge',
|
||||||
|
'baseUniq',
|
||||||
'cacheIndexOf',
|
'cacheIndexOf',
|
||||||
'cachePush',
|
'cachePush',
|
||||||
'charAtCallback',
|
'charAtCallback',
|
||||||
@@ -534,6 +539,7 @@
|
|||||||
'escapeStringChar',
|
'escapeStringChar',
|
||||||
'getArray',
|
'getArray',
|
||||||
'getObject',
|
'getObject',
|
||||||
|
'hasThis',
|
||||||
'isNode',
|
'isNode',
|
||||||
'iteratorTemplate',
|
'iteratorTemplate',
|
||||||
'lodash',
|
'lodash',
|
||||||
@@ -541,6 +547,7 @@
|
|||||||
'noop',
|
'noop',
|
||||||
'releaseArray',
|
'releaseArray',
|
||||||
'releaseObject',
|
'releaseObject',
|
||||||
|
'setBindData',
|
||||||
'shimIsPlainObject',
|
'shimIsPlainObject',
|
||||||
'shimKeys',
|
'shimKeys',
|
||||||
'slice',
|
'slice',
|
||||||
@@ -716,7 +723,7 @@
|
|||||||
].join('\n'));
|
].join('\n'));
|
||||||
|
|
||||||
// replace wrapper `Array` method assignments
|
// replace wrapper `Array` method assignments
|
||||||
source = source.replace(/^(?:(?: *\/\/.*\n)*(?: *if *\(.+\n)?( *)(basicEach|forEach)\(\['[\s\S]+?\n\1}\);(?:\n *})?\n+)+/m, function(match, indent, methodName) {
|
source = source.replace(/^(?:(?: *\/\/.*\n)*(?: *if *\(.+\n)?( *)(baseEach|forEach)\(\['[\s\S]+?\n\1}\);(?:\n *})?\n+)+/m, function(match, indent, methodName) {
|
||||||
return indent + [
|
return indent + [
|
||||||
'// add `Array` mutator functions to the wrapper',
|
'// add `Array` mutator functions to the wrapper',
|
||||||
methodName + "(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {",
|
methodName + "(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {",
|
||||||
@@ -1360,18 +1367,6 @@
|
|||||||
return result ? result[0] : '';
|
return result ? result[0] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the `hasThis` fork from `source`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {String} source The source to inspect.
|
|
||||||
* @returns {String} Returns the `isFunction` fork.
|
|
||||||
*/
|
|
||||||
function getHasThisFork(source) {
|
|
||||||
var result = source.match(/(?:\s*\/\/.*)*\n( *)if *\(!defineProperty\s*\|\|\s*!reThis\)[\s\S]+?\n\1}/);
|
|
||||||
return result ? result[0] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Lo-Dash method assignments snippet from `source`.
|
* Gets the Lo-Dash method assignments snippet from `source`.
|
||||||
*
|
*
|
||||||
@@ -1635,6 +1630,30 @@
|
|||||||
return source.replace(getDeferFork(source), '');
|
return source.replace(getDeferFork(source), '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes ES5 specific optimizations from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to process.
|
||||||
|
* @returns {String} Returns the modified source.
|
||||||
|
*/
|
||||||
|
function removeEsOptimization(source) {
|
||||||
|
// remove `__bindData` logic and `setBindData` function calls from `createBound`
|
||||||
|
source = source.replace(matchFunction(source, 'createBound'), function(match) {
|
||||||
|
return match
|
||||||
|
.replace(/\bargs *=.+?__bindData__.+\s+/, '')
|
||||||
|
.replace(/^( *)if *\(args\)[\s\S]+?\n\1}/m, '')
|
||||||
|
.replace(/^.+?setBindData.+\n/m, '')
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove `hasThis` use `_.createCallback`
|
||||||
|
source = source.replace(matchFunction(source, 'createCallback'), function(match) {
|
||||||
|
return match.replace(/\s*\|\|\s*!hasThis\(.+?\)/, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all references to `identifier` from `createIterator` in `source`.
|
* Removes all references to `identifier` from `createIterator` in `source`.
|
||||||
*
|
*
|
||||||
@@ -1756,8 +1775,8 @@
|
|||||||
function removeGetIndexOf(source) {
|
function removeGetIndexOf(source) {
|
||||||
source = removeFunction(source, 'getIndexOf');
|
source = removeFunction(source, 'getIndexOf');
|
||||||
|
|
||||||
// replace all `getIndexOf` calls with `basicIndexOf`
|
// replace all `getIndexOf` calls with `baseIndexOf`
|
||||||
source = source.replace(/\bgetIndexOf\(\)/g, 'basicIndexOf');
|
source = source.replace(/\bgetIndexOf\(\)/g, 'baseIndexOf');
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
@@ -1795,35 +1814,6 @@
|
|||||||
return source.replace(getIsFunctionFork(source), '');
|
return source.replace(getIsFunctionFork(source), '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes `hasThis` and its binding optimizations from `source`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {String} source The source to process.
|
|
||||||
* @returns {String} Returns the modified source.
|
|
||||||
*/
|
|
||||||
function removeHasThis(source) {
|
|
||||||
source = removeFunction(source, 'hasThis');
|
|
||||||
|
|
||||||
// remove `hasThis` use `_.createCallback`
|
|
||||||
source = source.replace(matchFunction(source, 'createCallback'), function(match) {
|
|
||||||
return match.replace(/\s*\|\|\s*!hasThis\(.+?\)/, '');
|
|
||||||
});
|
|
||||||
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the `hasThis` fork from `source`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {String} source The source to process.
|
|
||||||
* @returns {String} Returns the modified source.
|
|
||||||
*/
|
|
||||||
function removeHasThisFork(source) {
|
|
||||||
return source.replace(getHasThisFork(source), '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the `Object.keys` object iteration optimization from `source`.
|
* Removes the `Object.keys` object iteration optimization from `source`.
|
||||||
*
|
*
|
||||||
@@ -2014,8 +2004,8 @@
|
|||||||
function removeSupportArgsObject(source) {
|
function removeSupportArgsObject(source) {
|
||||||
source = removeSupportProp(source, 'argsObject');
|
source = removeSupportProp(source, 'argsObject');
|
||||||
|
|
||||||
// remove `argsAreObjects` from `_.isEqual`
|
// remove `argsAreObjects` from `baseIsEqual`
|
||||||
source = source.replace(matchFunction(source, 'isEqual'), function(match) {
|
source = source.replace(matchFunction(source, 'baseIsEqual'), function(match) {
|
||||||
return match.replace(/!support.\argsObject[^:]+:\s*/g, '');
|
return match.replace(/!support.\argsObject[^:]+:\s*/g, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2079,15 +2069,15 @@
|
|||||||
function removeSupportNodeClass(source) {
|
function removeSupportNodeClass(source) {
|
||||||
source = removeSupportProp(source, 'nodeClass');
|
source = removeSupportProp(source, 'nodeClass');
|
||||||
|
|
||||||
// remove `support.nodeClass` from `_.clone` and `shimIsPlainObject`
|
// remove `support.nodeClass` from `baseClone` and `shimIsPlainObject`
|
||||||
_.each(['clone', 'shimIsPlainObject'], function(funcName) {
|
_.each(['baseClone', 'shimIsPlainObject'], function(funcName) {
|
||||||
source = source.replace(matchFunction(source, funcName), function(match) {
|
source = source.replace(matchFunction(source, funcName), function(match) {
|
||||||
return match.replace(/\s*\|\|\s*\(!support\.nodeClass[\s\S]+?\)\)/, '');
|
return match.replace(/\s*\|\|\s*\(!support\.nodeClass[\s\S]+?\)\)/, '');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove `support.nodeClass` from `_.isEqual`
|
// remove `support.nodeClass` from `baseIsEqual`
|
||||||
source = source.replace(matchFunction(source, 'isEqual'), function(match) {
|
source = source.replace(matchFunction(source, 'baseIsEqual'), function(match) {
|
||||||
return match.replace(/\s*\|\|\s*\(!support\.nodeClass[\s\S]+?\)\)\)/, '');
|
return match.replace(/\s*\|\|\s*\(!support\.nodeClass[\s\S]+?\)\)\)/, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2734,19 +2724,23 @@
|
|||||||
else if (isModularize) {
|
else if (isModularize) {
|
||||||
_.forOwn(funcDependencyMap, function(deps, funcName) {
|
_.forOwn(funcDependencyMap, function(deps, funcName) {
|
||||||
if (_.contains(deps, 'getIndexOf')) {
|
if (_.contains(deps, 'getIndexOf')) {
|
||||||
(deps = funcDependencyMap[funcName] = _.without(deps, 'getIndexOf')).push( 'basicIndexOf');
|
(deps = funcDependencyMap[funcName] = _.without(deps, 'getIndexOf')).push( 'baseIndexOf');
|
||||||
}
|
}
|
||||||
if (_.contains(deps, 'lodash') || _.contains(deps, 'lodashWrapper')) {
|
if (_.contains(deps, 'lodash') || _.contains(deps, 'lodashWrapper')) {
|
||||||
funcDependencyMap[funcName] = _.without(deps, 'lodash', 'lodashWrapper');
|
funcDependencyMap[funcName] = _.without(deps, 'lodash', 'lodashWrapper');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isLegacy || isMobile || isUnderscore) {
|
||||||
|
funcDependencyMap.createBound = _.without(funcDependencyMap.createBound, 'setBindData');
|
||||||
|
funcDependencyMap.createCallback = _.without(funcDependencyMap.createCallback, 'hasThis');
|
||||||
|
}
|
||||||
if (_.contains(plusFuncs, 'chain') == !isUnderscore) {
|
if (_.contains(plusFuncs, 'chain') == !isUnderscore) {
|
||||||
funcDependencyMap.mixin = _.without(funcDependencyMap.mixin, 'isFunction');
|
funcDependencyMap.mixin = _.without(funcDependencyMap.mixin, 'isFunction');
|
||||||
}
|
}
|
||||||
if (isUnderscore) {
|
if (isUnderscore) {
|
||||||
if (!isLodash('clone') && !isLodash('cloneDeep')) {
|
if (!isLodash('baseClone') && !isLodash('clone') && !isLodash('cloneDeep')) {
|
||||||
funcDependencyMap.clone = _.without(funcDependencyMap.clone, 'forEach', 'forOwn');
|
(funcDependencyMap.clone = _.without(funcDependencyMap.clone, 'baseClone')).push('assign', 'isArray', 'isObject');
|
||||||
}
|
}
|
||||||
if (!isLodash('contains')) {
|
if (!isLodash('contains')) {
|
||||||
funcDependencyMap.contains = _.without(funcDependencyMap.contains, 'isString');
|
funcDependencyMap.contains = _.without(funcDependencyMap.contains, 'isString');
|
||||||
@@ -2757,8 +2751,8 @@
|
|||||||
if (!isLodash('isEmpty')) {
|
if (!isLodash('isEmpty')) {
|
||||||
funcDependencyMap.isEmpty = ['isArray', 'isString'];
|
funcDependencyMap.isEmpty = ['isArray', 'isString'];
|
||||||
}
|
}
|
||||||
if (!isLodash('isEqual')) {
|
if (!isLodash('baseIsEqual') && !isLodash('isEqual')) {
|
||||||
funcDependencyMap.isEqual = _.without(funcDependencyMap.isEqual, 'forIn', 'isArguments');
|
funcDependencyMap.baseIsEqual = _.without(funcDependencyMap.baseIsEqual, 'forIn', 'isArguments');
|
||||||
}
|
}
|
||||||
if (!isLodash('pick')){
|
if (!isLodash('pick')){
|
||||||
funcDependencyMap.pick = _.without(funcDependencyMap.pick, 'forIn', 'isObject');
|
funcDependencyMap.pick = _.without(funcDependencyMap.pick, 'forIn', 'isObject');
|
||||||
@@ -2770,7 +2764,7 @@
|
|||||||
funcDependencyMap.toArray.push('isArray', 'map');
|
funcDependencyMap.toArray.push('isArray', 'map');
|
||||||
}
|
}
|
||||||
if (!isLodash('where')) {
|
if (!isLodash('where')) {
|
||||||
funcDependencyMap.createCallback = _.without(funcDependencyMap.createCallback, 'isEqual');
|
funcDependencyMap.createCallback = _.without(funcDependencyMap.createCallback, 'baseIsEqual');
|
||||||
funcDependencyMap.where.push('find', 'isEmpty');
|
funcDependencyMap.where.push('find', 'isEmpty');
|
||||||
}
|
}
|
||||||
if (!isLodash('forOwn')) {
|
if (!isLodash('forOwn')) {
|
||||||
@@ -2779,28 +2773,35 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!isLodash('forIn')) {
|
if (!isLodash('forIn')) {
|
||||||
_.each(['isEqual', 'shimIsPlainObject'], function(funcName) {
|
_.each(['baseIsEqual', 'shimIsPlainObject'], function(funcName) {
|
||||||
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
|
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_.each(['basicUniq', 'difference', 'intersection'], function(funcName) {
|
_.each(['baseUniq', 'difference', 'intersection'], function(funcName) {
|
||||||
if (!isLodash(funcName)) {
|
if (!isLodash(funcName)) {
|
||||||
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'cacheIndexOf', 'createCache')).push('getIndexOf');
|
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'cacheIndexOf', 'createCache')).push('getIndexOf');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(['basicEach', 'forEach', 'forIn', 'forOwn'], function(funcName) {
|
_.each(['baseEach', 'forEach', 'forIn', 'forOwn'], function(funcName) {
|
||||||
if (funcName == 'basicEach' || !isLodash(funcName)) {
|
if (funcName == 'baseEach' || !isLodash(funcName)) {
|
||||||
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
|
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(['clone', 'isEqual', 'omit', 'pick'], function(funcName) {
|
_.each(['clone', 'isEqual', 'omit', 'pick'], function(funcName) {
|
||||||
if (funcName == 'clone'
|
if (funcName == 'isEqual') {
|
||||||
? (!isLodash('clone') && !isLodash('cloneDeep'))
|
if (isLodash('baseIsEqual') || isLodash('isEqual')) {
|
||||||
: !isLodash(funcName)
|
return;
|
||||||
) {
|
}
|
||||||
|
}
|
||||||
|
if (funcName == 'clone') {
|
||||||
|
if (isLodash('baseClone') || isLodash('clone') || isLodash('cloneDeep')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isLodash(funcName)) {
|
||||||
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createCallback');
|
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createCallback');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -2820,7 +2821,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (isModern || isUnderscore) {
|
if (isModern || isUnderscore) {
|
||||||
_.each(['assign', 'basicEach', 'defaults', 'forIn', 'forOwn', 'shimKeys'], function(funcName) {
|
_.each(['assign', 'baseEach', 'defaults', 'forIn', 'forOwn', 'shimKeys'], function(funcName) {
|
||||||
if (!(isUnderscore && isLodash(funcName))) {
|
if (!(isUnderscore && isLodash(funcName))) {
|
||||||
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('objectTypes');
|
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('objectTypes');
|
||||||
|
|
||||||
@@ -2864,12 +2865,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!isMobile) {
|
if (!isMobile) {
|
||||||
_.each(['clone', 'transform', 'value'], function(funcName) {
|
_.each(['baseClone', 'transform', 'value'], function(funcName) {
|
||||||
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'basicEach')).push('forEach');
|
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'baseEach')).push('forEach');
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(['contains', 'every', 'filter', 'find', 'forEach', 'map', 'max', 'min', 'reduce', 'some'], function(funcName) {
|
_.each(['contains', 'every', 'filter', 'find', 'forEach', 'map', 'max', 'min', 'reduce', 'some'], function(funcName) {
|
||||||
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'basicEach')).push('forOwn');
|
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'baseEach')).push('forOwn');
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(['every', 'find', 'filter', 'forEach', 'forIn', 'forOwn', 'map', 'reduce', 'shimKeys'], function(funcName) {
|
_.each(['every', 'find', 'filter', 'forEach', 'forIn', 'forOwn', 'map', 'reduce', 'shimKeys'], function(funcName) {
|
||||||
@@ -3008,7 +3009,6 @@
|
|||||||
}
|
}
|
||||||
if (isModern) {
|
if (isModern) {
|
||||||
source = removeIsArgumentsFork(source);
|
source = removeIsArgumentsFork(source);
|
||||||
source = removeHasThisFork(source);
|
|
||||||
source = removeSupportSpliceObjects(source);
|
source = removeSupportSpliceObjects(source);
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
@@ -3026,8 +3026,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((isLegacy || isMobile || isUnderscore) && !isLodash('createCallback')) {
|
if (isLegacy || isMobile || isUnderscore) {
|
||||||
source = removeHasThis(source);
|
source = removeEsOptimization(source);
|
||||||
}
|
}
|
||||||
if (isLegacy || isMobile || isUnderscore) {
|
if (isLegacy || isMobile || isUnderscore) {
|
||||||
if (isMobile || (!isLodash('assign') && !isLodash('defaults') && !isLodash('forIn') && !isLodash('forOwn'))) {
|
if (isMobile || (!isLodash('assign') && !isLodash('defaults') && !isLodash('forIn') && !isLodash('forOwn'))) {
|
||||||
@@ -3064,7 +3064,7 @@
|
|||||||
' }',
|
' }',
|
||||||
' }',
|
' }',
|
||||||
' } else {',
|
' } else {',
|
||||||
' basicEach(collection, callback);',
|
' baseEach(collection, callback);',
|
||||||
' }',
|
' }',
|
||||||
' return collection;',
|
' return collection;',
|
||||||
'}',
|
'}',
|
||||||
@@ -3093,7 +3093,7 @@
|
|||||||
' }',
|
' }',
|
||||||
' } else {',
|
' } else {',
|
||||||
' result = [];',
|
' result = [];',
|
||||||
' basicEach(collection, function(value, key, collection) {',
|
' baseEach(collection, function(value, key, collection) {',
|
||||||
' result[++index] = callback(value, key, collection);',
|
' result[++index] = callback(value, key, collection);',
|
||||||
' });',
|
' });',
|
||||||
' }',
|
' }',
|
||||||
@@ -3124,7 +3124,7 @@
|
|||||||
match = match.replace(/^( *)var noaccum\b/m, '$1if (!collection) return accumulator;\n$&');
|
match = match.replace(/^( *)var noaccum\b/m, '$1if (!collection) return accumulator;\n$&');
|
||||||
}
|
}
|
||||||
else if (/^(?:max|min)$/.test(funcName)) {
|
else if (/^(?:max|min)$/.test(funcName)) {
|
||||||
match = match.replace(/\bbasicEach\(/, 'forEach(');
|
match = match.replace(/\bbaseEach\(/, 'forEach(');
|
||||||
if (!isUnderscore || isLodash(funcName)) {
|
if (!isUnderscore || isLodash(funcName)) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
@@ -3175,7 +3175,7 @@
|
|||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
// replace `_.clone`
|
// replace `_.clone`
|
||||||
if (!isLodash('clone') && !isLodash('cloneDeep')) {
|
if (!isLodash('baseClone') && !isLodash('clone') && !isLodash('cloneDeep')) {
|
||||||
source = replaceFunction(source, 'clone', [
|
source = replaceFunction(source, 'clone', [
|
||||||
'function clone(value) {',
|
'function clone(value) {',
|
||||||
' return isObject(value)',
|
' return isObject(value)',
|
||||||
@@ -3194,7 +3194,7 @@
|
|||||||
" if (length && typeof length == 'number') {",
|
" if (length && typeof length == 'number') {",
|
||||||
' result = indexOf(collection, target) > -1;',
|
' result = indexOf(collection, target) > -1;',
|
||||||
' } else {',
|
' } else {',
|
||||||
' basicEach(collection, function(value) {',
|
' baseEach(collection, function(value) {',
|
||||||
' return !(result = value === target);',
|
' return !(result = value === target);',
|
||||||
' });',
|
' });',
|
||||||
' }',
|
' }',
|
||||||
@@ -3230,7 +3230,7 @@
|
|||||||
' var index = -1,',
|
' var index = -1,',
|
||||||
' indexOf = getIndexOf(),',
|
' indexOf = getIndexOf(),',
|
||||||
' length = array.length,',
|
' length = array.length,',
|
||||||
' flattened = basicFlatten(arguments, true, true, 1),',
|
' flattened = baseFlatten(arguments, true, true, 1),',
|
||||||
' result = [];',
|
' result = [];',
|
||||||
'',
|
'',
|
||||||
' while (++index < length) {',
|
' while (++index < length) {',
|
||||||
@@ -3288,7 +3288,7 @@
|
|||||||
if (!isLodash('flatten')) {
|
if (!isLodash('flatten')) {
|
||||||
source = replaceFunction(source, 'flatten', [
|
source = replaceFunction(source, 'flatten', [
|
||||||
'function flatten(array, isShallow) {',
|
'function flatten(array, isShallow) {',
|
||||||
' return basicFlatten(array, isShallow);',
|
' return baseFlatten(array, isShallow);',
|
||||||
'}'
|
'}'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
@@ -3340,9 +3340,15 @@
|
|||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
// replace `_.isEqual`
|
// replace `_.isEqual`
|
||||||
if (!isLodash('isEqual')) {
|
if (!isLodash('baseIsEqual') && !isLodash('isEqual')) {
|
||||||
source = replaceFunction(source, 'isEqual', [
|
source = replaceFunction(source, 'isEqual', [
|
||||||
'function isEqual(a, b, stackA, stackB) {',
|
'function isEqual(a, b) {',
|
||||||
|
' return baseIsEqual(a, b);',
|
||||||
|
'}'
|
||||||
|
].join('\n'));
|
||||||
|
|
||||||
|
source = replaceFunction(source, 'baseIsEqual', [
|
||||||
|
'function baseIsEqual(a, b, stackA, stackB) {',
|
||||||
' if (a === b) {',
|
' if (a === b) {',
|
||||||
' return a !== 0 || (1 / a == 1 / b);',
|
' return a !== 0 || (1 / a == 1 / b);',
|
||||||
' }',
|
' }',
|
||||||
@@ -3380,7 +3386,7 @@
|
|||||||
' var isArr = className == arrayClass;',
|
' var isArr = className == arrayClass;',
|
||||||
' if (!isArr) {',
|
' if (!isArr) {',
|
||||||
' if (a instanceof lodash || b instanceof lodash) {',
|
' if (a instanceof lodash || b instanceof lodash) {',
|
||||||
' return isEqual(a.__wrapped__ || a, b.__wrapped__ || b, stackA, stackB);',
|
' return baseIsEqual(a.__wrapped__ || a, b.__wrapped__ || b, stackA, stackB);',
|
||||||
' }',
|
' }',
|
||||||
' if (className != objectClass) {',
|
' if (className != objectClass) {',
|
||||||
' return false;',
|
' return false;',
|
||||||
@@ -3416,7 +3422,7 @@
|
|||||||
'',
|
'',
|
||||||
' if (result) {',
|
' if (result) {',
|
||||||
' while (size--) {',
|
' while (size--) {',
|
||||||
' if (!(result = isEqual(a[size], b[size], stackA, stackB))) {',
|
' if (!(result = baseIsEqual(a[size], b[size], stackA, stackB))) {',
|
||||||
' break;',
|
' break;',
|
||||||
' }',
|
' }',
|
||||||
' }',
|
' }',
|
||||||
@@ -3426,7 +3432,7 @@
|
|||||||
' forIn(b, function(value, key, b) {',
|
' forIn(b, function(value, key, b) {',
|
||||||
' if (hasOwnProperty.call(b, key)) {',
|
' if (hasOwnProperty.call(b, key)) {',
|
||||||
' size++;',
|
' size++;',
|
||||||
' return (result = hasOwnProperty.call(a, key) && isEqual(a[key], value, stackA, stackB));',
|
' return (result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, stackA, stackB));',
|
||||||
' }',
|
' }',
|
||||||
' });',
|
' });',
|
||||||
'',
|
'',
|
||||||
@@ -3460,7 +3466,7 @@
|
|||||||
source = replaceFunction(source, 'omit', [
|
source = replaceFunction(source, 'omit', [
|
||||||
'function omit(object) {',
|
'function omit(object) {',
|
||||||
' var indexOf = getIndexOf(),',
|
' var indexOf = getIndexOf(),',
|
||||||
' props = basicFlatten(arguments, true, false, 1),',
|
' props = baseFlatten(arguments, true, false, 1),',
|
||||||
' result = {};',
|
' result = {};',
|
||||||
'',
|
'',
|
||||||
' forIn(object, function(value, key) {',
|
' forIn(object, function(value, key) {',
|
||||||
@@ -3477,7 +3483,7 @@
|
|||||||
source = replaceFunction(source, 'pick', [
|
source = replaceFunction(source, 'pick', [
|
||||||
'function pick(object) {',
|
'function pick(object) {',
|
||||||
' var index = -1,',
|
' var index = -1,',
|
||||||
' props = basicFlatten(arguments, true, false, 1),',
|
' props = baseFlatten(arguments, true, false, 1),',
|
||||||
' length = props.length,',
|
' length = props.length,',
|
||||||
' result = {};',
|
' result = {};',
|
||||||
'',
|
'',
|
||||||
@@ -3637,10 +3643,10 @@
|
|||||||
'}'
|
'}'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
// replace `basicUniq`
|
// replace `baseUniq`
|
||||||
if (!isLodash('uniq')) {
|
if (!isLodash('uniq')) {
|
||||||
source = replaceFunction(source, 'basicUniq', [
|
source = replaceFunction(source, 'baseUniq', [
|
||||||
'function basicUniq(array, isSorted, callback) {',
|
'function baseUniq(array, isSorted, callback) {',
|
||||||
' var index = -1,',
|
' var index = -1,',
|
||||||
' indexOf = getIndexOf(),',
|
' indexOf = getIndexOf(),',
|
||||||
' length = array ? array.length : 0,',
|
' length = array ? array.length : 0,',
|
||||||
@@ -3689,8 +3695,8 @@
|
|||||||
return match
|
return match
|
||||||
// remove unnecessary fast path
|
// remove unnecessary fast path
|
||||||
.replace(/^(( *)var props *=.+?),[\s\S]+?\n\2}/m, '$1;')
|
.replace(/^(( *)var props *=.+?),[\s\S]+?\n\2}/m, '$1;')
|
||||||
// remove `_.isEqual` use
|
// remove `baseIsEqual` use
|
||||||
.replace(/=.+?\bisEqual\((.+?), *(.+?),.+?\)/, '= $1 === $2');
|
.replace(/=.+?\bbaseIsEqual\((.+?), *(.+?),.+?\)/, '= $1 === $2');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// replace `_.zip`
|
// replace `_.zip`
|
||||||
@@ -3720,7 +3726,7 @@
|
|||||||
// replace `slice` with `nativeSlice.call`
|
// replace `slice` with `nativeSlice.call`
|
||||||
_.each(['clone', 'first', 'initial', 'last', 'rest', 'toArray'], function(funcName) {
|
_.each(['clone', 'first', 'initial', 'last', 'rest', 'toArray'], function(funcName) {
|
||||||
if (funcName == 'clone'
|
if (funcName == 'clone'
|
||||||
? (!isLodash('clone') && !isLodash('cloneDeep'))
|
? (!isLodash('baseClone') && !isLodash('clone') && !isLodash('cloneDeep'))
|
||||||
: !isLodash(funcName)
|
: !isLodash(funcName)
|
||||||
) {
|
) {
|
||||||
source = source.replace(matchFunction(source, funcName), function(match) {
|
source = source.replace(matchFunction(source, funcName), function(match) {
|
||||||
@@ -3737,42 +3743,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove unused features from `createBound`
|
|
||||||
if (_.every(['bindKey', 'partial', 'partialRight'], function(funcName) {
|
|
||||||
return !_.contains(buildFuncs, funcName);
|
|
||||||
})) {
|
|
||||||
source = source.replace(matchFunction(source, 'createBound'), function(match) {
|
|
||||||
return match
|
|
||||||
.replace(/, *indicator[^)]*/, '')
|
|
||||||
.replace(/(function createBound\([^{]+{)[\s\S]+?(\n *)(function bound)/, function(match, part1, indent, part2) {
|
|
||||||
return [
|
|
||||||
part1,
|
|
||||||
'if (!isFunction(func)) {',
|
|
||||||
' throw new TypeError;',
|
|
||||||
'}',
|
|
||||||
part2
|
|
||||||
].join(indent);
|
|
||||||
})
|
|
||||||
.replace(/thisBinding *=[^}]+}/, 'thisBinding = thisArg;\n')
|
|
||||||
.replace(/\(args *=.+/, 'partialArgs.concat(nativeSlice.call(args))');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// add Underscore's chaining functions
|
// add Underscore's chaining functions
|
||||||
if (_.contains(plusFuncs, 'chain') == !isUnderscore) {
|
if (_.contains(plusFuncs, 'chain') == !isUnderscore) {
|
||||||
source = addUnderscoreChaining(source);
|
source = addUnderscoreChaining(source);
|
||||||
}
|
}
|
||||||
// replace `basicEach` references with `forEach` and `forOwn`
|
// replace `baseEach` references with `forEach` and `forOwn`
|
||||||
if (isUnderscore || (isModern && !isMobile)) {
|
if (isUnderscore || (isModern && !isMobile)) {
|
||||||
// replace `basicEach` with `_.forOwn` in "Collections" functions
|
// replace `baseEach` with `_.forOwn` in "Collections" functions
|
||||||
source = source.replace(/\bbasicEach(?=\(collection)/g, 'forOwn');
|
source = source.replace(/\bbaseEach(?=\(collection)/g, 'forOwn');
|
||||||
|
|
||||||
// replace `basicEach` with `_.forEach` in the rest of the functions
|
// replace `baseEach` with `_.forEach` in the rest of the functions
|
||||||
source = source.replace(/(\?\s*)basicEach(?=\s*:)/g, '$1forEach');
|
source = source.replace(/(\?\s*)baseEach(?=\s*:)/g, '$1forEach');
|
||||||
|
|
||||||
// replace `basicEach` with `_.forEach` in the function assignment snippet
|
// replace `baseEach` with `_.forEach` in the function assignment snippet
|
||||||
source = source.replace(/\bbasicEach(?=\(\[')/g, 'forEach');
|
source = source.replace(/\bbaseEach(?=\(\[')/g, 'forEach');
|
||||||
}
|
}
|
||||||
|
|
||||||
var context = vm.createContext({
|
var context = vm.createContext({
|
||||||
@@ -3871,9 +3856,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (isUnderscore) {
|
if (isUnderscore) {
|
||||||
// unexpose "exit early" feature of `basicEach`, `_.forEach`, `_.forIn`, and `_.forOwn`
|
// unexpose "exit early" feature of `baseEach`, `_.forEach`, `_.forIn`, and `_.forOwn`
|
||||||
_.each(['basicEach', 'forEach', 'forIn', 'forOwn'], function(funcName) {
|
_.each(['baseEach', 'forEach', 'forIn', 'forOwn'], function(funcName) {
|
||||||
if (funcName == 'basicEach' || !isLodash(funcName)) {
|
if (funcName == 'baseEach' || !isLodash(funcName)) {
|
||||||
source = source.replace(matchFunction(source, funcName), function(match) {
|
source = source.replace(matchFunction(source, funcName), function(match) {
|
||||||
return match.replace(/=== *false\)/g, '=== indicatorObject)');
|
return match.replace(/=== *false\)/g, '=== indicatorObject)');
|
||||||
});
|
});
|
||||||
@@ -3900,9 +3885,9 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// modify `_.isEqual` and `shimIsPlainObject` to use the private `indicatorObject`
|
// modify `baseEqual` and `shimIsPlainObject` to use the private `indicatorObject`
|
||||||
if (!isLodash('forIn')) {
|
if (!isLodash('forIn')) {
|
||||||
source = source.replace(matchFunction(source, 'isEqual'), function(match) {
|
source = source.replace(matchFunction(source, 'baseIsEqual'), function(match) {
|
||||||
return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;');
|
return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3926,9 +3911,9 @@
|
|||||||
if (!isLodash('createCallback')) {
|
if (!isLodash('createCallback')) {
|
||||||
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
|
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
|
||||||
}
|
}
|
||||||
// remove chainability from `basicEach` and `_.forEach`
|
// remove chainability from `baseEach` and `_.forEach`
|
||||||
if (!isLodash('forEach')) {
|
if (!isLodash('forEach')) {
|
||||||
_.each(['basicEach', 'forEach'], function(funcName) {
|
_.each(['baseEach', 'forEach'], function(funcName) {
|
||||||
source = source.replace(matchFunction(source, funcName), function(match) {
|
source = source.replace(matchFunction(source, funcName), function(match) {
|
||||||
return match
|
return match
|
||||||
.replace(/\n *return .+?([};\s]+)$/, '$1')
|
.replace(/\n *return .+?([};\s]+)$/, '$1')
|
||||||
@@ -4009,7 +3994,7 @@
|
|||||||
// remove all `lodash.prototype` additions
|
// remove all `lodash.prototype` additions
|
||||||
source = source
|
source = source
|
||||||
.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash,[\s\S]+?\n\1}.+/g, '')
|
.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash,[\s\S]+?\n\1}.+/g, '')
|
||||||
.replace(/(?:\s*\/\/.*)*\n( *)(?:basicEach|forEach)\(\['[\s\S]+?\n\1}.+/g, '')
|
.replace(/(?:\s*\/\/.*)*\n( *)(?:baseEach|forEach)\(\['[\s\S]+?\n\1}.+/g, '')
|
||||||
.replace(/(?:\s*\/\/.*)*\n *lodash\.prototype\.[\s\S]+?;/g, '');
|
.replace(/(?:\s*\/\/.*)*\n *lodash\.prototype\.[\s\S]+?;/g, '');
|
||||||
}
|
}
|
||||||
if (!isNoDep) {
|
if (!isNoDep) {
|
||||||
@@ -4063,6 +4048,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove functions from the build
|
||||||
|
allFuncs.forEach(function(otherName) {
|
||||||
|
if (!_.contains(buildFuncs, otherName) &&
|
||||||
|
!(otherName == 'findWhere' && !isUnderscore) &&
|
||||||
|
!(otherName == 'lodash' && !isNoDep)) {
|
||||||
|
source = removeFunction(source, otherName);
|
||||||
|
if (!isNoDep) {
|
||||||
|
source = removeFromCreateIterator(source, otherName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove forks of removed functions
|
||||||
|
_.each(['createObject', 'defer', 'isArguments', 'isArray', 'isFunction'], function(funcName) {
|
||||||
|
if (isExcluded(funcName)) {
|
||||||
|
source = eval('remove' + capitalize(funcName) + 'Fork')(source);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove unneeded property dependencies
|
||||||
|
_.each(propDependencies, function(propName) {
|
||||||
|
if (!_.contains(includeProps, propName)) {
|
||||||
|
source = removeProp(source, propName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// remove code used to resolve unneeded `support` properties
|
// remove code used to resolve unneeded `support` properties
|
||||||
source = source.replace(matchVar(source, 'support'), function(match) {
|
source = source.replace(matchVar(source, 'support'), function(match) {
|
||||||
return match.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *=[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) {
|
return match.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *=[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) {
|
||||||
@@ -4093,32 +4104,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove functions from the build
|
|
||||||
allFuncs.forEach(function(otherName) {
|
|
||||||
if (!_.contains(buildFuncs, otherName) &&
|
|
||||||
!(otherName == 'findWhere' && !isUnderscore) &&
|
|
||||||
!(otherName == 'lodash' && !isNoDep)) {
|
|
||||||
source = removeFunction(source, otherName);
|
|
||||||
if (!isNoDep) {
|
|
||||||
source = removeFromCreateIterator(source, otherName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// remove forks of removed functions
|
|
||||||
_.each(['createObject', 'defer', 'hasThis', 'isArguments', 'isArray', 'isFunction'], function(funcName) {
|
|
||||||
if (isExcluded(funcName)) {
|
|
||||||
source = eval('remove' + capitalize(funcName) + 'Fork')(source);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// remove unneeded property dependencies
|
|
||||||
_.each(propDependencies, function(propName) {
|
|
||||||
if (!_.contains(includeProps, propName)) {
|
|
||||||
source = removeProp(source, propName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// remove unused variables
|
// remove unused variables
|
||||||
(function() {
|
(function() {
|
||||||
var isShallow = isExcluded('runInContext'),
|
var isShallow = isExcluded('runInContext'),
|
||||||
|
|||||||
@@ -80,6 +80,8 @@
|
|||||||
'TypeError',
|
'TypeError',
|
||||||
'VERSION',
|
'VERSION',
|
||||||
'_',
|
'_',
|
||||||
|
'__bindData__',
|
||||||
|
'__chain__',
|
||||||
'__wrapped__',
|
'__wrapped__',
|
||||||
'after',
|
'after',
|
||||||
'all',
|
'all',
|
||||||
@@ -95,6 +97,7 @@
|
|||||||
'bindAll',
|
'bindAll',
|
||||||
'bindKey',
|
'bindKey',
|
||||||
'cache',
|
'cache',
|
||||||
|
'chain',
|
||||||
'clearTimeout',
|
'clearTimeout',
|
||||||
'clone',
|
'clone',
|
||||||
'cloneDeep',
|
'cloneDeep',
|
||||||
@@ -127,6 +130,7 @@
|
|||||||
'find',
|
'find',
|
||||||
'findIndex',
|
'findIndex',
|
||||||
'findKey',
|
'findKey',
|
||||||
|
'findWhere',
|
||||||
'first',
|
'first',
|
||||||
'flatten',
|
'flatten',
|
||||||
'foldl',
|
'foldl',
|
||||||
@@ -244,12 +248,7 @@
|
|||||||
'without',
|
'without',
|
||||||
'wrap',
|
'wrap',
|
||||||
'zip',
|
'zip',
|
||||||
'zipObject',
|
'zipObject'
|
||||||
|
|
||||||
// properties used by the `backbone` and `underscore` builds
|
|
||||||
'__chain__',
|
|
||||||
'chain',
|
|
||||||
'findWhere'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -374,8 +373,8 @@
|
|||||||
'createIterator\\((?:{|[a-zA-Z]+)[\\s\\S]*?\\);\\n',
|
'createIterator\\((?:{|[a-zA-Z]+)[\\s\\S]*?\\);\\n',
|
||||||
// match variables storing `createIterator` options
|
// match variables storing `createIterator` options
|
||||||
'^( *)var [a-zA-Z]+IteratorOptions\\b[\\s\\S]+?\\n\\2}',
|
'^( *)var [a-zA-Z]+IteratorOptions\\b[\\s\\S]+?\\n\\2}',
|
||||||
// match `basicUniq`, `cachePush`, `createCache`, `createIterator`, `getObject`, and `releaseObject` functions
|
// match `baseUniq`, `cachePush`, `createCache`, `createIterator`, `getObject`, and `releaseObject` functions
|
||||||
'^( *)(?:var|function) +(?:basicUniq|cachePush|createCache|createIterator|getObject|releaseObject)\\b[\\s\\S]+?\\n\\3}'
|
'^( *)(?:var|function) +(?:baseUniq|cachePush|createCache|createIterator|getObject|releaseObject)\\b[\\s\\S]+?\\n\\3}'
|
||||||
].join('|'), 'gm')
|
].join('|'), 'gm')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -3836,6 +3836,7 @@
|
|||||||
'after',
|
'after',
|
||||||
'bind',
|
'bind',
|
||||||
'bindAll',
|
'bindAll',
|
||||||
|
'bindKey',
|
||||||
'compose',
|
'compose',
|
||||||
'debounce',
|
'debounce',
|
||||||
'defer',
|
'defer',
|
||||||
|
|||||||
Reference in New Issue
Block a user