jsonrepair
Advanced tools
Comparing version 3.11.1 to 3.11.2
@@ -88,8 +88,9 @@ "use strict"; | ||
function parseWhitespaceAndSkipComments() { | ||
let skipNewline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
const start = i; | ||
let changed = parseWhitespace(); | ||
let changed = parseWhitespace(skipNewline); | ||
do { | ||
changed = parseComment(); | ||
if (changed) { | ||
changed = parseWhitespace(); | ||
changed = parseWhitespace(skipNewline); | ||
} | ||
@@ -99,14 +100,17 @@ } while (changed); | ||
} | ||
function parseWhitespace() { | ||
function parseWhitespace(skipNewline) { | ||
const _isWhiteSpace = skipNewline ? _stringUtils.isWhitespace : _stringUtils.isWhitespaceExceptNewline; | ||
let whitespace = ''; | ||
let normal; | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
while ((normal = (0, _stringUtils.isWhitespace)(text.charCodeAt(i))) || (0, _stringUtils.isSpecialWhitespace)(text.charCodeAt(i))) { | ||
if (normal) { | ||
while (true) { | ||
const c = text.charCodeAt(i); | ||
if (_isWhiteSpace(c)) { | ||
whitespace += text[i]; | ||
} else { | ||
i++; | ||
} else if ((0, _stringUtils.isSpecialWhitespace)(c)) { | ||
// repair special whitespace | ||
whitespace += ' '; | ||
i++; | ||
} else { | ||
break; | ||
} | ||
i++; | ||
} | ||
@@ -317,3 +321,3 @@ if (whitespace.length > 0) { | ||
// repair: wrap the output inside array brackets | ||
output = `[\n${output}\n]`; | ||
output = "[\n".concat(output, "\n]"); | ||
} | ||
@@ -386,3 +390,3 @@ | ||
output += str; | ||
parseWhitespaceAndSkipComments(); | ||
parseWhitespaceAndSkipComments(false); | ||
if (stopAtDelimiter || i >= text.length || (0, _stringUtils.isDelimiter)(text.charAt(i)) || (0, _stringUtils.isQuote)(text.charCodeAt(i)) || (0, _stringUtils.isDigit)(text.charCodeAt(i))) { | ||
@@ -418,3 +422,3 @@ // The quote is followed by the end of the text, a delimiter, | ||
// repair unescaped quote | ||
str = `${str.substring(0, oQuote)}\\${str.substring(oQuote)}`; | ||
str = "".concat(str.substring(0, oQuote), "\\").concat(str.substring(oQuote)); | ||
} else if (stopAtDelimiter && (0, _stringUtils.isUnquotedStringDelimiter)(text[i])) { | ||
@@ -470,3 +474,3 @@ // we're in the mode to stop the string at the first delimiter | ||
// repair unescaped double quote | ||
str += `\\${char}`; | ||
str += "\\".concat(char); | ||
i++; | ||
@@ -585,3 +589,3 @@ } else if ((0, _stringUtils.isControlCharacter)(code)) { | ||
const hasInvalidLeadingZero = /^0\d/.test(num); | ||
output += hasInvalidLeadingZero ? `"${num}"` : num; | ||
output += hasInvalidLeadingZero ? "\"".concat(num, "\"") : num; | ||
return true; | ||
@@ -678,3 +682,3 @@ } | ||
i++; | ||
output += `"${text.substring(start, i)}"`; | ||
output += "\"".concat(text.substring(start, i), "\""); | ||
return true; | ||
@@ -697,9 +701,9 @@ } | ||
// change the number more than it needs to make it valid JSON | ||
output += `${text.slice(start, i)}0`; | ||
output += "".concat(text.slice(start, i), "0"); | ||
} | ||
function throwInvalidCharacter(char) { | ||
throw new _JSONRepairError.JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i); | ||
throw new _JSONRepairError.JSONRepairError("Invalid character ".concat(JSON.stringify(char)), i); | ||
} | ||
function throwUnexpectedCharacter() { | ||
throw new _JSONRepairError.JSONRepairError(`Unexpected character ${JSON.stringify(text[i])}`, i); | ||
throw new _JSONRepairError.JSONRepairError("Unexpected character ".concat(JSON.stringify(text[i])), i); | ||
} | ||
@@ -717,3 +721,3 @@ function throwUnexpectedEnd() { | ||
const chars = text.slice(i, i + 6); | ||
throw new _JSONRepairError.JSONRepairError(`Invalid unicode character "${chars}"`, i); | ||
throw new _JSONRepairError.JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i); | ||
} | ||
@@ -720,0 +724,0 @@ } |
@@ -14,7 +14,7 @@ "use strict"; | ||
if (index < offset) { | ||
throw new Error(`${indexOutOfRangeMessage} (index: ${index}, offset: ${offset})`); | ||
throw new Error("".concat(indexOutOfRangeMessage, " (index: ").concat(index, ", offset: ").concat(offset, ")")); | ||
} | ||
if (index >= currentLength) { | ||
if (!closed) { | ||
throw new Error(`${indexOutOfRangeMessage} (index: ${index})`); | ||
throw new Error("".concat(indexOutOfRangeMessage, " (index: ").concat(index, ")")); | ||
} | ||
@@ -21,0 +21,0 @@ } |
@@ -39,3 +39,3 @@ "use strict"; | ||
if (offset > 0) { | ||
throw new Error(`Cannot unshift: ${flushedMessage}`); | ||
throw new Error("Cannot unshift: ".concat(flushedMessage)); | ||
} | ||
@@ -47,3 +47,3 @@ buffer = text + buffer; | ||
if (start < offset) { | ||
throw new Error(`Cannot remove: ${flushedMessage}`); | ||
throw new Error("Cannot remove: ".concat(flushedMessage)); | ||
} | ||
@@ -58,3 +58,3 @@ if (end !== undefined) { | ||
if (index < offset) { | ||
throw new Error(`Cannot insert: ${flushedMessage}`); | ||
throw new Error("Cannot insert: ".concat(flushedMessage)); | ||
} | ||
@@ -89,3 +89,3 @@ buffer = buffer.substring(0, index - offset) + text + buffer.substring(index - offset); | ||
if (bufferIndex <= 0) { | ||
throw new Error(`Cannot insert: ${flushedMessage}`); | ||
throw new Error("Cannot insert: ".concat(flushedMessage)); | ||
} | ||
@@ -92,0 +92,0 @@ buffer = buffer.substring(0, bufferIndex) + textToInsert + buffer.substring(bufferIndex); |
@@ -207,3 +207,3 @@ "use strict"; | ||
i++; | ||
output.push(`"${input.substring(start, i)}"`); | ||
output.push("\"".concat(input.substring(start, i), "\"")); | ||
return stack.update(_stack.Caret.afterValue); | ||
@@ -356,8 +356,9 @@ } | ||
function parseWhitespaceAndSkipComments() { | ||
let skipNewline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
const start = i; | ||
let changed = parseWhitespace(); | ||
let changed = parseWhitespace(skipNewline); | ||
do { | ||
changed = parseComment(); | ||
if (changed) { | ||
changed = parseWhitespace(); | ||
changed = parseWhitespace(skipNewline); | ||
} | ||
@@ -367,15 +368,17 @@ } while (changed); | ||
} | ||
function parseWhitespace() { | ||
function parseWhitespace(skipNewline) { | ||
const _isWhiteSpace = skipNewline ? _stringUtils.isWhitespace : _stringUtils.isWhitespaceExceptNewline; | ||
let whitespace = ''; | ||
let normal; | ||
while ( | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
(normal = (0, _stringUtils.isWhitespace)(input.charCodeAt(i))) || (0, _stringUtils.isSpecialWhitespace)(input.charCodeAt(i))) { | ||
if (normal) { | ||
while (true) { | ||
const c = input.charCodeAt(i); | ||
if (_isWhiteSpace(c)) { | ||
whitespace += input.charAt(i); | ||
} else { | ||
i++; | ||
} else if ((0, _stringUtils.isSpecialWhitespace)(c)) { | ||
// repair special whitespace | ||
whitespace += ' '; | ||
i++; | ||
} else { | ||
break; | ||
} | ||
i++; | ||
} | ||
@@ -506,3 +509,3 @@ if (whitespace.length > 0) { | ||
i++; | ||
parseWhitespaceAndSkipComments(); | ||
parseWhitespaceAndSkipComments(false); | ||
if (stopAtDelimiter || input.isEnd(i) || (0, _stringUtils.isDelimiter)(input.charAt(i)) || (0, _stringUtils.isQuote)(input.charCodeAt(i)) || (0, _stringUtils.isDigit)(input.charCodeAt(i))) { | ||
@@ -588,3 +591,3 @@ // The quote is followed by the end of the text, a delimiter, or a next value | ||
// repair unescaped double quote | ||
output.push(`\\${char}`); | ||
output.push("\\".concat(char)); | ||
i++; | ||
@@ -703,3 +706,3 @@ } else if ((0, _stringUtils.isControlCharacter)(code)) { | ||
const hasInvalidLeadingZero = /^0\d/.test(num); | ||
output.push(hasInvalidLeadingZero ? `"${num}"` : num); | ||
output.push(hasInvalidLeadingZero ? "\"".concat(num, "\"") : num); | ||
return stack.update(_stack.Caret.afterValue); | ||
@@ -768,9 +771,9 @@ } | ||
// change the number more than it needs to make it valid JSON | ||
output.push(`${input.substring(start, i)}0`); | ||
output.push("".concat(input.substring(start, i), "0")); | ||
} | ||
function throwInvalidCharacter(char) { | ||
throw new _JSONRepairError.JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i); | ||
throw new _JSONRepairError.JSONRepairError("Invalid character ".concat(JSON.stringify(char)), i); | ||
} | ||
function throwUnexpectedCharacter() { | ||
throw new _JSONRepairError.JSONRepairError(`Unexpected character ${JSON.stringify(input.charAt(i))}`, i); | ||
throw new _JSONRepairError.JSONRepairError("Unexpected character ".concat(JSON.stringify(input.charAt(i))), i); | ||
} | ||
@@ -788,3 +791,3 @@ function throwUnexpectedEnd() { | ||
const chars = input.substring(i, i + 6); | ||
throw new _JSONRepairError.JSONRepairError(`Invalid unicode character "${chars}"`, i); | ||
throw new _JSONRepairError.JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i); | ||
} | ||
@@ -791,0 +794,0 @@ function atEndOfBlockComment(i) { |
@@ -12,4 +12,4 @@ "use strict"; | ||
onData: chunk => transform.push(chunk), | ||
bufferSize: options?.bufferSize, | ||
chunkSize: options?.chunkSize | ||
bufferSize: options === null || options === void 0 ? void 0 : options.bufferSize, | ||
chunkSize: options === null || options === void 0 ? void 0 : options.chunkSize | ||
}); | ||
@@ -16,0 +16,0 @@ const transform = new _nodeStream.Transform({ |
@@ -9,3 +9,3 @@ "use strict"; | ||
constructor(message, position) { | ||
super(`${message} at position ${position}`); | ||
super("".concat(message, " at position ").concat(position)); | ||
this.position = position; | ||
@@ -12,0 +12,0 @@ } |
@@ -23,2 +23,3 @@ "use strict"; | ||
exports.isWhitespace = isWhitespace; | ||
exports.isWhitespaceExceptNewline = isWhitespaceExceptNewline; | ||
exports.regexUrlStart = exports.regexUrlChar = exports.regexFunctionNameCharStart = exports.regexFunctionNameChar = void 0; | ||
@@ -115,2 +116,10 @@ exports.removeAtIndex = removeAtIndex; | ||
/** | ||
* Check if the given character is a whitespace character like space or tab, | ||
* but NOT a newline | ||
*/ | ||
function isWhitespaceExceptNewline(code) { | ||
return code === codeSpace || code === codeTab || code === codeReturn; | ||
} | ||
/** | ||
* Check if the given character is a special whitespace character, some | ||
@@ -117,0 +126,0 @@ * unicode variant |
import { JSONRepairError } from '../utils/JSONRepairError.js'; | ||
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codePlus, codeSemicolon, codeSlash, codeUppercaseE, endsWithCommaOrNewline, insertBeforeLastWhitespace, isControlCharacter, isDelimiter, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isUnquotedStringDelimiter, isValidStringCharacter, isWhitespace, regexFunctionNameChar, regexFunctionNameCharStart, regexUrlChar, regexUrlStart, removeAtIndex, stripLastOccurrence } from '../utils/stringUtils.js'; | ||
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codePlus, codeSemicolon, codeSlash, codeUppercaseE, endsWithCommaOrNewline, insertBeforeLastWhitespace, isControlCharacter, isDelimiter, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isUnquotedStringDelimiter, isValidStringCharacter, isWhitespace, isWhitespaceExceptNewline, regexFunctionNameChar, regexFunctionNameCharStart, regexUrlChar, regexUrlStart, removeAtIndex, stripLastOccurrence } from '../utils/stringUtils.js'; | ||
const controlCharacters = { | ||
@@ -82,8 +82,9 @@ '\b': '\\b', | ||
function parseWhitespaceAndSkipComments() { | ||
let skipNewline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
const start = i; | ||
let changed = parseWhitespace(); | ||
let changed = parseWhitespace(skipNewline); | ||
do { | ||
changed = parseComment(); | ||
if (changed) { | ||
changed = parseWhitespace(); | ||
changed = parseWhitespace(skipNewline); | ||
} | ||
@@ -93,14 +94,17 @@ } while (changed); | ||
} | ||
function parseWhitespace() { | ||
function parseWhitespace(skipNewline) { | ||
const _isWhiteSpace = skipNewline ? isWhitespace : isWhitespaceExceptNewline; | ||
let whitespace = ''; | ||
let normal; | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
while ((normal = isWhitespace(text.charCodeAt(i))) || isSpecialWhitespace(text.charCodeAt(i))) { | ||
if (normal) { | ||
while (true) { | ||
const c = text.charCodeAt(i); | ||
if (_isWhiteSpace(c)) { | ||
whitespace += text[i]; | ||
} else { | ||
i++; | ||
} else if (isSpecialWhitespace(c)) { | ||
// repair special whitespace | ||
whitespace += ' '; | ||
i++; | ||
} else { | ||
break; | ||
} | ||
i++; | ||
} | ||
@@ -311,3 +315,3 @@ if (whitespace.length > 0) { | ||
// repair: wrap the output inside array brackets | ||
output = `[\n${output}\n]`; | ||
output = "[\n".concat(output, "\n]"); | ||
} | ||
@@ -380,3 +384,3 @@ | ||
output += str; | ||
parseWhitespaceAndSkipComments(); | ||
parseWhitespaceAndSkipComments(false); | ||
if (stopAtDelimiter || i >= text.length || isDelimiter(text.charAt(i)) || isQuote(text.charCodeAt(i)) || isDigit(text.charCodeAt(i))) { | ||
@@ -412,3 +416,3 @@ // The quote is followed by the end of the text, a delimiter, | ||
// repair unescaped quote | ||
str = `${str.substring(0, oQuote)}\\${str.substring(oQuote)}`; | ||
str = "".concat(str.substring(0, oQuote), "\\").concat(str.substring(oQuote)); | ||
} else if (stopAtDelimiter && isUnquotedStringDelimiter(text[i])) { | ||
@@ -464,3 +468,3 @@ // we're in the mode to stop the string at the first delimiter | ||
// repair unescaped double quote | ||
str += `\\${char}`; | ||
str += "\\".concat(char); | ||
i++; | ||
@@ -579,3 +583,3 @@ } else if (isControlCharacter(code)) { | ||
const hasInvalidLeadingZero = /^0\d/.test(num); | ||
output += hasInvalidLeadingZero ? `"${num}"` : num; | ||
output += hasInvalidLeadingZero ? "\"".concat(num, "\"") : num; | ||
return true; | ||
@@ -672,3 +676,3 @@ } | ||
i++; | ||
output += `"${text.substring(start, i)}"`; | ||
output += "\"".concat(text.substring(start, i), "\""); | ||
return true; | ||
@@ -691,9 +695,9 @@ } | ||
// change the number more than it needs to make it valid JSON | ||
output += `${text.slice(start, i)}0`; | ||
output += "".concat(text.slice(start, i), "0"); | ||
} | ||
function throwInvalidCharacter(char) { | ||
throw new JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i); | ||
throw new JSONRepairError("Invalid character ".concat(JSON.stringify(char)), i); | ||
} | ||
function throwUnexpectedCharacter() { | ||
throw new JSONRepairError(`Unexpected character ${JSON.stringify(text[i])}`, i); | ||
throw new JSONRepairError("Unexpected character ".concat(JSON.stringify(text[i])), i); | ||
} | ||
@@ -711,3 +715,3 @@ function throwUnexpectedEnd() { | ||
const chars = text.slice(i, i + 6); | ||
throw new JSONRepairError(`Invalid unicode character "${chars}"`, i); | ||
throw new JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i); | ||
} | ||
@@ -714,0 +718,0 @@ } |
@@ -8,7 +8,7 @@ export function createInputBuffer() { | ||
if (index < offset) { | ||
throw new Error(`${indexOutOfRangeMessage} (index: ${index}, offset: ${offset})`); | ||
throw new Error("".concat(indexOutOfRangeMessage, " (index: ").concat(index, ", offset: ").concat(offset, ")")); | ||
} | ||
if (index >= currentLength) { | ||
if (!closed) { | ||
throw new Error(`${indexOutOfRangeMessage} (index: ${index})`); | ||
throw new Error("".concat(indexOutOfRangeMessage, " (index: ").concat(index, ")")); | ||
} | ||
@@ -15,0 +15,0 @@ } |
@@ -33,3 +33,3 @@ import { isWhitespace } from '../../utils/stringUtils.js'; | ||
if (offset > 0) { | ||
throw new Error(`Cannot unshift: ${flushedMessage}`); | ||
throw new Error("Cannot unshift: ".concat(flushedMessage)); | ||
} | ||
@@ -41,3 +41,3 @@ buffer = text + buffer; | ||
if (start < offset) { | ||
throw new Error(`Cannot remove: ${flushedMessage}`); | ||
throw new Error("Cannot remove: ".concat(flushedMessage)); | ||
} | ||
@@ -52,3 +52,3 @@ if (end !== undefined) { | ||
if (index < offset) { | ||
throw new Error(`Cannot insert: ${flushedMessage}`); | ||
throw new Error("Cannot insert: ".concat(flushedMessage)); | ||
} | ||
@@ -83,3 +83,3 @@ buffer = buffer.substring(0, index - offset) + text + buffer.substring(index - offset); | ||
if (bufferIndex <= 0) { | ||
throw new Error(`Cannot insert: ${flushedMessage}`); | ||
throw new Error("Cannot insert: ".concat(flushedMessage)); | ||
} | ||
@@ -86,0 +86,0 @@ buffer = buffer.substring(0, bufferIndex) + textToInsert + buffer.substring(bufferIndex); |
import { JSONRepairError } from '../utils/JSONRepairError.js'; | ||
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpenParenthesis, codeOpeningBrace, codeOpeningBracket, codePlus, codeSemicolon, codeSlash, codeUppercaseE, isControlCharacter, isDelimiter, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isUnquotedStringDelimiter, isValidStringCharacter, isWhitespace, regexFunctionNameChar, regexFunctionNameCharStart, regexUrlChar, regexUrlStart } from '../utils/stringUtils.js'; | ||
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpenParenthesis, codeOpeningBrace, codeOpeningBracket, codePlus, codeSemicolon, codeSlash, codeUppercaseE, isControlCharacter, isDelimiter, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isUnquotedStringDelimiter, isValidStringCharacter, isWhitespace, isWhitespaceExceptNewline, regexFunctionNameChar, regexFunctionNameCharStart, regexUrlChar, regexUrlStart } from '../utils/stringUtils.js'; | ||
import { createInputBuffer } from './buffer/InputBuffer.js'; | ||
@@ -201,3 +201,3 @@ import { createOutputBuffer } from './buffer/OutputBuffer.js'; | ||
i++; | ||
output.push(`"${input.substring(start, i)}"`); | ||
output.push("\"".concat(input.substring(start, i), "\"")); | ||
return stack.update(Caret.afterValue); | ||
@@ -350,8 +350,9 @@ } | ||
function parseWhitespaceAndSkipComments() { | ||
let skipNewline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
const start = i; | ||
let changed = parseWhitespace(); | ||
let changed = parseWhitespace(skipNewline); | ||
do { | ||
changed = parseComment(); | ||
if (changed) { | ||
changed = parseWhitespace(); | ||
changed = parseWhitespace(skipNewline); | ||
} | ||
@@ -361,15 +362,17 @@ } while (changed); | ||
} | ||
function parseWhitespace() { | ||
function parseWhitespace(skipNewline) { | ||
const _isWhiteSpace = skipNewline ? isWhitespace : isWhitespaceExceptNewline; | ||
let whitespace = ''; | ||
let normal; | ||
while ( | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
(normal = isWhitespace(input.charCodeAt(i))) || isSpecialWhitespace(input.charCodeAt(i))) { | ||
if (normal) { | ||
while (true) { | ||
const c = input.charCodeAt(i); | ||
if (_isWhiteSpace(c)) { | ||
whitespace += input.charAt(i); | ||
} else { | ||
i++; | ||
} else if (isSpecialWhitespace(c)) { | ||
// repair special whitespace | ||
whitespace += ' '; | ||
i++; | ||
} else { | ||
break; | ||
} | ||
i++; | ||
} | ||
@@ -500,3 +503,3 @@ if (whitespace.length > 0) { | ||
i++; | ||
parseWhitespaceAndSkipComments(); | ||
parseWhitespaceAndSkipComments(false); | ||
if (stopAtDelimiter || input.isEnd(i) || isDelimiter(input.charAt(i)) || isQuote(input.charCodeAt(i)) || isDigit(input.charCodeAt(i))) { | ||
@@ -582,3 +585,3 @@ // The quote is followed by the end of the text, a delimiter, or a next value | ||
// repair unescaped double quote | ||
output.push(`\\${char}`); | ||
output.push("\\".concat(char)); | ||
i++; | ||
@@ -697,3 +700,3 @@ } else if (isControlCharacter(code)) { | ||
const hasInvalidLeadingZero = /^0\d/.test(num); | ||
output.push(hasInvalidLeadingZero ? `"${num}"` : num); | ||
output.push(hasInvalidLeadingZero ? "\"".concat(num, "\"") : num); | ||
return stack.update(Caret.afterValue); | ||
@@ -762,9 +765,9 @@ } | ||
// change the number more than it needs to make it valid JSON | ||
output.push(`${input.substring(start, i)}0`); | ||
output.push("".concat(input.substring(start, i), "0")); | ||
} | ||
function throwInvalidCharacter(char) { | ||
throw new JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i); | ||
throw new JSONRepairError("Invalid character ".concat(JSON.stringify(char)), i); | ||
} | ||
function throwUnexpectedCharacter() { | ||
throw new JSONRepairError(`Unexpected character ${JSON.stringify(input.charAt(i))}`, i); | ||
throw new JSONRepairError("Unexpected character ".concat(JSON.stringify(input.charAt(i))), i); | ||
} | ||
@@ -782,3 +785,3 @@ function throwUnexpectedEnd() { | ||
const chars = input.substring(i, i + 6); | ||
throw new JSONRepairError(`Invalid unicode character "${chars}"`, i); | ||
throw new JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i); | ||
} | ||
@@ -785,0 +788,0 @@ function atEndOfBlockComment(i) { |
@@ -6,4 +6,4 @@ import { Transform } from 'node:stream'; | ||
onData: chunk => transform.push(chunk), | ||
bufferSize: options?.bufferSize, | ||
chunkSize: options?.chunkSize | ||
bufferSize: options === null || options === void 0 ? void 0 : options.bufferSize, | ||
chunkSize: options === null || options === void 0 ? void 0 : options.chunkSize | ||
}); | ||
@@ -10,0 +10,0 @@ const transform = new Transform({ |
export class JSONRepairError extends Error { | ||
constructor(message, position) { | ||
super(`${message} at position ${position}`); | ||
super("".concat(message, " at position ").concat(position)); | ||
this.position = position; | ||
@@ -5,0 +5,0 @@ } |
@@ -89,2 +89,10 @@ export const codeBackslash = 0x5c; // "\" | ||
/** | ||
* Check if the given character is a whitespace character like space or tab, | ||
* but NOT a newline | ||
*/ | ||
export function isWhitespaceExceptNewline(code) { | ||
return code === codeSpace || code === codeTab || code === codeReturn; | ||
} | ||
/** | ||
* Check if the given character is a special whitespace character, some | ||
@@ -91,0 +99,0 @@ * unicode variant |
@@ -49,2 +49,7 @@ export declare const codeBackslash = 92; | ||
/** | ||
* Check if the given character is a whitespace character like space or tab, | ||
* but NOT a newline | ||
*/ | ||
export declare function isWhitespaceExceptNewline(code: number): boolean; | ||
/** | ||
* Check if the given character is a special whitespace character, some | ||
@@ -51,0 +56,0 @@ * unicode variant |
@@ -9,3 +9,3 @@ (function (global, factory) { | ||
constructor(message, position) { | ||
super(`${message} at position ${position}`); | ||
super("".concat(message, " at position ").concat(position)); | ||
this.position = position; | ||
@@ -102,2 +102,10 @@ } | ||
/** | ||
* Check if the given character is a whitespace character like space or tab, | ||
* but NOT a newline | ||
*/ | ||
function isWhitespaceExceptNewline(code) { | ||
return code === codeSpace || code === codeTab || code === codeReturn; | ||
} | ||
/** | ||
* Check if the given character is a special whitespace character, some | ||
@@ -261,8 +269,9 @@ * unicode variant | ||
function parseWhitespaceAndSkipComments() { | ||
let skipNewline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
const start = i; | ||
let changed = parseWhitespace(); | ||
let changed = parseWhitespace(skipNewline); | ||
do { | ||
changed = parseComment(); | ||
if (changed) { | ||
changed = parseWhitespace(); | ||
changed = parseWhitespace(skipNewline); | ||
} | ||
@@ -272,14 +281,17 @@ } while (changed); | ||
} | ||
function parseWhitespace() { | ||
function parseWhitespace(skipNewline) { | ||
const _isWhiteSpace = skipNewline ? isWhitespace : isWhitespaceExceptNewline; | ||
let whitespace = ''; | ||
let normal; | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
while ((normal = isWhitespace(text.charCodeAt(i))) || isSpecialWhitespace(text.charCodeAt(i))) { | ||
if (normal) { | ||
while (true) { | ||
const c = text.charCodeAt(i); | ||
if (_isWhiteSpace(c)) { | ||
whitespace += text[i]; | ||
} else { | ||
i++; | ||
} else if (isSpecialWhitespace(c)) { | ||
// repair special whitespace | ||
whitespace += ' '; | ||
i++; | ||
} else { | ||
break; | ||
} | ||
i++; | ||
} | ||
@@ -490,3 +502,3 @@ if (whitespace.length > 0) { | ||
// repair: wrap the output inside array brackets | ||
output = `[\n${output}\n]`; | ||
output = "[\n".concat(output, "\n]"); | ||
} | ||
@@ -559,3 +571,3 @@ | ||
output += str; | ||
parseWhitespaceAndSkipComments(); | ||
parseWhitespaceAndSkipComments(false); | ||
if (stopAtDelimiter || i >= text.length || isDelimiter(text.charAt(i)) || isQuote(text.charCodeAt(i)) || isDigit(text.charCodeAt(i))) { | ||
@@ -591,3 +603,3 @@ // The quote is followed by the end of the text, a delimiter, | ||
// repair unescaped quote | ||
str = `${str.substring(0, oQuote)}\\${str.substring(oQuote)}`; | ||
str = "".concat(str.substring(0, oQuote), "\\").concat(str.substring(oQuote)); | ||
} else if (stopAtDelimiter && isUnquotedStringDelimiter(text[i])) { | ||
@@ -643,3 +655,3 @@ // we're in the mode to stop the string at the first delimiter | ||
// repair unescaped double quote | ||
str += `\\${char}`; | ||
str += "\\".concat(char); | ||
i++; | ||
@@ -758,3 +770,3 @@ } else if (isControlCharacter(code)) { | ||
const hasInvalidLeadingZero = /^0\d/.test(num); | ||
output += hasInvalidLeadingZero ? `"${num}"` : num; | ||
output += hasInvalidLeadingZero ? "\"".concat(num, "\"") : num; | ||
return true; | ||
@@ -851,3 +863,3 @@ } | ||
i++; | ||
output += `"${text.substring(start, i)}"`; | ||
output += "\"".concat(text.substring(start, i), "\""); | ||
return true; | ||
@@ -870,9 +882,9 @@ } | ||
// change the number more than it needs to make it valid JSON | ||
output += `${text.slice(start, i)}0`; | ||
output += "".concat(text.slice(start, i), "0"); | ||
} | ||
function throwInvalidCharacter(char) { | ||
throw new JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i); | ||
throw new JSONRepairError("Invalid character ".concat(JSON.stringify(char)), i); | ||
} | ||
function throwUnexpectedCharacter() { | ||
throw new JSONRepairError(`Unexpected character ${JSON.stringify(text[i])}`, i); | ||
throw new JSONRepairError("Unexpected character ".concat(JSON.stringify(text[i])), i); | ||
} | ||
@@ -890,3 +902,3 @@ function throwUnexpectedEnd() { | ||
const chars = text.slice(i, i + 6); | ||
throw new JSONRepairError(`Invalid unicode character "${chars}"`, i); | ||
throw new JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i); | ||
} | ||
@@ -893,0 +905,0 @@ } |
@@ -1,3 +0,1 @@ | ||
((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).JSONRepair={})})(this,function(t){class y extends Error{constructor(t,e){super(t+" at position "+e),this.position=e}}let u=125,e=32,O=10,N=9,J=13,S=8,j=12,k=34,r=39,m=48,z=57,d=44,I=65,T=97,Z=70,_=102,l=160,s=8192,A=8202,E=8239,W=8287,X=12288,n=8220,o=8221,i=8216,c=8217,f=96,a=180;function R(t){return t>=m&&t<=z}function U(t){return h.test(t)}let h=/^[,:[\]/{}()\n+]$/,C=/^[,[\]/{}\n+]$/,Y=/^[a-zA-Z_$]$/,tt=/^[a-zA-Z_$0-9]$/,F=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,q=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function B(t){return C.test(t)}function D(t){return g.test(t)||t&&H(t.charCodeAt(0))}let g=/^[[{\w-]$/;function G(t){return t===e||t===O||t===N||t===J}function H(t){return K(t)||M(t)}function K(t){return t===k||t===n||t===o}function L(t){return t===k}function M(t){return t===r||t===i||t===c||t===f||t===a}function P(t){return t===r}function Q(t,e,r){r=2<arguments.length&&void 0!==r&&r,e=t.lastIndexOf(e);return-1!==e?t.substring(0,e)+(r?"":t.substring(e+1)):t}function V(t,e){let r=t.length;if(!G(t.charCodeAt(r-1)))return t+e;for(;G(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}let et={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},rt={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=y,t.jsonrepair=function(C){let g=0,b="";if(!i())throw new y("Unexpected end of json string",C.length);var t=c(d);if(t&&v(),D(C[g])&&/[,\n][ \t\r]*$/.test(b)){t||(b=V(b,","));{let t=!0,e=!0;for(;e;)t?t=!1:c(d)||(b=V(b,",")),e=i();b=`[ | ||
${b=e?b:Q(b,",")} | ||
]`}}else t&&(b=Q(b,","));for(;C.charCodeAt(g)===u||93===C.charCodeAt(g);)g++,v();if(g>=C.length)return b;throw new y("Unexpected character "+JSON.stringify(C[g]),g);function i(){v();var t=(()=>{if(123!==C.charCodeAt(g))return!1;{b+="{",g++,v(),p(d)&&v();let e=!0;for(;g<C.length&&C.charCodeAt(g)!==u;){let t;if(e?(t=!0,e=!1):((t=c(d))||(b=V(b,",")),v()),f(),!($()||a(!0))){C.charCodeAt(g)===u||123===C.charCodeAt(g)||93===C.charCodeAt(g)||91===C.charCodeAt(g)||void 0===C[g]?b=Q(b,","):(()=>{throw new y("Object key expected",g)})();break}v();var r=c(58),n=g>=C.length,o=(r||(D(C[g])||n?b=V(b,":"):h()),i());o||(r||n?b+="null":h())}return C.charCodeAt(g)===u?(b+="}",g++):b=V(b,"}"),!0}})()||(()=>{if(91!==C.charCodeAt(g))return!1;{b+="[",g++,v(),p(d)&&v();let t=!0;for(;g<C.length&&93!==C.charCodeAt(g);){t?t=!1:c(d)||(b=V(b,",")),f();var e=i();if(!e){b=Q(b,",");break}}return 93===C.charCodeAt(g)?(b+="]",g++):b=V(b,"]"),!0}})()||$()||(()=>{var t,e,r=g;if(45===C.charCodeAt(g)){if(g++,n())return o(r),!0;if(!R(C.charCodeAt(g)))return g=r,!1}for(;R(C.charCodeAt(g));)g++;if(46===C.charCodeAt(g)){if(g++,n())return o(r),!0;if(!R(C.charCodeAt(g)))return g=r,!1;for(;R(C.charCodeAt(g));)g++}if(101===C.charCodeAt(g)||69===C.charCodeAt(g)){if(g++,45!==C.charCodeAt(g)&&43!==C.charCodeAt(g)||g++,n())return o(r),!0;if(!R(C.charCodeAt(g)))return g=r,!1;for(;R(C.charCodeAt(g));)g++}if(n()){if(g>r)return t=C.slice(r,g),e=/^0\d/.test(t),b+=e?`"${t}"`:t,!0}else g=r;return!1})()||r("true","true")||r("false","false")||r("null","null")||r("True","true")||r("False","false")||r("None","null")||a(!1)||(()=>{if("/"===C[g]){var t=g;for(g++;g<C.length&&("/"!==C[g]||"\\"===C[g-1]);)g++;return g++,b+=`"${C.substring(t,g)}"`,!0}})();return v(),t}function v(){g;let t=e();for(;t=(t=(()=>{if(47===C.charCodeAt(g)&&42===C.charCodeAt(g+1)){for(;g<C.length&&!((t,e)=>"*"===t[e]&&"/"===t[e+1])(C,g);)g++;g+=2}else{if(47!==C.charCodeAt(g)||47!==C.charCodeAt(g+1))return!1;for(;g<C.length&&C.charCodeAt(g)!==O;)g++}return!0})())&&e(););g}function e(){let t="";for(var e,r;(e=G(C.charCodeAt(g)))||(r=C.charCodeAt(g))===l||r>=s&&r<=A||r===E||r===W||r===X;)t+=e?C[g]:" ",g++;return 0<t.length&&(b+=t,!0)}function c(t){return C.charCodeAt(g)===t&&(b+=C[g],g++,!0)}function p(t){return C.charCodeAt(g)===t&&(g++,!0)}function f(){v(),46===C.charCodeAt(g)&&46===C.charCodeAt(g+1)&&46===C.charCodeAt(g+2)&&(g+=3,v(),p(d))}function $(t,e){var r,n,o=0<arguments.length&&void 0!==t&&t,i=1<arguments.length&&void 0!==e?e:-1;let c=92===C.charCodeAt(g);if(c&&(g++,c=!0),H(C.charCodeAt(g))){var f=L(C.charCodeAt(g))?L:P(C.charCodeAt(g))?P:M(C.charCodeAt(g))?M:K,a=g,h=b.length;let e='"';for(g++;;){if(g>=C.length)return u=x(g-1),!o&&U(C.charAt(u))?(g=a,b=b.substring(0,h),$(!0)):(e=V(e,'"'),b+=e,!0);if(g===i)return e=V(e,'"'),b+=e,!0;if(f(C.charCodeAt(g))){var u=g,d=e.length;if(e+='"',g++,b+=e,v(),o||g>=C.length||U(C.charAt(g))||H(C.charCodeAt(g))||R(C.charCodeAt(g)))return w(),!0;var l=x(u-1),s=C.charAt(l);if(","===s)return g=a,b=b.substring(0,h),$(!1,l);if(U(s))return g=a,b=b.substring(0,h),$(!0);b=b.substring(0,h),g=u+1,e=e.substring(0,d)+"\\"+e.substring(d)}else{if(o&&B(C[g])){if(58===C.charCodeAt(g-1)&&F.test(C.substring(a+1,g+2)))for(;g<C.length&&q.test(C[g]);)e+=C[g],g++;return e=V(e,'"'),b+=e,w(),!0}if(92===C.charCodeAt(g)){l=C.charAt(g+1);if(void 0!==rt[l])e+=C.slice(g,g+2),g+=2;else if("u"===l){let t=2;for(;t<6&&((n=C.charCodeAt(g+t))>=m&&n<=z||n>=I&&n<=Z||n>=T&&n<=_);)t++;if(6===t)e+=C.slice(g,g+6),g+=6;else{if(!(g+t>=C.length))throw s=void 0,s=C.slice(g,g+6),new y(`Invalid unicode character "${s}"`,g);g=C.length}}else e+=l,g+=2}else{var d=C.charAt(g),A=C.charCodeAt(g);if(A===k&&92!==C.charCodeAt(g-1))e+="\\"+d;else if((r=A)===O||r===J||r===N||r===S||r===j)e+=et[d];else{if(!(32<=(r=A)&&r<=1114111))throw A=void 0,A=d,new y("Invalid character "+JSON.stringify(A),g);e+=d}g++}}c&&p(92)}}return!1}function w(){let t=!1;for(v();43===C.charCodeAt(g);){t=!0,g++,v();var e=(b=Q(b,'"',!0)).length,r=$();b=r?(r=b,e=e,n=1,r.substring(0,e)+r.substring(e+n)):V(b,'"')}var n;t}function r(t,e){return C.slice(g,g+t.length)===t&&(b+=e,g+=t.length,!0)}function a(t){var e=g;if(Y.test(C[g])){for(;g<C.length&&tt.test(C[g]);)g++;let t=g;for(;G(C.charCodeAt(t));)t++;if("("===C[t])return g=t+1,i(),41===C.charCodeAt(g)&&(g++,59===C.charCodeAt(g))&&g++,!0}for(;g<C.length&&!B(C[g])&&!H(C.charCodeAt(g))&&(!t||58!==C.charCodeAt(g));)g++;if(58===C.charCodeAt(g-1)&&F.test(C.substring(e,g+2)))for(;g<C.length&&q.test(C[g]);)g++;if(g>e){for(;G(C.charCodeAt(g-1))&&0<g;)g--;e=C.slice(e,g);return b+="undefined"===e?"null":JSON.stringify(e),C.charCodeAt(g)===k&&g++,!0}}function x(t){let e=t;for(;0<e&&G(C.charCodeAt(e));)e--;return e}function n(){return g>=C.length||U(C[g])||G(C.charCodeAt(g))}function o(t){b+=C.slice(t,g)+"0"}function h(){throw new y("Colon expected",g)}}}); | ||
((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).JSONRepair={})})(this,function(t){class y extends Error{constructor(t,e){super("".concat(t," at position ").concat(e)),this.position=e}}let d=125,e=32,O=10,N=9,J=13,S=8,j=12,k=34,r=39,m=48,z=57,l=44,I=65,T=97,Z=70,_=102,s=160,A=8192,E=8202,R=8239,X=8287,Y=12288,n=8220,o=8221,c=8216,i=8217,a=96,f=180;function U(t){return t>=m&&t<=z}function F(t){return h.test(t)}let h=/^[,:[\]/{}()\n+]$/,u=/^[,[\]/{}\n+]$/,tt=/^[a-zA-Z_$]$/,et=/^[a-zA-Z_$0-9]$/,q=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,B=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function D(t){return u.test(t)}function G(t){return C.test(t)||t&&K(t.charCodeAt(0))}let C=/^[[{\w-]$/;function H(t){return t===e||t===O||t===N||t===J}function rt(t){return t===e||t===N||t===J}function K(t){return L(t)||P(t)}function L(t){return t===k||t===n||t===o}function M(t){return t===k}function P(t){return t===r||t===c||t===i||t===a||t===f}function Q(t){return t===r}function V(t,e,r){r=2<arguments.length&&void 0!==r&&r,e=t.lastIndexOf(e);return-1!==e?t.substring(0,e)+(r?"":t.substring(e+1)):t}function W(t,e){let r=t.length;if(!H(t.charCodeAt(r-1)))return t+e;for(;H(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}let nt={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},ot={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=y,t.jsonrepair=function(C){let g=0,v="";if(!c())throw new y("Unexpected end of json string",C.length);var t=i(l);if(t&&b(),G(C[g])&&/[,\n][ \t\r]*$/.test(v)){t||(v=W(v,","));{let t=!0,e=!0;for(;e;)t?t=!1:i(l)||(v=W(v,",")),e=c();e||(v=V(v,",")),v="[\n".concat(v,"\n]")}}else t&&(v=V(v,","));for(;C.charCodeAt(g)===d||93===C.charCodeAt(g);)g++,b();if(g>=C.length)return v;throw new y("Unexpected character ".concat(JSON.stringify(C[g])),g);function c(){b();var t=(()=>{if(123!==C.charCodeAt(g))return!1;{v+="{",g++,b(),p(l)&&b();let e=!0;for(;g<C.length&&C.charCodeAt(g)!==d;){let t;if(e?(t=!0,e=!1):((t=i(l))||(v=W(v,",")),b()),a(),!(w()||f(!0))){C.charCodeAt(g)===d||123===C.charCodeAt(g)||93===C.charCodeAt(g)||91===C.charCodeAt(g)||void 0===C[g]?v=V(v,","):(()=>{throw new y("Object key expected",g)})();break}b();var r=i(58),n=g>=C.length,o=(r||(G(C[g])||n?v=W(v,":"):u()),c());o||(r||n?v+="null":u())}return C.charCodeAt(g)===d?(v+="}",g++):v=W(v,"}"),!0}})()||(()=>{if(91!==C.charCodeAt(g))return!1;{v+="[",g++,b(),p(l)&&b();let t=!0;for(;g<C.length&&93!==C.charCodeAt(g);){t?t=!1:i(l)||(v=W(v,",")),a();var e=c();if(!e){v=V(v,",");break}}return 93===C.charCodeAt(g)?(v+="]",g++):v=W(v,"]"),!0}})()||w()||(()=>{var t,e,r=g;if(45===C.charCodeAt(g)){if(g++,o())return h(r),!0;if(!U(C.charCodeAt(g)))return g=r,!1}for(;U(C.charCodeAt(g));)g++;if(46===C.charCodeAt(g)){if(g++,o())return h(r),!0;if(!U(C.charCodeAt(g)))return g=r,!1;for(;U(C.charCodeAt(g));)g++}if(101===C.charCodeAt(g)||69===C.charCodeAt(g)){if(g++,45!==C.charCodeAt(g)&&43!==C.charCodeAt(g)||g++,o())return h(r),!0;if(!U(C.charCodeAt(g)))return g=r,!1;for(;U(C.charCodeAt(g));)g++}if(o()){if(g>r)return t=C.slice(r,g),e=/^0\d/.test(t),v+=e?'"'.concat(t,'"'):t,!0}else g=r;return!1})()||e("true","true")||e("false","false")||e("null","null")||e("True","true")||e("False","false")||e("None","null")||f(!1)||(()=>{if("/"===C[g]){var t=g;for(g++;g<C.length&&("/"!==C[g]||"\\"===C[g-1]);)g++;return g++,v+='"'.concat(C.substring(t,g),'"'),!0}})();return b(),t}function b(t){var e=!(0<arguments.length&&void 0!==t)||t;g;let r=n(e);for(;r=(r=(()=>{if(47===C.charCodeAt(g)&&42===C.charCodeAt(g+1)){for(;g<C.length&&!((t,e)=>"*"===t[e]&&"/"===t[e+1])(C,g);)g++;g+=2}else{if(47!==C.charCodeAt(g)||47!==C.charCodeAt(g+1))return!1;for(;g<C.length&&C.charCodeAt(g)!==O;)g++}return!0})())&&n(e););g}function n(t){var e=t?H:rt;let r="";for(;;){var n=C.charCodeAt(g);if(e(n))r+=C[g];else{if(!((n=n)===s||n>=A&&n<=E||n===R||n===X||n===Y))break;r+=" "}g++}return 0<r.length&&(v+=r,!0)}function i(t){return C.charCodeAt(g)===t&&(v+=C[g],g++,!0)}function p(t){return C.charCodeAt(g)===t&&(g++,!0)}function a(){b(),46===C.charCodeAt(g)&&46===C.charCodeAt(g+1)&&46===C.charCodeAt(g+2)&&(g+=3,b(),p(l))}function w(t,e){var r,n,o=0<arguments.length&&void 0!==t&&t,c=1<arguments.length&&void 0!==e?e:-1;let i=92===C.charCodeAt(g);if(i&&(g++,i=!0),K(C.charCodeAt(g))){var a=M(C.charCodeAt(g))?M:Q(C.charCodeAt(g))?Q:P(C.charCodeAt(g))?P:L,f=g,h=v.length;let e='"';for(g++;;){if(g>=C.length)return u=x(g-1),!o&&F(C.charAt(u))?(g=f,v=v.substring(0,h),w(!0)):(e=W(e,'"'),v+=e,!0);if(g===c)return e=W(e,'"'),v+=e,!0;if(a(C.charCodeAt(g))){var u=g,d=e.length;if(e+='"',g++,v+=e,b(!1),o||g>=C.length||F(C.charAt(g))||K(C.charCodeAt(g))||U(C.charCodeAt(g)))return $(),!0;var l=x(u-1),s=C.charAt(l);if(","===s)return g=f,v=v.substring(0,h),w(!1,l);if(F(s))return g=f,v=v.substring(0,h),w(!0);v=v.substring(0,h),g=u+1,e="".concat(e.substring(0,d),"\\").concat(e.substring(d))}else{if(o&&D(C[g])){if(58===C.charCodeAt(g-1)&&q.test(C.substring(f+1,g+2)))for(;g<C.length&&B.test(C[g]);)e+=C[g],g++;return e=W(e,'"'),v+=e,$(),!0}if(92===C.charCodeAt(g)){l=C.charAt(g+1);if(void 0!==ot[l])e+=C.slice(g,g+2),g+=2;else if("u"===l){let t=2;for(;t<6&&((n=C.charCodeAt(g+t))>=m&&n<=z||n>=I&&n<=Z||n>=T&&n<=_);)t++;if(6===t)e+=C.slice(g,g+6),g+=6;else{if(!(g+t>=C.length))throw s=void 0,s=C.slice(g,g+6),new y('Invalid unicode character "'.concat(s,'"'),g);g=C.length}}else e+=l,g+=2}else{var d=C.charAt(g),A=C.charCodeAt(g);if(A===k&&92!==C.charCodeAt(g-1))e+="\\".concat(d);else if((r=A)===O||r===J||r===N||r===S||r===j)e+=nt[d];else{if(!(32<=(r=A)&&r<=1114111))throw A=void 0,A=d,new y("Invalid character ".concat(JSON.stringify(A)),g);e+=d}g++}}i&&p(92)}}return!1}function $(){let t=!1;for(b();43===C.charCodeAt(g);){t=!0,g++,b();var e=(v=V(v,'"',!0)).length,r=w();v=r?(r=v,e=e,n=1,r.substring(0,e)+r.substring(e+n)):W(v,'"')}var n;t}function e(t,e){return C.slice(g,g+t.length)===t&&(v+=e,g+=t.length,!0)}function f(t){var e=g;if(tt.test(C[g])){for(;g<C.length&&et.test(C[g]);)g++;let t=g;for(;H(C.charCodeAt(t));)t++;if("("===C[t])return g=t+1,c(),41===C.charCodeAt(g)&&(g++,59===C.charCodeAt(g))&&g++,!0}for(;g<C.length&&!D(C[g])&&!K(C.charCodeAt(g))&&(!t||58!==C.charCodeAt(g));)g++;if(58===C.charCodeAt(g-1)&&q.test(C.substring(e,g+2)))for(;g<C.length&&B.test(C[g]);)g++;if(g>e){for(;H(C.charCodeAt(g-1))&&0<g;)g--;e=C.slice(e,g);return v+="undefined"===e?"null":JSON.stringify(e),C.charCodeAt(g)===k&&g++,!0}}function x(t){let e=t;for(;0<e&&H(C.charCodeAt(e));)e--;return e}function o(){return g>=C.length||F(C[g])||H(C.charCodeAt(g))}function h(t){v+="".concat(C.slice(t,g),"0")}function u(){throw new y("Colon expected",g)}}}); |
{ | ||
"name": "jsonrepair", | ||
"version": "3.11.1", | ||
"version": "3.11.2", | ||
"description": "Repair broken JSON documents", | ||
@@ -70,11 +70,11 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/cli": "7.25.9", | ||
"@babel/cli": "7.26.4", | ||
"@babel/core": "7.26.0", | ||
"@babel/plugin-transform-typescript": "7.25.9", | ||
"@babel/plugin-transform-typescript": "7.26.3", | ||
"@babel/preset-env": "7.26.0", | ||
"@babel/preset-typescript": "7.26.0", | ||
"@biomejs/biome": "1.9.4", | ||
"@commitlint/cli": "19.6.0", | ||
"@commitlint/cli": "19.6.1", | ||
"@commitlint/config-conventional": "19.6.0", | ||
"@types/node": "22.10.1", | ||
"@types/node": "22.10.2", | ||
"benchmark": "2.1.4", | ||
@@ -85,3 +85,3 @@ "cpy-cli": "5.0.0", | ||
"npm-run-all": "4.1.5", | ||
"rollup": "4.28.0", | ||
"rollup": "4.28.1", | ||
"standard-version": "9.5.0", | ||
@@ -88,0 +88,0 @@ "ts-node": "10.9.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
538972
5023