mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Add getTemplateSettings, removeTemplateSettings, and removeGetIndexOf to build.js.
Former-commit-id: c22a41e98a84b1739696776e40ba66a63f267159
This commit is contained in:
54
build.js
54
build.js
@@ -1167,6 +1167,22 @@
|
|||||||
) || methodName;
|
) || methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the `templateSettings` assignment from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to inspect.
|
||||||
|
* @returns {String} Returns the `templateSettings`.
|
||||||
|
*/
|
||||||
|
function getTemplateSettings(source) {
|
||||||
|
var result = source.match(RegExp(
|
||||||
|
multilineComment +
|
||||||
|
'( *)(?:var +|lodash\\.)templateSettings *=[\\s\\S]+?\\n\\1};\\n'
|
||||||
|
));
|
||||||
|
|
||||||
|
return result ? result[0] : '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a sorted array of all variables defined outside of Lo-Dash methods.
|
* Creates a sorted array of all variables defined outside of Lo-Dash methods.
|
||||||
*
|
*
|
||||||
@@ -1448,6 +1464,22 @@
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all references to `getIndexOf` from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to process.
|
||||||
|
* @returns {String} Returns the modified source.
|
||||||
|
*/
|
||||||
|
function removeGetIndexOf(source) {
|
||||||
|
source = removeFunction(source, 'getIndexOf');
|
||||||
|
|
||||||
|
// replace all `getIndexOf` calls with `basicEach`
|
||||||
|
source = source.replace(/\bgetIndexOf\(\)/g, 'basicEach');
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the `_.isArguments` fork from `source`.
|
* Removes the `_.isArguments` fork from `source`.
|
||||||
*
|
*
|
||||||
@@ -1889,6 +1921,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the `templateSettings` assignment from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to inspect.
|
||||||
|
* @returns {String} Returns the modified source.
|
||||||
|
*/
|
||||||
|
function removeTemplateSettings(source) {
|
||||||
|
return source.replace(getTemplateSettings(source), '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a given variable from `source`.
|
* Removes a given variable from `source`.
|
||||||
*
|
*
|
||||||
@@ -3677,9 +3720,8 @@
|
|||||||
].join('\n' + indent);
|
].join('\n' + indent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (isExcluded('template')) {
|
if (!_.contains(includeVars, 'templateSettings') && isExcluded('template')) {
|
||||||
// remove `templateSettings` assignment
|
source = removeTemplateSettings(source);
|
||||||
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, '');
|
|
||||||
}
|
}
|
||||||
if (isExcluded('value')) {
|
if (isExcluded('value')) {
|
||||||
source = removeLodashWrapper(source);
|
source = removeLodashWrapper(source);
|
||||||
@@ -3710,8 +3752,10 @@
|
|||||||
if (isNoDep) {
|
if (isNoDep) {
|
||||||
source = removeFromCreateIterator(source, 'lodash');
|
source = removeFromCreateIterator(source, 'lodash');
|
||||||
|
|
||||||
// replace `lodash.createCallback` references with `createCallback`
|
source = removeGetIndexOf(source);
|
||||||
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
|
|
||||||
|
// remove`lodash` namespace from properties
|
||||||
|
source = source.replace(/\blodash\.(\w+)\b(?!\s*=)/g, '$1');
|
||||||
|
|
||||||
// remove all horizontal rule comment separators
|
// remove all horizontal rule comment separators
|
||||||
source = source.replace(/^ *\/\*-+\*\/\n/gm, '');
|
source = source.replace(/^ *\/\*-+\*\/\n/gm, '');
|
||||||
|
|||||||
Reference in New Issue
Block a user