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.10.0 to 3.11.0

26

lib/cjs/regular/jsonrepair.js

@@ -328,6 +328,8 @@ "use strict";

* more conservative way, stopping the string at the first next delimiter
* and fixing the string by inserting a quote there.
* and fixing the string by inserting a quote there, or stopping at a
* stop index detected in the first iteration.
*/
function parseString() {
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
let stopAtIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
let skipEscapeChars = text.charCodeAt(i) === _stringUtils.codeBackslash;

@@ -368,2 +370,8 @@ if (skipEscapeChars) {

// biome-ignore lint/style/noUselessElse: <explanation>
} else if (i === stopAtIndex) {
// use the stop index detected in the first iteration, and repair end quote
str = (0, _stringUtils.insertBeforeLastWhitespace)(str, '"');
output += str;
return true;
// biome-ignore lint/style/noUselessElse: <explanation>
} else if (isEndQuote(text.charCodeAt(i))) {

@@ -379,8 +387,18 @@ // end quote

if (stopAtDelimiter || i >= text.length || (0, _stringUtils.isDelimiter)(text.charAt(i)) || (0, _stringUtils.isQuote)(text.charCodeAt(i)) || (0, _stringUtils.isDigit)(text.charCodeAt(i))) {
// The quote is followed by the end of the text, a delimiter, or a next value
// so the quote is indeed the end of the string
// The quote is followed by the end of the text, a delimiter,
// or a next value. So the quote is indeed the end of the string.
parseConcatenatedString();
return true;
}
if ((0, _stringUtils.isDelimiter)(text.charAt(prevNonWhitespaceIndex(iQuote - 1)))) {
const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
const prevChar = text.charAt(iPrevChar);
if (prevChar === ',') {
// A comma followed by a quote, like '{"a":"b,c,"d":"e"}'.
// We assume that the quote is a start quote, and that the end quote
// should have been located right before the comma but is missing.
i = iBefore;
output = output.substring(0, oBefore);
return parseString(false, iPrevChar);
}
if ((0, _stringUtils.isDelimiter)(prevChar)) {
// This is not the right end quote: it is preceded by a delimiter,

@@ -387,0 +405,0 @@ // and NOT followed by a delimiter. So, there is an end quote missing

@@ -451,6 +451,8 @@ "use strict";

* more conservative way, stopping the string at the first next delimiter
* and fixing the string by inserting a quote there.
* and fixing the string by inserting a quote there, or stopping at a
* stop index detected in the first iteration.
*/
function parseString() {
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
let stopAtIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
let skipEscapeChars = input.charCodeAt(i) === _stringUtils.codeBackslash;

@@ -490,2 +492,7 @@ if (skipEscapeChars) {

// biome-ignore lint/style/noUselessElse: <explanation>
} else if (i === stopAtIndex) {
// use the stop index detected in the first iteration, and repair end quote
output.insertBeforeLastWhitespace('"');
return stack.update(_stack.Caret.afterValue);
// biome-ignore lint/style/noUselessElse: <explanation>
} else if (isEndQuote(input.charCodeAt(i))) {

@@ -505,3 +512,13 @@ // end quote

}
if ((0, _stringUtils.isDelimiter)(input.charAt(prevNonWhitespaceIndex(iQuote - 1)))) {
const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
const prevChar = input.charAt(iPrevChar);
if (prevChar === ',') {
// A comma followed by a quote, like '{"a":"b,c,"d":"e"}'.
// We assume that the quote is a start quote, and that the end quote
// should have been located right before the comma but is missing.
i = iBefore;
output.remove(oBefore);
return parseString(false, iPrevChar);
}
if ((0, _stringUtils.isDelimiter)(prevChar)) {
// This is not the right end quote: it is preceded by a delimiter,

@@ -508,0 +525,0 @@ // and NOT followed by a delimiter. So, there is an end quote missing

@@ -322,6 +322,8 @@ import { JSONRepairError } from '../utils/JSONRepairError.js';

* more conservative way, stopping the string at the first next delimiter
* and fixing the string by inserting a quote there.
* and fixing the string by inserting a quote there, or stopping at a
* stop index detected in the first iteration.
*/
function parseString() {
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
let stopAtIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
let skipEscapeChars = text.charCodeAt(i) === codeBackslash;

@@ -362,2 +364,8 @@ if (skipEscapeChars) {

// biome-ignore lint/style/noUselessElse: <explanation>
} else if (i === stopAtIndex) {
// use the stop index detected in the first iteration, and repair end quote
str = insertBeforeLastWhitespace(str, '"');
output += str;
return true;
// biome-ignore lint/style/noUselessElse: <explanation>
} else if (isEndQuote(text.charCodeAt(i))) {

@@ -373,8 +381,18 @@ // end quote

if (stopAtDelimiter || i >= text.length || isDelimiter(text.charAt(i)) || isQuote(text.charCodeAt(i)) || isDigit(text.charCodeAt(i))) {
// The quote is followed by the end of the text, a delimiter, or a next value
// so the quote is indeed the end of the string
// The quote is followed by the end of the text, a delimiter,
// or a next value. So the quote is indeed the end of the string.
parseConcatenatedString();
return true;
}
if (isDelimiter(text.charAt(prevNonWhitespaceIndex(iQuote - 1)))) {
const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
const prevChar = text.charAt(iPrevChar);
if (prevChar === ',') {
// A comma followed by a quote, like '{"a":"b,c,"d":"e"}'.
// We assume that the quote is a start quote, and that the end quote
// should have been located right before the comma but is missing.
i = iBefore;
output = output.substring(0, oBefore);
return parseString(false, iPrevChar);
}
if (isDelimiter(prevChar)) {
// This is not the right end quote: it is preceded by a delimiter,

@@ -381,0 +399,0 @@ // and NOT followed by a delimiter. So, there is an end quote missing

@@ -445,6 +445,8 @@ import { JSONRepairError } from '../utils/JSONRepairError.js';

* more conservative way, stopping the string at the first next delimiter
* and fixing the string by inserting a quote there.
* and fixing the string by inserting a quote there, or stopping at a
* stop index detected in the first iteration.
*/
function parseString() {
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
let stopAtIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
let skipEscapeChars = input.charCodeAt(i) === codeBackslash;

@@ -484,2 +486,7 @@ if (skipEscapeChars) {

// biome-ignore lint/style/noUselessElse: <explanation>
} else if (i === stopAtIndex) {
// use the stop index detected in the first iteration, and repair end quote
output.insertBeforeLastWhitespace('"');
return stack.update(Caret.afterValue);
// biome-ignore lint/style/noUselessElse: <explanation>
} else if (isEndQuote(input.charCodeAt(i))) {

@@ -499,3 +506,13 @@ // end quote

}
if (isDelimiter(input.charAt(prevNonWhitespaceIndex(iQuote - 1)))) {
const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
const prevChar = input.charAt(iPrevChar);
if (prevChar === ',') {
// A comma followed by a quote, like '{"a":"b,c,"d":"e"}'.
// We assume that the quote is a start quote, and that the end quote
// should have been located right before the comma but is missing.
i = iBefore;
output.remove(oBefore);
return parseString(false, iPrevChar);
}
if (isDelimiter(prevChar)) {
// This is not the right end quote: it is preceded by a delimiter,

@@ -502,0 +519,0 @@ // and NOT followed by a delimiter. So, there is an end quote missing

@@ -499,6 +499,8 @@ (function (global, factory) {

* more conservative way, stopping the string at the first next delimiter
* and fixing the string by inserting a quote there.
* and fixing the string by inserting a quote there, or stopping at a
* stop index detected in the first iteration.
*/
function parseString() {
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
let stopAtIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
let skipEscapeChars = text.charCodeAt(i) === codeBackslash;

@@ -539,2 +541,8 @@ if (skipEscapeChars) {

// biome-ignore lint/style/noUselessElse: <explanation>
} else if (i === stopAtIndex) {
// use the stop index detected in the first iteration, and repair end quote
str = insertBeforeLastWhitespace(str, '"');
output += str;
return true;
// biome-ignore lint/style/noUselessElse: <explanation>
} else if (isEndQuote(text.charCodeAt(i))) {

@@ -550,8 +558,18 @@ // end quote

if (stopAtDelimiter || i >= text.length || isDelimiter(text.charAt(i)) || isQuote(text.charCodeAt(i)) || isDigit(text.charCodeAt(i))) {
// The quote is followed by the end of the text, a delimiter, or a next value
// so the quote is indeed the end of the string
// The quote is followed by the end of the text, a delimiter,
// or a next value. So the quote is indeed the end of the string.
parseConcatenatedString();
return true;
}
if (isDelimiter(text.charAt(prevNonWhitespaceIndex(iQuote - 1)))) {
const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
const prevChar = text.charAt(iPrevChar);
if (prevChar === ',') {
// A comma followed by a quote, like '{"a":"b,c,"d":"e"}'.
// We assume that the quote is a start quote, and that the end quote
// should have been located right before the comma but is missing.
i = iBefore;
output = output.substring(0, oBefore);
return parseString(false, iPrevChar);
}
if (isDelimiter(prevChar)) {
// This is not the right end quote: it is preceded by a delimiter,

@@ -558,0 +576,0 @@ // and NOT followed by a delimiter. So, there is an end quote missing

6

lib/umd/jsonrepair.min.js

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

((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 w extends Error{constructor(t,e){super(t+" at position "+e),this.position=e}}let u=125,e=32,x=10,y=9,O=13,N=8,J=12,S=34,r=39,j=48,k=57,d=44,m=65,z=97,I=70,T=102,l=160,Z=8192,_=8202,E=8239,W=8287,X=12288,n=8220,o=8221,i=8216,c=8217,f=96,a=180;function R(t){return t>=j&&t<=k}function U(t){return h.test(t)}let h=/^[,:[\]/{}()\n+]$/,s=/^[,[\]/{}\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 s.test(t)}function D(t){return A.test(t)||t&&H(t.charCodeAt(0))}let A=/^[[{\w-]$/;function G(t){return t===e||t===x||t===y||t===O}function H(t){return K(t)||M(t)}function K(t){return t===S||t===n||t===o}function L(t){return t===S}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=w,t.jsonrepair=function(s){let A=0,C="";if(!i())throw new w("Unexpected end of json string",s.length);var t=c(d);if(t&&g(),D(s[A])&&/[,\n][ \t\r]*$/.test(C)){t||(C=V(C,","));{let t=!0,e=!0;for(;e;)t?t=!1:c(d)||(C=V(C,",")),e=i();C=`[
${C=e?C:Q(C,",")}
]`}}else t&&(C=Q(C,","));for(;s.charCodeAt(A)===u||93===s.charCodeAt(A);)A++,g();if(A>=s.length)return C;throw new w("Unexpected character "+JSON.stringify(s[A]),A);function i(){g();var t=(()=>{if(123!==s.charCodeAt(A))return!1;{C+="{",A++,g(),b(d)&&g();let e=!0;for(;A<s.length&&s.charCodeAt(A)!==u;){let t;if(e?(t=!0,e=!1):((t=c(d))||(C=V(C,",")),g()),f(),!(v()||a(!0))){s.charCodeAt(A)===u||123===s.charCodeAt(A)||93===s.charCodeAt(A)||91===s.charCodeAt(A)||void 0===s[A]?C=Q(C,","):(()=>{throw new w("Object key expected",A)})();break}g();var r=c(58),n=A>=s.length,o=(r||(D(s[A])||n?C=V(C,":"):h()),i());o||(r||n?C+="null":h())}return s.charCodeAt(A)===u?(C+="}",A++):C=V(C,"}"),!0}})()||(()=>{if(91!==s.charCodeAt(A))return!1;{C+="[",A++,g(),b(d)&&g();let t=!0;for(;A<s.length&&93!==s.charCodeAt(A);){t?t=!1:c(d)||(C=V(C,",")),f();var e=i();if(!e){C=Q(C,",");break}}return 93===s.charCodeAt(A)?(C+="]",A++):C=V(C,"]"),!0}})()||v()||(()=>{var t,e,r=A;if(45===s.charCodeAt(A)){if(A++,n())return o(r),!0;if(!R(s.charCodeAt(A)))return A=r,!1}for(;R(s.charCodeAt(A));)A++;if(46===s.charCodeAt(A)){if(A++,n())return o(r),!0;if(!R(s.charCodeAt(A)))return A=r,!1;for(;R(s.charCodeAt(A));)A++}if(101===s.charCodeAt(A)||69===s.charCodeAt(A)){if(A++,45!==s.charCodeAt(A)&&43!==s.charCodeAt(A)||A++,n())return o(r),!0;if(!R(s.charCodeAt(A)))return A=r,!1;for(;R(s.charCodeAt(A));)A++}if(n()){if(A>r)return t=s.slice(r,A),e=/^0\d/.test(t),C+=e?`"${t}"`:t,!0}else A=r;return!1})()||r("true","true")||r("false","false")||r("null","null")||r("True","true")||r("False","false")||r("None","null")||a(!1)||(()=>{if("/"===s[A]){var t=A;for(A++;A<s.length&&("/"!==s[A]||"\\"===s[A-1]);)A++;return A++,C+=`"${s.substring(t,A)}"`,!0}})();return g(),t}function g(){A;let t=e();for(;t=(t=(()=>{if(47===s.charCodeAt(A)&&42===s.charCodeAt(A+1)){for(;A<s.length&&!((t,e)=>"*"===t[e]&&"/"===t[e+1])(s,A);)A++;A+=2}else{if(47!==s.charCodeAt(A)||47!==s.charCodeAt(A+1))return!1;for(;A<s.length&&s.charCodeAt(A)!==x;)A++}return!0})())&&e(););A}function e(){let t="";for(var e,r;(e=G(s.charCodeAt(A)))||(r=s.charCodeAt(A))===l||r>=Z&&r<=_||r===E||r===W||r===X;)t+=e?s[A]:" ",A++;return 0<t.length&&(C+=t,!0)}function c(t){return s.charCodeAt(A)===t&&(C+=s[A],A++,!0)}function b(t){return s.charCodeAt(A)===t&&(A++,!0)}function f(){g(),46===s.charCodeAt(A)&&46===s.charCodeAt(A+1)&&46===s.charCodeAt(A+2)&&(A+=3,g(),b(d))}function v(t){var r,n,o=0<arguments.length&&void 0!==t&&t;let i=92===s.charCodeAt(A);if(i&&(A++,i=!0),H(s.charCodeAt(A))){var c=L(s.charCodeAt(A))?L:P(s.charCodeAt(A))?P:M(s.charCodeAt(A))?M:K,f=A,a=C.length;let e='"';for(A++;;){if(A>=s.length)return h=$(A-1),!o&&U(s.charAt(h))?(A=f,C=C.substring(0,a),v(!0)):(e=V(e,'"'),C+=e,!0);if(c(s.charCodeAt(A))){var h=A,u=e.length;if(e+='"',A++,C+=e,g(),o||A>=s.length||U(s.charAt(A))||H(s.charCodeAt(A))||R(s.charCodeAt(A)))return p(),!0;if(U(s.charAt($(h-1))))return A=f,C=C.substring(0,a),v(!0);C=C.substring(0,a),A=h+1,e=e.substring(0,u)+"\\"+e.substring(u)}else{if(o&&B(s[A])){if(58===s.charCodeAt(A-1)&&F.test(s.substring(f+1,A+2)))for(;A<s.length&&q.test(s[A]);)e+=s[A],A++;return e=V(e,'"'),C+=e,p(),!0}if(92===s.charCodeAt(A)){u=s.charAt(A+1);if(void 0!==rt[u])e+=s.slice(A,A+2),A+=2;else if("u"===u){let t=2;for(;t<6&&((n=s.charCodeAt(A+t))>=j&&n<=k||n>=m&&n<=I||n>=z&&n<=T);)t++;if(6===t)e+=s.slice(A,A+6),A+=6;else{if(!(A+t>=s.length))throw d=void 0,d=s.slice(A,A+6),new w(`Invalid unicode character "${d}"`,A);A=s.length}}else e+=u,A+=2}else{var d=s.charAt(A),l=s.charCodeAt(A);if(l===S&&92!==s.charCodeAt(A-1))e+="\\"+d;else if((r=l)===x||r===O||r===y||r===N||r===J)e+=et[d];else{if(!(32<=(r=l)&&r<=1114111))throw l=void 0,l=d,new w("Invalid character "+JSON.stringify(l),A);e+=d}A++}}i&&b(92)}}return!1}function p(){let t=!1;for(g();43===s.charCodeAt(A);){t=!0,A++,g();var e=(C=Q(C,'"',!0)).length,r=v();C=r?(r=C,e=e,n=1,r.substring(0,e)+r.substring(e+n)):V(C,'"')}var n;t}function r(t,e){return s.slice(A,A+t.length)===t&&(C+=e,A+=t.length,!0)}function a(t){var e=A;if(Y.test(s[A])){for(;A<s.length&&tt.test(s[A]);)A++;let t=A;for(;G(s.charCodeAt(t));)t++;if("("===s[t])return A=t+1,i(),41===s.charCodeAt(A)&&(A++,59===s.charCodeAt(A))&&A++,!0}for(;A<s.length&&!B(s[A])&&!H(s.charCodeAt(A))&&(!t||58!==s.charCodeAt(A));)A++;if(58===s.charCodeAt(A-1)&&F.test(s.substring(e,A+2)))for(;A<s.length&&q.test(s[A]);)A++;if(A>e){for(;G(s.charCodeAt(A-1))&&0<A;)A--;e=s.slice(e,A);return C+="undefined"===e?"null":JSON.stringify(e),s.charCodeAt(A)===S&&A++,!0}}function $(t){let e=t;for(;0<e&&G(s.charCodeAt(e));)e--;return e}function n(){return A>=s.length||U(s[A])||G(s.charCodeAt(A))}function o(t){C+=s.slice(t,A)+"0"}function h(){throw new w("Colon expected",A)}}});
((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)}}});
{
"name": "jsonrepair",
"version": "3.10.0",
"version": "3.11.0",
"description": "Repair broken JSON documents",

@@ -5,0 +5,0 @@ "repository": {

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