mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Make pre-compile.js avoid erroring when lodash functions are missing.
Former-commit-id: 61f56f206225e1bb0232faea5624d541bc905aa0
This commit is contained in:
@@ -126,8 +126,13 @@
|
|||||||
|
|
||||||
// minify `_.sortBy` internal properties
|
// minify `_.sortBy` internal properties
|
||||||
(function() {
|
(function() {
|
||||||
|
// exit early if `_.sortBy` is not found
|
||||||
|
var snippet = (source.match(/( +)function sortBy[\s\S]+?\n\1}/) || [])[0];
|
||||||
|
if (!snippet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var properties = ['criteria', 'value'],
|
var properties = ['criteria', 'value'],
|
||||||
snippet = source.match(/( +)function sortBy[\s\S]+?\n\1}/)[0],
|
|
||||||
result = snippet;
|
result = snippet;
|
||||||
|
|
||||||
// minify property strings
|
// minify property strings
|
||||||
@@ -140,7 +145,7 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
// minify all compilable snippets
|
// minify all compilable snippets
|
||||||
source.match(
|
var snippets = source.match(
|
||||||
RegExp([
|
RegExp([
|
||||||
// match the `iterationTemplate`
|
// match the `iterationTemplate`
|
||||||
'( +)var iteratorTemplate[\\s\\S]+?\\n\\1}',
|
'( +)var iteratorTemplate[\\s\\S]+?\\n\\1}',
|
||||||
@@ -149,10 +154,16 @@
|
|||||||
// match the the `createIterator` function
|
// match the the `createIterator` function
|
||||||
'( +)function createIterator[\\s\\S]+?\\n\\3}',
|
'( +)function createIterator[\\s\\S]+?\\n\\3}',
|
||||||
// match methods created by `createIterator` calls
|
// match methods created by `createIterator` calls
|
||||||
'createIterator\\((?:[\'{]|[a-zA-Z]+,)[\\s\\S]+?\\);\\n'
|
'createIterator\\((?:{|[a-zA-Z]+)[\\s\\S]+?\\);\\n'
|
||||||
].join('|'), 'g')
|
].join('|'), 'g')
|
||||||
)
|
);
|
||||||
.forEach(function(snippet, index) {
|
|
||||||
|
// exit early if no compilable snippets
|
||||||
|
if (!snippets) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
snippets.forEach(function(snippet, index) {
|
||||||
var isCreateIterator = /function createIterator/.test(snippet),
|
var isCreateIterator = /function createIterator/.test(snippet),
|
||||||
isIteratorTemplate = /var iteratorTemplate/.test(snippet),
|
isIteratorTemplate = /var iteratorTemplate/.test(snippet),
|
||||||
result = snippet;
|
result = snippet;
|
||||||
|
|||||||
Reference in New Issue
Block a user