mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
lodash: Add spaces to compiled / template strings. [jddalton]
Former-commit-id: e28bb94dfb8f315f62dd942765752739f30950dc
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
/** The Node filesystem module */
|
||||
var fs = require('fs');
|
||||
|
||||
/** Used to minify string literals embedded in compiled strings */
|
||||
/** Used to minify string values used by `iterationFactory` and its options */
|
||||
var compiledValues = [
|
||||
'arrays',
|
||||
'objects'
|
||||
@@ -114,6 +114,13 @@
|
||||
// http://code.google.com/closure/compiler/docs/api-tutorial3.html#export
|
||||
source = source.replace(RegExp('\\.(' + iterationFactoryOptions.concat(propWhitelist).join('|') + ')\\b', 'g'), "['$1']");
|
||||
|
||||
// remove whitespace from string literals
|
||||
source = source.replace(/'(?:(?=(\\?))\1.)*?'/g, function(string) {
|
||||
return string.replace(/\[object |else if|function | in |return\s+[\w']|throw |use strict|var |'\\n'|\\n|\s+/g, function(match) {
|
||||
return match == false || match == '\\n' ? '' : match;
|
||||
});
|
||||
});
|
||||
|
||||
// minify `sortBy` and `template` methods
|
||||
['sortBy', 'template'].forEach(function(methodName) {
|
||||
var properties = ['criteria', 'value'],
|
||||
@@ -125,9 +132,6 @@
|
||||
result = result.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'");
|
||||
});
|
||||
|
||||
// remove escaped newlines in strings
|
||||
result = result.replace(/\\n/g, '');
|
||||
|
||||
// replace with modified snippet
|
||||
source = source.replace(snippet, result);
|
||||
});
|
||||
@@ -186,9 +190,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// remove escaped newlines in strings
|
||||
result = result.replace(/\\n/g, '');
|
||||
|
||||
// replace with modified snippet
|
||||
source = source.replace(snippet, result);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user