@babel/helper-string-parser
Advanced tools
Comparing version 7.18.10 to 7.19.4
@@ -30,3 +30,3 @@ "use strict"; | ||
let out = ""; | ||
let containsInvalid = false; | ||
let firstInvalidLoc = null; | ||
let chunkStart = pos; | ||
@@ -53,16 +53,19 @@ const { | ||
out += input.slice(chunkStart, pos); | ||
let escaped; | ||
const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors); | ||
if (res.ch === null && !firstInvalidLoc) { | ||
firstInvalidLoc = { | ||
pos, | ||
lineStart, | ||
curLine | ||
}; | ||
} else { | ||
out += res.ch; | ||
} | ||
({ | ||
ch: escaped, | ||
pos, | ||
lineStart, | ||
curLine | ||
} = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors)); | ||
if (escaped === null) { | ||
containsInvalid = true; | ||
} else { | ||
out += escaped; | ||
} | ||
} = res); | ||
chunkStart = pos; | ||
@@ -95,5 +98,6 @@ } else if (ch === 8232 || ch === 8233) { | ||
str: out, | ||
containsInvalid, | ||
firstInvalidLoc, | ||
lineStart, | ||
curLine | ||
curLine, | ||
containsInvalid: !!firstInvalidLoc | ||
}; | ||
@@ -219,3 +223,3 @@ } | ||
pos | ||
} = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors)); | ||
} = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid)); | ||
@@ -236,3 +240,3 @@ if (n === null) { | ||
function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors) { | ||
function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) { | ||
const start = pos; | ||
@@ -253,4 +257,12 @@ const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct; | ||
if (!allowNumSeparator) { | ||
if (bailOnError) return { | ||
n: null, | ||
pos | ||
}; | ||
errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine); | ||
} else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) { | ||
if (bailOnError) return { | ||
n: null, | ||
pos | ||
}; | ||
errors.unexpectedNumericSeparator(pos, lineStart, curLine); | ||
@@ -274,3 +286,8 @@ } | ||
if (val >= radix) { | ||
if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) { | ||
if (val <= 9 && bailOnError) { | ||
return { | ||
n: null, | ||
pos | ||
}; | ||
} else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) { | ||
val = 0; | ||
@@ -335,2 +352,4 @@ } else if (forceLen) { | ||
}; | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/helper-string-parser", | ||
"version": "7.18.10", | ||
"version": "7.19.4", | ||
"description": "A utility package to parse strings", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31709
5
293