mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Optimize the ES6 template delimiter regexp and regexp to detect strings.
Former-commit-id: 6177f2b32f27515cf8edcac6036d0adb58ebfcd0
This commit is contained in:
2
build.js
2
build.js
@@ -2413,8 +2413,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (!isStdOut) {
|
else if (!isStdOut) {
|
||||||
outputUsed = true;
|
|
||||||
filePath = outputPath || path.join(cwd, basename + '.js');
|
filePath = outputPath || path.join(cwd, basename + '.js');
|
||||||
|
outputUsed = true;
|
||||||
callback({
|
callback({
|
||||||
'source': debugSource,
|
'source': debugSource,
|
||||||
'outputPath': filePath
|
'outputPath': filePath
|
||||||
|
|||||||
@@ -233,7 +233,7 @@
|
|||||||
source = source.replace("result[length]['value']", 'result[length].value');
|
source = source.replace("result[length]['value']", 'result[length].value');
|
||||||
|
|
||||||
// remove whitespace from string literals
|
// remove whitespace from string literals
|
||||||
source = source.replace(/^([ "'\w]+:)? *"(?:(?=(\\?))\2.)*?"|'(?:(?=(\\?))\3.)*?'/gm, function(string, captured) {
|
source = source.replace(/^([ "'\w]+:)? *"[^"\\\n]*(?:\\.[^"\\\n]*)*"|'[^'\\\n]*(?:\\.[^'\\\n]*)*'/gm, function(string, captured) {
|
||||||
// remove object literal property name
|
// remove object literal property name
|
||||||
if (/:$/.test(captured)) {
|
if (/:$/.test(captured)) {
|
||||||
string = string.slice(captured.length);
|
string = string.slice(captured.length);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
* Used to match ES6 template delimiters
|
* Used to match ES6 template delimiters
|
||||||
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6
|
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6
|
||||||
*/
|
*/
|
||||||
var reEsTemplate = /\$\{((?:(?=\\?)\\?[\s\S])*?)\}/g;
|
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
||||||
|
|
||||||
/** Used to match "interpolate" template delimiters */
|
/** Used to match "interpolate" template delimiters */
|
||||||
var reInterpolate = /<%=([\s\S]+?)%>/g;
|
var reInterpolate = /<%=([\s\S]+?)%>/g;
|
||||||
|
|||||||
Reference in New Issue
Block a user