Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonrepair

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonrepair - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

4

lib/cjs/index.js

@@ -8,3 +8,3 @@ "use strict";

enumerable: true,
get: function get() {
get: function () {
return _JSONRepairError.JSONRepairError;

@@ -15,3 +15,3 @@ }

enumerable: true,
get: function get() {
get: function () {
return _jsonrepair.jsonrepair;

@@ -18,0 +18,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

var _stringUtils = require("./stringUtils.js");
var controlCharacters = {
const controlCharacters = {
'\b': '\\b',

@@ -19,3 +19,3 @@ '\f': '\\f',

// map with all escape characters
var escapeCharacters = {
const escapeCharacters = {
'"': '"',

@@ -49,10 +49,10 @@ '\\': '\\',

function jsonrepair(text) {
var i = 0; // current index in text
var output = ''; // generated output
let i = 0; // current index in text
let output = ''; // generated output
var processed = parseValue();
const processed = parseValue();
if (!processed) {
throwUnexpectedEnd();
}
var processedComma = parseCharacter(_stringUtils.codeComma);
const processedComma = parseCharacter(_stringUtils.codeComma);
if (processedComma) {

@@ -80,3 +80,3 @@ parseWhitespaceAndSkipComments();

parseWhitespaceAndSkipComments();
var processed = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString();
const processed = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString();
parseWhitespaceAndSkipComments();

@@ -86,4 +86,4 @@ return processed;

function parseWhitespaceAndSkipComments() {
var start = i;
var changed = parseWhitespace();
const start = i;
let changed = parseWhitespace();
do {

@@ -98,4 +98,4 @@ changed = parseComment();

function parseWhitespace() {
var whitespace = '';
var normal;
let whitespace = '';
let normal;
while ((normal = (0, _stringUtils.isWhitespace)(text.charCodeAt(i))) || (0, _stringUtils.isSpecialWhitespace)(text.charCodeAt(i))) {

@@ -164,8 +164,8 @@ if (normal) {

parseWhitespaceAndSkipComments();
var initial = true;
let initial = true;
while (i < text.length && text.charCodeAt(i) !== _stringUtils.codeClosingBrace) {
var _processedComma = void 0;
let processedComma;
if (!initial) {
_processedComma = parseCharacter(_stringUtils.codeComma);
if (!_processedComma) {
processedComma = parseCharacter(_stringUtils.codeComma);
if (!processedComma) {
// repair missing comma

@@ -176,6 +176,6 @@ output = (0, _stringUtils.insertBeforeLastWhitespace)(output, ',');

} else {
_processedComma = true;
processedComma = true;
initial = false;
}
var processedKey = parseString() || parseUnquotedString();
const processedKey = parseString() || parseUnquotedString();
if (!processedKey) {

@@ -191,3 +191,3 @@ if (text.charCodeAt(i) === _stringUtils.codeClosingBrace || text.charCodeAt(i) === _stringUtils.codeOpeningBrace || text.charCodeAt(i) === _stringUtils.codeClosingBracket || text.charCodeAt(i) === _stringUtils.codeOpeningBracket || text[i] === undefined) {

parseWhitespaceAndSkipComments();
var processedColon = parseCharacter(_stringUtils.codeColon);
const processedColon = parseCharacter(_stringUtils.codeColon);
if (!processedColon) {

@@ -201,6 +201,7 @@ if ((0, _stringUtils.isStartOfValue)(text[i])) {

}
var processedValue = parseValue();
const processedValue = parseValue();
if (!processedValue) {
if (processedColon) {
throwObjectValueExpected();
// repair missing object value
output += 'null';
} else {

@@ -231,7 +232,7 @@ throwColonExpected();

parseWhitespaceAndSkipComments();
var initial = true;
let initial = true;
while (i < text.length && text.charCodeAt(i) !== _stringUtils.codeClosingBracket) {
if (!initial) {
var _processedComma2 = parseCharacter(_stringUtils.codeComma);
if (!_processedComma2) {
const processedComma = parseCharacter(_stringUtils.codeComma);
if (!processedComma) {
// repair missing comma

@@ -243,3 +244,3 @@ output = (0, _stringUtils.insertBeforeLastWhitespace)(output, ',');

}
var processedValue = parseValue();
const processedValue = parseValue();
if (!processedValue) {

@@ -269,9 +270,9 @@ // repair trailing comma

// repair NDJSON
var initial = true;
var processedValue = true;
let initial = true;
let processedValue = true;
while (processedValue) {
if (!initial) {
// parse optional comma, insert when missing
var _processedComma3 = parseCharacter(_stringUtils.codeComma);
if (!_processedComma3) {
const processedComma = parseCharacter(_stringUtils.codeComma);
if (!processedComma) {
// repair: add missing comma

@@ -300,3 +301,3 @@ output = (0, _stringUtils.insertBeforeLastWhitespace)(output, ',');

function parseString() {
var skipEscapeChars = text.charCodeAt(i) === _stringUtils.codeBackslash;
let skipEscapeChars = text.charCodeAt(i) === _stringUtils.codeBackslash;
if (skipEscapeChars) {

@@ -308,3 +309,3 @@ // repair: remove the first escape character

if ((0, _stringUtils.isQuote)(text.charCodeAt(i))) {
var isEndQuote = (0, _stringUtils.isSingleQuoteLike)(text.charCodeAt(i)) ? _stringUtils.isSingleQuoteLike : (0, _stringUtils.isDoubleQuote)(text.charCodeAt(i)) ? _stringUtils.isDoubleQuote // eslint-disable-line indent
const isEndQuote = (0, _stringUtils.isSingleQuoteLike)(text.charCodeAt(i)) ? _stringUtils.isSingleQuoteLike : (0, _stringUtils.isDoubleQuote)(text.charCodeAt(i)) ? _stringUtils.isDoubleQuote // eslint-disable-line indent
: _stringUtils.isDoubleQuoteLike; // eslint-disable-line indent

@@ -316,4 +317,4 @@

if (text.charCodeAt(i) === _stringUtils.codeBackslash) {
var char = text[i + 1];
var escapeChar = escapeCharacters[char];
const char = text[i + 1];
const escapeChar = escapeCharacters[char];
if (escapeChar !== undefined) {

@@ -335,17 +336,17 @@ output += text.slice(i, i + 2);

} else {
var _char = text[i];
var code = text.charCodeAt(i);
const char = text[i];
const code = text.charCodeAt(i);
if (code === _stringUtils.codeDoubleQuote && text.charCodeAt(i - 1) !== _stringUtils.codeBackslash) {
// repair unescaped double quote
output += '\\' + _char;
output += '\\' + char;
i++;
} else if ((0, _stringUtils.isControlCharacter)(code)) {
// unescaped control character
output += controlCharacters[_char];
output += controlCharacters[char];
i++;
} else {
if (!(0, _stringUtils.isValidStringCharacter)(code)) {
throwInvalidCharacter(_char);
throwInvalidCharacter(char);
}
output += _char;
output += char;
i++;

@@ -355,4 +356,4 @@ }

if (skipEscapeChars) {
var _processed = skipEscapeCharacter();
if (_processed) {
const processed = skipEscapeCharacter();
if (processed) {
// repair: skipped escape character (nothing to do)

@@ -382,3 +383,3 @@ }

function parseConcatenatedString() {
var processed = false;
let processed = false;
parseWhitespaceAndSkipComments();

@@ -392,3 +393,3 @@ while (text.charCodeAt(i) === _stringUtils.codePlus) {

output = (0, _stringUtils.stripLastOccurrence)(output, '"', true);
var start = output.length;
const start = output.length;
parseString();

@@ -406,3 +407,3 @@

function parseNumber() {
var start = i;
const start = i;
if (text.charCodeAt(i) === _stringUtils.codeMinus) {

@@ -475,3 +476,3 @@ i++;

// note that the symbol can end with whitespaces: we stop at the next delimiter
var start = i;
const start = i;
while (i < text.length && !(0, _stringUtils.isDelimiter)(text[i])) {

@@ -502,4 +503,4 @@ i++;

}
var symbol = text.slice(start, i);
output += JSON.stringify(symbol);
const symbol = text.slice(start, i);
output += symbol === 'undefined' ? 'null' : JSON.stringify(symbol);
return true;

@@ -511,3 +512,3 @@ }

if (!(0, _stringUtils.isDigit)(text.charCodeAt(i))) {
var numSoFar = text.slice(start, i);
const numSoFar = text.slice(start, i);
throw new _JSONRepairError.JSONRepairError("Invalid number '".concat(numSoFar, "', expecting a digit ").concat(got()), 2);

@@ -540,5 +541,2 @@ }

}
function throwObjectValueExpected() {
throw new _JSONRepairError.JSONRepairError('Object value expected', i);
}
function throwColonExpected() {

@@ -548,7 +546,7 @@ throw new _JSONRepairError.JSONRepairError('Colon expected', i);

function throwInvalidUnicodeCharacter(start) {
var end = start + 2;
let end = start + 2;
while (/\w/.test(text[end])) {
end++;
}
var chars = text.slice(start, end);
const chars = text.slice(start, end);
throw new _JSONRepairError.JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i);

@@ -555,0 +553,0 @@ }

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -8,30 +7,9 @@ value: true

exports.JSONRepairError = void 0;
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var JSONRepairError = /*#__PURE__*/function (_Error) {
_inherits(JSONRepairError, _Error);
var _super = _createSuper(JSONRepairError);
function JSONRepairError(message, position) {
var _this;
_classCallCheck(this, JSONRepairError);
_this = _super.call(this, message + ' at position ' + position);
_this.position = position;
return _this;
class JSONRepairError extends Error {
constructor(message, position) {
super(message + ' at position ' + position);
this.position = position;
}
return _createClass(JSONRepairError);
}( /*#__PURE__*/_wrapNativeSuper(Error));
}
exports.JSONRepairError = JSONRepairError;
//# sourceMappingURL=JSONRepairError.js.map

@@ -25,78 +25,78 @@ "use strict";

// TODO: sort the codes
var codeBackslash = 0x5c; // "\"
const codeBackslash = 0x5c; // "\"
exports.codeBackslash = codeBackslash;
var codeSlash = 0x2f; // "/"
const codeSlash = 0x2f; // "/"
exports.codeSlash = codeSlash;
var codeAsterisk = 0x2a; // "*"
const codeAsterisk = 0x2a; // "*"
exports.codeAsterisk = codeAsterisk;
var codeOpeningBrace = 0x7b; // "{"
const codeOpeningBrace = 0x7b; // "{"
exports.codeOpeningBrace = codeOpeningBrace;
var codeClosingBrace = 0x7d; // "}"
const codeClosingBrace = 0x7d; // "}"
exports.codeClosingBrace = codeClosingBrace;
var codeOpeningBracket = 0x5b; // "["
const codeOpeningBracket = 0x5b; // "["
exports.codeOpeningBracket = codeOpeningBracket;
var codeClosingBracket = 0x5d; // "]"
const codeClosingBracket = 0x5d; // "]"
exports.codeClosingBracket = codeClosingBracket;
var codeOpenParenthesis = 0x28; // "("
const codeOpenParenthesis = 0x28; // "("
exports.codeOpenParenthesis = codeOpenParenthesis;
var codeCloseParenthesis = 0x29; // ")"
const codeCloseParenthesis = 0x29; // ")"
exports.codeCloseParenthesis = codeCloseParenthesis;
var codeSpace = 0x20; // " "
const codeSpace = 0x20; // " "
exports.codeSpace = codeSpace;
var codeNewline = 0xa; // "\n"
const codeNewline = 0xa; // "\n"
exports.codeNewline = codeNewline;
var codeTab = 0x9; // "\t"
const codeTab = 0x9; // "\t"
exports.codeTab = codeTab;
var codeReturn = 0xd; // "\r"
const codeReturn = 0xd; // "\r"
exports.codeReturn = codeReturn;
var codeBackspace = 0x08; // "\b"
const codeBackspace = 0x08; // "\b"
exports.codeBackspace = codeBackspace;
var codeFormFeed = 0x0c; // "\f"
const codeFormFeed = 0x0c; // "\f"
exports.codeFormFeed = codeFormFeed;
var codeDoubleQuote = 0x0022; // "
const codeDoubleQuote = 0x0022; // "
exports.codeDoubleQuote = codeDoubleQuote;
var codePlus = 0x2b; // "+"
const codePlus = 0x2b; // "+"
exports.codePlus = codePlus;
var codeMinus = 0x2d; // "-"
const codeMinus = 0x2d; // "-"
exports.codeMinus = codeMinus;
var codeQuote = 0x27; // "'"
const codeQuote = 0x27; // "'"
exports.codeQuote = codeQuote;
var codeZero = 0x30;
const codeZero = 0x30;
exports.codeZero = codeZero;
var codeOne = 0x31;
const codeOne = 0x31;
exports.codeOne = codeOne;
var codeNine = 0x39;
const codeNine = 0x39;
exports.codeNine = codeNine;
var codeComma = 0x2c; // ","
const codeComma = 0x2c; // ","
exports.codeComma = codeComma;
var codeDot = 0x2e; // "." (dot, period)
const codeDot = 0x2e; // "." (dot, period)
exports.codeDot = codeDot;
var codeColon = 0x3a; // ":"
const codeColon = 0x3a; // ":"
exports.codeColon = codeColon;
var codeSemicolon = 0x3b; // ";"
const codeSemicolon = 0x3b; // ";"
exports.codeSemicolon = codeSemicolon;
var codeUppercaseA = 0x41; // "A"
const codeUppercaseA = 0x41; // "A"
exports.codeUppercaseA = codeUppercaseA;
var codeLowercaseA = 0x61; // "a"
const codeLowercaseA = 0x61; // "a"
exports.codeLowercaseA = codeLowercaseA;
var codeUppercaseE = 0x45; // "E"
const codeUppercaseE = 0x45; // "E"
exports.codeUppercaseE = codeUppercaseE;
var codeLowercaseE = 0x65; // "e"
const codeLowercaseE = 0x65; // "e"
exports.codeLowercaseE = codeLowercaseE;
var codeUppercaseF = 0x46; // "F"
const codeUppercaseF = 0x46; // "F"
exports.codeUppercaseF = codeUppercaseF;
var codeLowercaseF = 0x66; // "f"
const codeLowercaseF = 0x66; // "f"
exports.codeLowercaseF = codeLowercaseF;
var codeNonBreakingSpace = 0xa0;
var codeEnQuad = 0x2000;
var codeHairSpace = 0x200a;
var codeNarrowNoBreakSpace = 0x202f;
var codeMediumMathematicalSpace = 0x205f;
var codeIdeographicSpace = 0x3000;
var codeDoubleQuoteLeft = 0x201c; // “
var codeDoubleQuoteRight = 0x201d; // ”
var codeQuoteLeft = 0x2018; // ‘
var codeQuoteRight = 0x2019; // ’
var codeGraveAccent = 0x0060; // `
var codeAcuteAccent = 0x00b4; // ´
const codeNonBreakingSpace = 0xa0;
const codeEnQuad = 0x2000;
const codeHairSpace = 0x200a;
const codeNarrowNoBreakSpace = 0x202f;
const codeMediumMathematicalSpace = 0x205f;
const codeIdeographicSpace = 0x3000;
const codeDoubleQuoteLeft = 0x201c; // “
const codeDoubleQuoteRight = 0x201d; // ”
const codeQuoteLeft = 0x2018; // ‘
const codeQuoteRight = 0x2019; // ’
const codeGraveAccent = 0x0060; // `
const codeAcuteAccent = 0x00b4; // ´

@@ -118,3 +118,3 @@ function isHex(code) {

}
var regexDelimiter = /^[,:[\]{}()\n]$/;
const regexDelimiter = /^[,:[\]{}()\n]$/;
function isStartOfValue(char) {

@@ -125,3 +125,3 @@ return regexStartOfValue.test(char) || char && isQuote(char.charCodeAt(0));

// alpha, number, minus, or opening bracket or brace
var regexStartOfValue = /^[[{\w-]$/;
const regexStartOfValue = /^[[{\w-]$/;
function isControlCharacter(code) {

@@ -185,8 +185,8 @@ return code === codeNewline || code === codeReturn || code === codeTab || code === codeBackspace || code === codeFormFeed;

function stripLastOccurrence(text, textToStrip) {
var stripRemainingText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var index = text.lastIndexOf(textToStrip);
let stripRemainingText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
const index = text.lastIndexOf(textToStrip);
return index !== -1 ? text.substring(0, index) + (stripRemainingText ? '' : text.substring(index + 1)) : text;
}
function insertBeforeLastWhitespace(text, textToInsert) {
var index = text.length;
let index = text.length;
if (!isWhitespace(text.charCodeAt(index - 1))) {

@@ -193,0 +193,0 @@ // no trailing whitespaces

import { JSONRepairError } from './JSONRepairError.js';
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codeOpenParenthesis, codePlus, codeSemicolon, codeSlash, codeUppercaseE, codeZero, endsWithCommaOrNewline, insertBeforeLastWhitespace, isControlCharacter, isDelimiter, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isNonZeroDigit, isQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isValidStringCharacter, isWhitespace, removeAtIndex, stripLastOccurrence } from './stringUtils.js';
var controlCharacters = {
const controlCharacters = {
'\b': '\\b',

@@ -12,3 +12,3 @@ '\f': '\\f',

// map with all escape characters
var escapeCharacters = {
const escapeCharacters = {
'"': '"',

@@ -42,10 +42,10 @@ '\\': '\\',

export function jsonrepair(text) {
var i = 0; // current index in text
var output = ''; // generated output
let i = 0; // current index in text
let output = ''; // generated output
var processed = parseValue();
const processed = parseValue();
if (!processed) {
throwUnexpectedEnd();
}
var processedComma = parseCharacter(codeComma);
const processedComma = parseCharacter(codeComma);
if (processedComma) {

@@ -73,3 +73,3 @@ parseWhitespaceAndSkipComments();

parseWhitespaceAndSkipComments();
var processed = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString();
const processed = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString();
parseWhitespaceAndSkipComments();

@@ -79,4 +79,4 @@ return processed;

function parseWhitespaceAndSkipComments() {
var start = i;
var changed = parseWhitespace();
const start = i;
let changed = parseWhitespace();
do {

@@ -91,4 +91,4 @@ changed = parseComment();

function parseWhitespace() {
var whitespace = '';
var normal;
let whitespace = '';
let normal;
while ((normal = isWhitespace(text.charCodeAt(i))) || isSpecialWhitespace(text.charCodeAt(i))) {

@@ -157,8 +157,8 @@ if (normal) {

parseWhitespaceAndSkipComments();
var initial = true;
let initial = true;
while (i < text.length && text.charCodeAt(i) !== codeClosingBrace) {
var _processedComma = void 0;
let processedComma;
if (!initial) {
_processedComma = parseCharacter(codeComma);
if (!_processedComma) {
processedComma = parseCharacter(codeComma);
if (!processedComma) {
// repair missing comma

@@ -169,6 +169,6 @@ output = insertBeforeLastWhitespace(output, ',');

} else {
_processedComma = true;
processedComma = true;
initial = false;
}
var processedKey = parseString() || parseUnquotedString();
const processedKey = parseString() || parseUnquotedString();
if (!processedKey) {

@@ -184,3 +184,3 @@ if (text.charCodeAt(i) === codeClosingBrace || text.charCodeAt(i) === codeOpeningBrace || text.charCodeAt(i) === codeClosingBracket || text.charCodeAt(i) === codeOpeningBracket || text[i] === undefined) {

parseWhitespaceAndSkipComments();
var processedColon = parseCharacter(codeColon);
const processedColon = parseCharacter(codeColon);
if (!processedColon) {

@@ -194,6 +194,7 @@ if (isStartOfValue(text[i])) {

}
var processedValue = parseValue();
const processedValue = parseValue();
if (!processedValue) {
if (processedColon) {
throwObjectValueExpected();
// repair missing object value
output += 'null';
} else {

@@ -224,7 +225,7 @@ throwColonExpected();

parseWhitespaceAndSkipComments();
var initial = true;
let initial = true;
while (i < text.length && text.charCodeAt(i) !== codeClosingBracket) {
if (!initial) {
var _processedComma2 = parseCharacter(codeComma);
if (!_processedComma2) {
const processedComma = parseCharacter(codeComma);
if (!processedComma) {
// repair missing comma

@@ -236,3 +237,3 @@ output = insertBeforeLastWhitespace(output, ',');

}
var processedValue = parseValue();
const processedValue = parseValue();
if (!processedValue) {

@@ -262,9 +263,9 @@ // repair trailing comma

// repair NDJSON
var initial = true;
var processedValue = true;
let initial = true;
let processedValue = true;
while (processedValue) {
if (!initial) {
// parse optional comma, insert when missing
var _processedComma3 = parseCharacter(codeComma);
if (!_processedComma3) {
const processedComma = parseCharacter(codeComma);
if (!processedComma) {
// repair: add missing comma

@@ -293,3 +294,3 @@ output = insertBeforeLastWhitespace(output, ',');

function parseString() {
var skipEscapeChars = text.charCodeAt(i) === codeBackslash;
let skipEscapeChars = text.charCodeAt(i) === codeBackslash;
if (skipEscapeChars) {

@@ -301,3 +302,3 @@ // repair: remove the first escape character

if (isQuote(text.charCodeAt(i))) {
var isEndQuote = isSingleQuoteLike(text.charCodeAt(i)) ? isSingleQuoteLike : isDoubleQuote(text.charCodeAt(i)) ? isDoubleQuote // eslint-disable-line indent
const isEndQuote = isSingleQuoteLike(text.charCodeAt(i)) ? isSingleQuoteLike : isDoubleQuote(text.charCodeAt(i)) ? isDoubleQuote // eslint-disable-line indent
: isDoubleQuoteLike; // eslint-disable-line indent

@@ -309,4 +310,4 @@

if (text.charCodeAt(i) === codeBackslash) {
var char = text[i + 1];
var escapeChar = escapeCharacters[char];
const char = text[i + 1];
const escapeChar = escapeCharacters[char];
if (escapeChar !== undefined) {

@@ -328,17 +329,17 @@ output += text.slice(i, i + 2);

} else {
var _char = text[i];
var code = text.charCodeAt(i);
const char = text[i];
const code = text.charCodeAt(i);
if (code === codeDoubleQuote && text.charCodeAt(i - 1) !== codeBackslash) {
// repair unescaped double quote
output += '\\' + _char;
output += '\\' + char;
i++;
} else if (isControlCharacter(code)) {
// unescaped control character
output += controlCharacters[_char];
output += controlCharacters[char];
i++;
} else {
if (!isValidStringCharacter(code)) {
throwInvalidCharacter(_char);
throwInvalidCharacter(char);
}
output += _char;
output += char;
i++;

@@ -348,4 +349,4 @@ }

if (skipEscapeChars) {
var _processed = skipEscapeCharacter();
if (_processed) {
const processed = skipEscapeCharacter();
if (processed) {
// repair: skipped escape character (nothing to do)

@@ -375,3 +376,3 @@ }

function parseConcatenatedString() {
var processed = false;
let processed = false;
parseWhitespaceAndSkipComments();

@@ -385,3 +386,3 @@ while (text.charCodeAt(i) === codePlus) {

output = stripLastOccurrence(output, '"', true);
var start = output.length;
const start = output.length;
parseString();

@@ -399,3 +400,3 @@

function parseNumber() {
var start = i;
const start = i;
if (text.charCodeAt(i) === codeMinus) {

@@ -468,3 +469,3 @@ i++;

// note that the symbol can end with whitespaces: we stop at the next delimiter
var start = i;
const start = i;
while (i < text.length && !isDelimiter(text[i])) {

@@ -495,4 +496,4 @@ i++;

}
var symbol = text.slice(start, i);
output += JSON.stringify(symbol);
const symbol = text.slice(start, i);
output += symbol === 'undefined' ? 'null' : JSON.stringify(symbol);
return true;

@@ -504,3 +505,3 @@ }

if (!isDigit(text.charCodeAt(i))) {
var numSoFar = text.slice(start, i);
const numSoFar = text.slice(start, i);
throw new JSONRepairError("Invalid number '".concat(numSoFar, "', expecting a digit ").concat(got()), 2);

@@ -533,5 +534,2 @@ }

}
function throwObjectValueExpected() {
throw new JSONRepairError('Object value expected', i);
}
function throwColonExpected() {

@@ -541,7 +539,7 @@ throw new JSONRepairError('Colon expected', i);

function throwInvalidUnicodeCharacter(start) {
var end = start + 2;
let end = start + 2;
while (/\w/.test(text[end])) {
end++;
}
var chars = text.slice(start, end);
const chars = text.slice(start, end);
throw new JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i);

@@ -548,0 +546,0 @@ }

@@ -1,29 +0,7 @@

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
export var JSONRepairError = /*#__PURE__*/function (_Error) {
_inherits(JSONRepairError, _Error);
var _super = _createSuper(JSONRepairError);
function JSONRepairError(message, position) {
var _this;
_classCallCheck(this, JSONRepairError);
_this = _super.call(this, message + ' at position ' + position);
_this.position = position;
return _this;
export class JSONRepairError extends Error {
constructor(message, position) {
super(message + ' at position ' + position);
this.position = position;
}
return _createClass(JSONRepairError);
}( /*#__PURE__*/_wrapNativeSuper(Error));
}
//# sourceMappingURL=JSONRepairError.js.map
// TODO: sort the codes
export var codeBackslash = 0x5c; // "\"
export var codeSlash = 0x2f; // "/"
export var codeAsterisk = 0x2a; // "*"
export var codeOpeningBrace = 0x7b; // "{"
export var codeClosingBrace = 0x7d; // "}"
export var codeOpeningBracket = 0x5b; // "["
export var codeClosingBracket = 0x5d; // "]"
export var codeOpenParenthesis = 0x28; // "("
export var codeCloseParenthesis = 0x29; // ")"
export var codeSpace = 0x20; // " "
export var codeNewline = 0xa; // "\n"
export var codeTab = 0x9; // "\t"
export var codeReturn = 0xd; // "\r"
export var codeBackspace = 0x08; // "\b"
export var codeFormFeed = 0x0c; // "\f"
export var codeDoubleQuote = 0x0022; // "
export var codePlus = 0x2b; // "+"
export var codeMinus = 0x2d; // "-"
export var codeQuote = 0x27; // "'"
export var codeZero = 0x30;
export var codeOne = 0x31;
export var codeNine = 0x39;
export var codeComma = 0x2c; // ","
export var codeDot = 0x2e; // "." (dot, period)
export var codeColon = 0x3a; // ":"
export var codeSemicolon = 0x3b; // ";"
export var codeUppercaseA = 0x41; // "A"
export var codeLowercaseA = 0x61; // "a"
export var codeUppercaseE = 0x45; // "E"
export var codeLowercaseE = 0x65; // "e"
export var codeUppercaseF = 0x46; // "F"
export var codeLowercaseF = 0x66; // "f"
var codeNonBreakingSpace = 0xa0;
var codeEnQuad = 0x2000;
var codeHairSpace = 0x200a;
var codeNarrowNoBreakSpace = 0x202f;
var codeMediumMathematicalSpace = 0x205f;
var codeIdeographicSpace = 0x3000;
var codeDoubleQuoteLeft = 0x201c; // “
var codeDoubleQuoteRight = 0x201d; // ”
var codeQuoteLeft = 0x2018; // ‘
var codeQuoteRight = 0x2019; // ’
var codeGraveAccent = 0x0060; // `
var codeAcuteAccent = 0x00b4; // ´
export const codeBackslash = 0x5c; // "\"
export const codeSlash = 0x2f; // "/"
export const codeAsterisk = 0x2a; // "*"
export const codeOpeningBrace = 0x7b; // "{"
export const codeClosingBrace = 0x7d; // "}"
export const codeOpeningBracket = 0x5b; // "["
export const codeClosingBracket = 0x5d; // "]"
export const codeOpenParenthesis = 0x28; // "("
export const codeCloseParenthesis = 0x29; // ")"
export const codeSpace = 0x20; // " "
export const codeNewline = 0xa; // "\n"
export const codeTab = 0x9; // "\t"
export const codeReturn = 0xd; // "\r"
export const codeBackspace = 0x08; // "\b"
export const codeFormFeed = 0x0c; // "\f"
export const codeDoubleQuote = 0x0022; // "
export const codePlus = 0x2b; // "+"
export const codeMinus = 0x2d; // "-"
export const codeQuote = 0x27; // "'"
export const codeZero = 0x30;
export const codeOne = 0x31;
export const codeNine = 0x39;
export const codeComma = 0x2c; // ","
export const codeDot = 0x2e; // "." (dot, period)
export const codeColon = 0x3a; // ":"
export const codeSemicolon = 0x3b; // ";"
export const codeUppercaseA = 0x41; // "A"
export const codeLowercaseA = 0x61; // "a"
export const codeUppercaseE = 0x45; // "E"
export const codeLowercaseE = 0x65; // "e"
export const codeUppercaseF = 0x46; // "F"
export const codeLowercaseF = 0x66; // "f"
const codeNonBreakingSpace = 0xa0;
const codeEnQuad = 0x2000;
const codeHairSpace = 0x200a;
const codeNarrowNoBreakSpace = 0x202f;
const codeMediumMathematicalSpace = 0x205f;
const codeIdeographicSpace = 0x3000;
const codeDoubleQuoteLeft = 0x201c; // “
const codeDoubleQuoteRight = 0x201d; // ”
const codeQuoteLeft = 0x2018; // ‘
const codeQuoteRight = 0x2019; // ’
const codeGraveAccent = 0x0060; // `
const codeAcuteAccent = 0x00b4; // ´

@@ -62,3 +62,3 @@ export function isHex(code) {

}
var regexDelimiter = /^[,:[\]{}()\n]$/;
const regexDelimiter = /^[,:[\]{}()\n]$/;
export function isStartOfValue(char) {

@@ -69,3 +69,3 @@ return regexStartOfValue.test(char) || char && isQuote(char.charCodeAt(0));

// alpha, number, minus, or opening bracket or brace
var regexStartOfValue = /^[[{\w-]$/;
const regexStartOfValue = /^[[{\w-]$/;
export function isControlCharacter(code) {

@@ -129,8 +129,8 @@ return code === codeNewline || code === codeReturn || code === codeTab || code === codeBackspace || code === codeFormFeed;

export function stripLastOccurrence(text, textToStrip) {
var stripRemainingText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var index = text.lastIndexOf(textToStrip);
let stripRemainingText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
const index = text.lastIndexOf(textToStrip);
return index !== -1 ? text.substring(0, index) + (stripRemainingText ? '' : text.substring(index + 1)) : text;
}
export function insertBeforeLastWhitespace(text, textToInsert) {
var index = text.length;
let index = text.length;
if (!isWhitespace(text.charCodeAt(index - 1))) {

@@ -137,0 +137,0 @@ // no trailing whitespaces

@@ -7,76 +7,54 @@ (function (global, factory) {

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var JSONRepairError = /*#__PURE__*/function (_Error) {
_inherits(JSONRepairError, _Error);
var _super = _createSuper(JSONRepairError);
function JSONRepairError(message, position) {
var _this;
_classCallCheck(this, JSONRepairError);
_this = _super.call(this, message + ' at position ' + position);
_this.position = position;
return _this;
class JSONRepairError extends Error {
constructor(message, position) {
super(message + ' at position ' + position);
this.position = position;
}
return _createClass(JSONRepairError);
}( /*#__PURE__*/_wrapNativeSuper(Error));
}
// TODO: sort the codes
var codeBackslash = 0x5c; // "\"
var codeSlash = 0x2f; // "/"
var codeAsterisk = 0x2a; // "*"
var codeOpeningBrace = 0x7b; // "{"
var codeClosingBrace = 0x7d; // "}"
var codeOpeningBracket = 0x5b; // "["
var codeClosingBracket = 0x5d; // "]"
var codeOpenParenthesis = 0x28; // "("
var codeCloseParenthesis = 0x29; // ")"
var codeSpace = 0x20; // " "
var codeNewline = 0xa; // "\n"
var codeTab = 0x9; // "\t"
var codeReturn = 0xd; // "\r"
var codeBackspace = 0x08; // "\b"
var codeFormFeed = 0x0c; // "\f"
var codeDoubleQuote = 0x0022; // "
var codePlus = 0x2b; // "+"
var codeMinus = 0x2d; // "-"
var codeQuote = 0x27; // "'"
var codeZero = 0x30;
var codeOne = 0x31;
var codeNine = 0x39;
var codeComma = 0x2c; // ","
var codeDot = 0x2e; // "." (dot, period)
var codeColon = 0x3a; // ":"
var codeSemicolon = 0x3b; // ";"
var codeUppercaseA = 0x41; // "A"
var codeLowercaseA = 0x61; // "a"
var codeUppercaseE = 0x45; // "E"
var codeLowercaseE = 0x65; // "e"
var codeUppercaseF = 0x46; // "F"
var codeLowercaseF = 0x66; // "f"
var codeNonBreakingSpace = 0xa0;
var codeEnQuad = 0x2000;
var codeHairSpace = 0x200a;
var codeNarrowNoBreakSpace = 0x202f;
var codeMediumMathematicalSpace = 0x205f;
var codeIdeographicSpace = 0x3000;
var codeDoubleQuoteLeft = 0x201c; // “
var codeDoubleQuoteRight = 0x201d; // ”
var codeQuoteLeft = 0x2018; // ‘
var codeQuoteRight = 0x2019; // ’
var codeGraveAccent = 0x0060; // `
var codeAcuteAccent = 0x00b4; // ´
const codeBackslash = 0x5c; // "\"
const codeSlash = 0x2f; // "/"
const codeAsterisk = 0x2a; // "*"
const codeOpeningBrace = 0x7b; // "{"
const codeClosingBrace = 0x7d; // "}"
const codeOpeningBracket = 0x5b; // "["
const codeClosingBracket = 0x5d; // "]"
const codeOpenParenthesis = 0x28; // "("
const codeCloseParenthesis = 0x29; // ")"
const codeSpace = 0x20; // " "
const codeNewline = 0xa; // "\n"
const codeTab = 0x9; // "\t"
const codeReturn = 0xd; // "\r"
const codeBackspace = 0x08; // "\b"
const codeFormFeed = 0x0c; // "\f"
const codeDoubleQuote = 0x0022; // "
const codePlus = 0x2b; // "+"
const codeMinus = 0x2d; // "-"
const codeQuote = 0x27; // "'"
const codeZero = 0x30;
const codeOne = 0x31;
const codeNine = 0x39;
const codeComma = 0x2c; // ","
const codeDot = 0x2e; // "." (dot, period)
const codeColon = 0x3a; // ":"
const codeSemicolon = 0x3b; // ";"
const codeUppercaseA = 0x41; // "A"
const codeLowercaseA = 0x61; // "a"
const codeUppercaseE = 0x45; // "E"
const codeLowercaseE = 0x65; // "e"
const codeUppercaseF = 0x46; // "F"
const codeLowercaseF = 0x66; // "f"
const codeNonBreakingSpace = 0xa0;
const codeEnQuad = 0x2000;
const codeHairSpace = 0x200a;
const codeNarrowNoBreakSpace = 0x202f;
const codeMediumMathematicalSpace = 0x205f;
const codeIdeographicSpace = 0x3000;
const codeDoubleQuoteLeft = 0x201c; // “
const codeDoubleQuoteRight = 0x201d; // ”
const codeQuoteLeft = 0x2018; // ‘
const codeQuoteRight = 0x2019; // ’
const codeGraveAccent = 0x0060; // `
const codeAcuteAccent = 0x00b4; // ´

@@ -98,3 +76,3 @@ function isHex(code) {

}
var regexDelimiter = /^[,:[\]{}()\n]$/;
const regexDelimiter = /^[,:[\]{}()\n]$/;
function isStartOfValue(char) {

@@ -105,3 +83,3 @@ return regexStartOfValue.test(char) || char && isQuote(char.charCodeAt(0));

// alpha, number, minus, or opening bracket or brace
var regexStartOfValue = /^[[{\w-]$/;
const regexStartOfValue = /^[[{\w-]$/;
function isControlCharacter(code) {

@@ -165,8 +143,8 @@ return code === codeNewline || code === codeReturn || code === codeTab || code === codeBackspace || code === codeFormFeed;

function stripLastOccurrence(text, textToStrip) {
var stripRemainingText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var index = text.lastIndexOf(textToStrip);
let stripRemainingText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
const index = text.lastIndexOf(textToStrip);
return index !== -1 ? text.substring(0, index) + (stripRemainingText ? '' : text.substring(index + 1)) : text;
}
function insertBeforeLastWhitespace(text, textToInsert) {
var index = text.length;
let index = text.length;
if (!isWhitespace(text.charCodeAt(index - 1))) {

@@ -192,3 +170,3 @@ // no trailing whitespaces

var controlCharacters = {
const controlCharacters = {
'\b': '\\b',

@@ -202,3 +180,3 @@ '\f': '\\f',

// map with all escape characters
var escapeCharacters = {
const escapeCharacters = {
'"': '"',

@@ -232,10 +210,10 @@ '\\': '\\',

function jsonrepair(text) {
var i = 0; // current index in text
var output = ''; // generated output
let i = 0; // current index in text
let output = ''; // generated output
var processed = parseValue();
const processed = parseValue();
if (!processed) {
throwUnexpectedEnd();
}
var processedComma = parseCharacter(codeComma);
const processedComma = parseCharacter(codeComma);
if (processedComma) {

@@ -263,3 +241,3 @@ parseWhitespaceAndSkipComments();

parseWhitespaceAndSkipComments();
var processed = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString();
const processed = parseObject() || parseArray() || parseString() || parseNumber() || parseKeywords() || parseUnquotedString();
parseWhitespaceAndSkipComments();

@@ -269,4 +247,4 @@ return processed;

function parseWhitespaceAndSkipComments() {
var start = i;
var changed = parseWhitespace();
const start = i;
let changed = parseWhitespace();
do {

@@ -281,4 +259,4 @@ changed = parseComment();

function parseWhitespace() {
var whitespace = '';
var normal;
let whitespace = '';
let normal;
while ((normal = isWhitespace(text.charCodeAt(i))) || isSpecialWhitespace(text.charCodeAt(i))) {

@@ -347,8 +325,8 @@ if (normal) {

parseWhitespaceAndSkipComments();
var initial = true;
let initial = true;
while (i < text.length && text.charCodeAt(i) !== codeClosingBrace) {
var _processedComma = void 0;
let processedComma;
if (!initial) {
_processedComma = parseCharacter(codeComma);
if (!_processedComma) {
processedComma = parseCharacter(codeComma);
if (!processedComma) {
// repair missing comma

@@ -359,6 +337,6 @@ output = insertBeforeLastWhitespace(output, ',');

} else {
_processedComma = true;
processedComma = true;
initial = false;
}
var processedKey = parseString() || parseUnquotedString();
const processedKey = parseString() || parseUnquotedString();
if (!processedKey) {

@@ -374,3 +352,3 @@ if (text.charCodeAt(i) === codeClosingBrace || text.charCodeAt(i) === codeOpeningBrace || text.charCodeAt(i) === codeClosingBracket || text.charCodeAt(i) === codeOpeningBracket || text[i] === undefined) {

parseWhitespaceAndSkipComments();
var processedColon = parseCharacter(codeColon);
const processedColon = parseCharacter(codeColon);
if (!processedColon) {

@@ -384,6 +362,7 @@ if (isStartOfValue(text[i])) {

}
var processedValue = parseValue();
const processedValue = parseValue();
if (!processedValue) {
if (processedColon) {
throwObjectValueExpected();
// repair missing object value
output += 'null';
} else {

@@ -414,7 +393,7 @@ throwColonExpected();

parseWhitespaceAndSkipComments();
var initial = true;
let initial = true;
while (i < text.length && text.charCodeAt(i) !== codeClosingBracket) {
if (!initial) {
var _processedComma2 = parseCharacter(codeComma);
if (!_processedComma2) {
const processedComma = parseCharacter(codeComma);
if (!processedComma) {
// repair missing comma

@@ -426,3 +405,3 @@ output = insertBeforeLastWhitespace(output, ',');

}
var processedValue = parseValue();
const processedValue = parseValue();
if (!processedValue) {

@@ -452,9 +431,9 @@ // repair trailing comma

// repair NDJSON
var initial = true;
var processedValue = true;
let initial = true;
let processedValue = true;
while (processedValue) {
if (!initial) {
// parse optional comma, insert when missing
var _processedComma3 = parseCharacter(codeComma);
if (!_processedComma3) {
const processedComma = parseCharacter(codeComma);
if (!processedComma) {
// repair: add missing comma

@@ -483,3 +462,3 @@ output = insertBeforeLastWhitespace(output, ',');

function parseString() {
var skipEscapeChars = text.charCodeAt(i) === codeBackslash;
let skipEscapeChars = text.charCodeAt(i) === codeBackslash;
if (skipEscapeChars) {

@@ -491,3 +470,3 @@ // repair: remove the first escape character

if (isQuote(text.charCodeAt(i))) {
var isEndQuote = isSingleQuoteLike(text.charCodeAt(i)) ? isSingleQuoteLike : isDoubleQuote(text.charCodeAt(i)) ? isDoubleQuote // eslint-disable-line indent
const isEndQuote = isSingleQuoteLike(text.charCodeAt(i)) ? isSingleQuoteLike : isDoubleQuote(text.charCodeAt(i)) ? isDoubleQuote // eslint-disable-line indent
: isDoubleQuoteLike; // eslint-disable-line indent

@@ -499,4 +478,4 @@

if (text.charCodeAt(i) === codeBackslash) {
var char = text[i + 1];
var escapeChar = escapeCharacters[char];
const char = text[i + 1];
const escapeChar = escapeCharacters[char];
if (escapeChar !== undefined) {

@@ -518,17 +497,17 @@ output += text.slice(i, i + 2);

} else {
var _char = text[i];
var code = text.charCodeAt(i);
const char = text[i];
const code = text.charCodeAt(i);
if (code === codeDoubleQuote && text.charCodeAt(i - 1) !== codeBackslash) {
// repair unescaped double quote
output += '\\' + _char;
output += '\\' + char;
i++;
} else if (isControlCharacter(code)) {
// unescaped control character
output += controlCharacters[_char];
output += controlCharacters[char];
i++;
} else {
if (!isValidStringCharacter(code)) {
throwInvalidCharacter(_char);
throwInvalidCharacter(char);
}
output += _char;
output += char;
i++;

@@ -559,3 +538,3 @@ }

function parseConcatenatedString() {
var processed = false;
let processed = false;
parseWhitespaceAndSkipComments();

@@ -569,3 +548,3 @@ while (text.charCodeAt(i) === codePlus) {

output = stripLastOccurrence(output, '"', true);
var start = output.length;
const start = output.length;
parseString();

@@ -583,3 +562,3 @@

function parseNumber() {
var start = i;
const start = i;
if (text.charCodeAt(i) === codeMinus) {

@@ -652,3 +631,3 @@ i++;

// note that the symbol can end with whitespaces: we stop at the next delimiter
var start = i;
const start = i;
while (i < text.length && !isDelimiter(text[i])) {

@@ -679,4 +658,4 @@ i++;

}
var symbol = text.slice(start, i);
output += JSON.stringify(symbol);
const symbol = text.slice(start, i);
output += symbol === 'undefined' ? 'null' : JSON.stringify(symbol);
return true;

@@ -688,3 +667,3 @@ }

if (!isDigit(text.charCodeAt(i))) {
var numSoFar = text.slice(start, i);
const numSoFar = text.slice(start, i);
throw new JSONRepairError("Invalid number '".concat(numSoFar, "', expecting a digit ").concat(got()), 2);

@@ -717,5 +696,2 @@ }

}
function throwObjectValueExpected() {
throw new JSONRepairError('Object value expected', i);
}
function throwColonExpected() {

@@ -725,7 +701,7 @@ throw new JSONRepairError('Colon expected', i);

function throwInvalidUnicodeCharacter(start) {
var end = start + 2;
let end = start + 2;
while (/\w/.test(text[end])) {
end++;
}
var chars = text.slice(start, end);
const chars = text.slice(start, end);
throw new JSONRepairError("Invalid unicode character \"".concat(chars, "\""), i);

@@ -732,0 +708,0 @@ }

@@ -1,1 +0,1 @@

!function(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){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==o(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===o(t)?t:String(t)}(n.key),n)}}function u(r){var n=i();return function(){var t,e=a(r),e=(t=n?(t=a(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function e(t){var r="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return n(t,arguments,a(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),f(e,t)}(t)}function n(t,e,r){return(n=i()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);e=new(Function.bind.apply(t,n));return r&&f(e,r.prototype),e}).apply(null,arguments)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function f(t,e){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var C=function(t){var e=i;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t);var r,n,o=u(i);function i(t,e){if(this instanceof i)return(t=o.call(this,t+" at position "+e)).position=e,t;throw new TypeError("Cannot call a class as a function")}return e=i,r&&c(e.prototype,r),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(e(Error)),r=32,A=10,v=9,g=13,w=8,O=12,m=34,l=39,j=48,S=49,x=57,h=65,d=97,s=70,p=102,P=160,B=8192,M=8202,U=8239,D=8287,q=12288,b=8220,y=8221,z=8216,G=8217,H=96,K=180;function R(t){return j<=t&&t<=x||h<=t&&t<=s||d<=t&&t<=p}function E(t){return j<=t&&t<=x}var L=/^[,:[\]{}()\n]$/;function T(t){return Q.test(t)||t&&N(t.charCodeAt(0))}var Q=/^[[{\w-]$/;function _(t){return t===r||t===A||t===v||t===g}function N(t){return J(t)||I(t)}function J(t){return t===m||t===b||t===y}function k(t){return t===m}function I(t){return t===l||t===z||t===G||t===H||t===K}function F(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 $(t,e){var r=t.length;if(!_(t.charCodeAt(r-1)))return t+e;for(;_(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}var V={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},W={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=C,t.jsonrepair=function(u){var f=0,a="";if(!n())throw new C("Unexpected end of json string",u.length);var t=i(44);if(t&&l(),T(u[f])&&/[,\n][ \t\r]*$/.test(a)){t||(a=$(a,","));for(var e=!0,r=!0;r;)e?e=!1:i(44)||(a=$(a,",")),r=n();r||(a=F(a,",")),a="[\n".concat(a,"\n]")}else t&&(a=F(a,","));if(f>=u.length)return a;throw new C("Unexpected character "+JSON.stringify(u[f]),f);function n(){l();var t=function(){if(123!==u.charCodeAt(f))return!1;a+="{",f++,l();var t=!0;for(;f<u.length&&125!==u.charCodeAt(f);){if(t?t=!!0:(i(44)||(a=$(a,",")),l()),!(d()||s())){125===u.charCodeAt(f)||123===u.charCodeAt(f)||93===u.charCodeAt(f)||91===u.charCodeAt(f)||void 0===u[f]?a=F(a,","):function(){throw new C("Object key expected",f)}();break}l();var e=i(58);e||(T(u[f])?a=$(a,":"):y()),n()||(e?function(){throw new C("Object value expected",f)}:y)()}125===u.charCodeAt(f)?(a+="}",f++):a=$(a,"}");return!0}()||function(){if(91!==u.charCodeAt(f))return!1;a+="[",f++,l();var t=!0;for(;f<u.length&&93!==u.charCodeAt(f);)if(t?t=!1:i(44)||(a=$(a,",")),!n()){a=F(a,",");break}93===u.charCodeAt(f)?(a+="]",f++):a=$(a,"]");return!0}()||d()||function(){var t=f;if(45===u.charCodeAt(f)&&(f++,b(t)))return!0;if(u.charCodeAt(f)===j)f++;else if(function(t){return S<=t&&t<=x}(u.charCodeAt(f)))for(f++;E(u.charCodeAt(f));)f++;if(46===u.charCodeAt(f)){if(f++,b(t))return!0;for(;E(u.charCodeAt(f));)f++}if(101===u.charCodeAt(f)||69===u.charCodeAt(f)){if(f++,45!==u.charCodeAt(f)&&43!==u.charCodeAt(f)||f++,b(t))return!0;for(;E(u.charCodeAt(f));)f++}if(t<f)return a+=u.slice(t,f),!0;return!1}()||c("true","true")||c("false","false")||c("null","null")||c("True","true")||c("False","false")||c("None","null")||s();return l(),t}function l(){for(o();function(){if(47===u.charCodeAt(f)&&42===u.charCodeAt(f+1)){for(;f<u.length&&!function(t,e){return"*"===t[e]&&"/"===t[e+1]}(u,f);)f++;f+=2}else{if(47!==u.charCodeAt(f)||47!==u.charCodeAt(f+1))return!1;for(;f<u.length&&u.charCodeAt(f)!==A;)f++}return!0}()&&o(););}function o(){for(var t,e,r="";(t=_(u.charCodeAt(f)))||(e=u.charCodeAt(f))===P||B<=e&&e<=M||e===U||e===D||e===q;)r+=t?u[f]:" ",f++;return 0<r.length&&(a+=r,!0)}function i(t){return u.charCodeAt(f)===t&&(a+=u[f],f++,!0)}function h(){92===u.charCodeAt(f)&&f++}function d(){var t,e=92===u.charCodeAt(f);if(e&&(f++,e=!0),N(u.charCodeAt(f))){var r=I(u.charCodeAt(f))?I:k(u.charCodeAt(f))?k:J;for(a+='"',f++;f<u.length&&!r(u.charCodeAt(f));){if(92===u.charCodeAt(f)){var n=u[f+1];if(void 0!==W[n])a+=u.slice(f,f+2),f+=2;else if("u"===n){if(!(R(u.charCodeAt(f+2))&&R(u.charCodeAt(f+3))&&R(u.charCodeAt(f+4))&&R(u.charCodeAt(f+5)))){i=o=void 0;for(var o=f,i=o+2;/\w/.test(u[i]);)i++;throw o=u.slice(o,i),new C('Invalid unicode character "'.concat(o,'"'),f)}a+=u.slice(f,f+6),f+=6}else a+=n,f+=2}else{o=u[f],n=u.charCodeAt(f);if(n===m&&92!==u.charCodeAt(f-1))a+="\\"+o;else if((t=n)===A||t===g||t===v||t===w||t===O)a+=V[o];else{if(!(32<=(t=n)&&t<=1114111))throw new C("Invalid character "+JSON.stringify(o),f);a+=o}f++}e&&h()}N(u.charCodeAt(f))?(u.charCodeAt(f),a+='"',f++):a+='"';for(l();43===u.charCodeAt(f);){f++,l();var c=(a=F(a,'"',!0)).length;d(),a=function(t,e,r){return t.substring(0,e)+t.substring(e+r)}(a,c,1)}return!0}return!1}function c(t,e){return u.slice(f,f+t.length)===t&&(a+=e,f+=t.length,!0)}function s(){for(var t,e=f;f<u.length&&(t=u[f],!(L.test(t)||t&&N(t.charCodeAt(0))));)f++;if(e<f){if(40===u.charCodeAt(f))f++,n(),41===u.charCodeAt(f)&&(f++,59===u.charCodeAt(f))&&f++;else{for(;_(u.charCodeAt(f-1))&&0<f;)f--;e=u.slice(e,f);a+=JSON.stringify(e)}return!0}}function p(t){if(!E(u.charCodeAt(f)))throw t=u.slice(t,f),new C("Invalid number '".concat(t,"', expecting a digit ").concat(u[f]?"but got '".concat(u[f],"'"):"but reached end of input"),2)}function b(t){if(f>=u.length)return a+=u.slice(t,f)+"0",1;p(t)}function y(){throw new C("Colon expected",f)}}});
!function(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){"use strict";class A extends Error{constructor(t,e){super(t+" at position "+e),this.position=e}}const e=32,g=10,v=9,b=13,p=8,w=12,x=34,r=39,y=48,O=49,N=57,n=65,o=97,c=70,i=102,J=160,S=8192,j=8202,I=8239,k=8287,m=12288,f=8220,a=8221,u=8216,d=8217,h=96,l=180;function T(t){return t>=y&&t<=N||t>=n&&t<=c||t>=o&&t<=i}function $(t){return t>=y&&t<=N}const G=/^[,:[\]{}()\n]$/;function E(t){return s.test(t)||t&&U(t.charCodeAt(0))}const s=/^[[{\w-]$/;function R(t){return t===e||t===g||t===v||t===b}function U(t){return F(t)||z(t)}function F(t){return t===x||t===f||t===a}function q(t){return t===x}function z(t){return t===r||t===u||t===d||t===h||t===l}function B(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 D(t,e){let r=t.length;if(!R(t.charCodeAt(r-1)))return t+e;for(;R(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}const H={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},K={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=A,t.jsonrepair=function(i){let f=0,a="";if(!o())throw new A("Unexpected end of json string",i.length);var t=c(44);if(t&&u(),E(i[f])&&/[,\n][ \t\r]*$/.test(a)){t||(a=D(a,","));{let t=!0,e=!0;for(;e;)t?t=!1:c(44)||(a=D(a,",")),e=o();e||(a=B(a,","));a="[\n".concat(a,"\n]")}}else t&&(a=B(a,","));if(f>=i.length)return a;throw new A("Unexpected character "+JSON.stringify(i[f]),f);function o(){u();var t=function(){if(123!==i.charCodeAt(f))return!1;{a+="{",f++,u();let e=!0;for(;f<i.length&&125!==i.charCodeAt(f);){let t;if(e?(t=!0,e=!1):((t=c(44))||(a=D(a,",")),u()),!(h()||l())){125===i.charCodeAt(f)||123===i.charCodeAt(f)||93===i.charCodeAt(f)||91===i.charCodeAt(f)||void 0===i[f]?a=B(a,","):function(){throw new A("Object key expected",f)}();break}u();var r=c(58),n=(r||(E(i[f])?a=D(a,":"):C()),o());n||(r?a+="null":C())}return 125===i.charCodeAt(f)?(a+="}",f++):a=D(a,"}"),!0}}()||function(){if(91!==i.charCodeAt(f))return!1;{a+="[",f++,u();let t=!0;for(;f<i.length&&93!==i.charCodeAt(f);){t?t=!1:c(44)||(a=D(a,","));var e=o();if(!e){a=B(a,",");break}}return 93===i.charCodeAt(f)?(a+="]",f++):a=D(a,"]"),!0}}()||h()||function(){var t=f;if(45===i.charCodeAt(f)&&(f++,s(t)))return!0;if(i.charCodeAt(f)===y)f++;else if(function(t){return t>=O&&t<=N}(i.charCodeAt(f)))for(f++;$(i.charCodeAt(f));)f++;if(46===i.charCodeAt(f)){if(f++,s(t))return!0;for(;$(i.charCodeAt(f));)f++}if(101===i.charCodeAt(f)||69===i.charCodeAt(f)){if(f++,45!==i.charCodeAt(f)&&43!==i.charCodeAt(f)||f++,s(t))return!0;for(;$(i.charCodeAt(f));)f++}if(f>t)return a+=i.slice(t,f),!0;return!1}()||r("true","true")||r("false","false")||r("null","null")||r("True","true")||r("False","false")||r("None","null")||l();return u(),t}function u(){f;let t=e();for(;t=(t=function(){if(47===i.charCodeAt(f)&&42===i.charCodeAt(f+1)){for(;f<i.length&&!function(t,e){return"*"===t[e]&&"/"===t[e+1]}(i,f);)f++;f+=2}else{if(47!==i.charCodeAt(f)||47!==i.charCodeAt(f+1))return!1;for(;f<i.length&&i.charCodeAt(f)!==g;)f++}return!0}())&&e(););f}function e(){let t="";for(var e,r;(e=R(i.charCodeAt(f)))||(r=i.charCodeAt(f))===J||r>=S&&r<=j||r===I||r===k||r===m;)t+=e?i[f]:" ",f++;return 0<t.length&&(a+=t,!0)}function c(t){return i.charCodeAt(f)===t&&(a+=i[f],f++,!0)}function d(){92===i.charCodeAt(f)&&f++}function h(){let t=92===i.charCodeAt(f);if(t&&(f++,t=!0),U(i.charCodeAt(f))){var e=z(i.charCodeAt(f))?z:q(i.charCodeAt(f))?q:F;for(a+='"',f++;f<i.length&&!e(i.charCodeAt(f));){if(92===i.charCodeAt(f)){var r=i[f+1];if(void 0!==K[r])a+=i.slice(f,f+2),f+=2;else if("u"===r){if(!(T(i.charCodeAt(f+2))&&T(i.charCodeAt(f+3))&&T(i.charCodeAt(f+4))&&T(i.charCodeAt(f+5)))){n=void 0;var n=f;let t=n+2;for(;/\w/.test(i[t]);)t++;n=i.slice(n,t);throw new A('Invalid unicode character "'.concat(n,'"'),f)}a+=i.slice(f,f+6),f+=6}else a+=r,f+=2}else{n=i[f],r=i.charCodeAt(f);if(r===x&&92!==i.charCodeAt(f-1))a+="\\"+n;else if((c=r)===g||c===b||c===v||c===p||c===w)a+=H[n];else{if(!(32<=(c=r)&&c<=1114111))throw c=void 0,c=n,new A("Invalid character "+JSON.stringify(c),f);a+=n}f++}t&&d()}U(i.charCodeAt(f))?(i.charCodeAt(f),x,a+='"',f++):a+='"';{let t=!1;u();for(;43===i.charCodeAt(f);){t=!0,f++,u();var o=(a=B(a,'"',!0)).length;h(),a=function(t,e,r){return t.substring(0,e)+t.substring(e+r)}(a,o,1)}t}return!0}var c;return!1}function r(t,e){return i.slice(f,f+t.length)===t&&(a+=e,f+=t.length,!0)}function l(){for(var t,e=f;f<i.length&&(t=i[f],!(G.test(t)||t&&U(t.charCodeAt(0))));)f++;if(f>e){if(40===i.charCodeAt(f))f++,o(),41===i.charCodeAt(f)&&(f++,59===i.charCodeAt(f))&&f++;else{for(;R(i.charCodeAt(f-1))&&0<f;)f--;e=i.slice(e,f);a+="undefined"===e?"null":JSON.stringify(e)}return!0}}function n(t){if(!$(i.charCodeAt(f)))throw t=i.slice(t,f),new A("Invalid number '".concat(t,"', expecting a digit ").concat(i[f]?"but got '".concat(i[f],"'"):"but reached end of input"),2)}function s(t){if(f>=i.length)return a+=i.slice(t,f)+"0",1;n(t)}function C(){throw new A("Colon expected",f)}}});
{
"name": "jsonrepair",
"version": "3.1.0",
"version": "3.2.0",
"description": "Repair broken JSON documents",

@@ -62,20 +62,20 @@ "repository": {

"devDependencies": {
"@babel/cli": "7.21.0",
"@babel/core": "7.21.4",
"@babel/plugin-transform-typescript": "7.21.3",
"@babel/preset-env": "7.21.4",
"@babel/preset-typescript": "7.21.4",
"@commitlint/cli": "17.6.1",
"@commitlint/config-conventional": "17.6.1",
"@babel/cli": "7.22.5",
"@babel/core": "7.22.5",
"@babel/plugin-transform-typescript": "7.22.5",
"@babel/preset-env": "7.22.5",
"@babel/preset-typescript": "7.22.5",
"@commitlint/cli": "17.6.5",
"@commitlint/config-conventional": "17.6.5",
"@types/mocha": "10.0.1",
"@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "5.58.0",
"@typescript-eslint/parser": "5.58.0",
"@types/node": "20.3.1",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"benchmark": "2.1.4",
"cpy-cli": "4.2.0",
"del-cli": "5.0.0",
"eslint": "8.38.0",
"eslint-config-standard": "17.0.0",
"eslint": "8.42.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-n": "15.7.0",
"eslint-plugin-n": "16.0.0",
"eslint-plugin-node": "11.1.0",

@@ -86,9 +86,9 @@ "eslint-plugin-promise": "6.1.1",

"npm-run-all": "4.1.5",
"prettier": "2.8.7",
"rollup": "3.20.4",
"prettier": "2.8.8",
"rollup": "3.25.1",
"standard-version": "9.5.0",
"ts-node": "10.9.1",
"typescript": "5.0.4",
"typescript": "5.1.3",
"uglify-js": "3.17.4"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc