jsonrepair
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -294,6 +294,5 @@ "use strict"; | ||
if ((0, _stringUtils.isQuote)(text.charCodeAt(i))) { | ||
var isEndQuote = (0, _stringUtils.isSingleQuote)(text.charCodeAt(i)) ? _stringUtils.isSingleQuote : _stringUtils.isDoubleQuote; | ||
if (text.charCodeAt(i) !== _stringUtils.codeDoubleQuote) { | ||
// repair non-normalized quote | ||
} | ||
var 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 | ||
output += '"'; | ||
@@ -300,0 +299,0 @@ i++; |
@@ -8,4 +8,6 @@ "use strict"; | ||
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, descriptor.key, descriptor); } } | ||
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"); } } | ||
@@ -12,0 +14,0 @@ 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); } |
@@ -13,6 +13,7 @@ "use strict"; | ||
exports.isDoubleQuote = isDoubleQuote; | ||
exports.isDoubleQuoteLike = isDoubleQuoteLike; | ||
exports.isHex = isHex; | ||
exports.isNonZeroDigit = isNonZeroDigit; | ||
exports.isQuote = isQuote; | ||
exports.isSingleQuote = isSingleQuote; | ||
exports.isSingleQuoteLike = isSingleQuoteLike; | ||
exports.isSpecialWhitespace = isSpecialWhitespace; | ||
@@ -150,3 +151,3 @@ exports.isStartOfValue = isStartOfValue; | ||
// the first check double quotes, since that occurs most often | ||
return isDoubleQuote(code) || isSingleQuote(code); | ||
return isDoubleQuoteLike(code) || isSingleQuoteLike(code); | ||
} | ||
@@ -158,3 +159,3 @@ | ||
*/ | ||
function isDoubleQuote(code) { | ||
function isDoubleQuoteLike(code) { | ||
// the first check double quotes, since that occurs most often | ||
@@ -165,6 +166,14 @@ return code === codeDoubleQuote || code === codeDoubleQuoteLeft || code === codeDoubleQuoteRight; | ||
/** | ||
* Test whether the given character is a double quote character. | ||
* Does NOT test for special variants of double quotes. | ||
*/ | ||
function isDoubleQuote(code) { | ||
return code === codeDoubleQuote; | ||
} | ||
/** | ||
* Test whether the given character is a single quote character. | ||
* Also tests for special variants of single quotes. | ||
*/ | ||
function isSingleQuote(code) { | ||
function isSingleQuoteLike(code) { | ||
return code === codeQuote || code === codeQuoteLeft || code === codeQuoteRight || code === codeGraveAccent || code === codeAcuteAccent; | ||
@@ -171,0 +180,0 @@ } |
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, isHex, isNonZeroDigit, isQuote, isSingleQuote, isSpecialWhitespace, isStartOfValue, isValidStringCharacter, isWhitespace, removeAtIndex, stripLastOccurrence } from './stringUtils.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 = { | ||
@@ -288,6 +288,5 @@ '\b': '\\b', | ||
if (isQuote(text.charCodeAt(i))) { | ||
var isEndQuote = isSingleQuote(text.charCodeAt(i)) ? isSingleQuote : isDoubleQuote; | ||
if (text.charCodeAt(i) !== codeDoubleQuote) { | ||
// repair non-normalized quote | ||
} | ||
var isEndQuote = isSingleQuoteLike(text.charCodeAt(i)) ? isSingleQuoteLike : isDoubleQuote(text.charCodeAt(i)) ? isDoubleQuote // eslint-disable-line indent | ||
: isDoubleQuoteLike; // eslint-disable-line indent | ||
output += '"'; | ||
@@ -294,0 +293,0 @@ i++; |
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, descriptor.key, descriptor); } } | ||
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"); } } | ||
@@ -5,0 +7,0 @@ 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); } |
@@ -95,3 +95,3 @@ // TODO: sort the codes | ||
// the first check double quotes, since that occurs most often | ||
return isDoubleQuote(code) || isSingleQuote(code); | ||
return isDoubleQuoteLike(code) || isSingleQuoteLike(code); | ||
} | ||
@@ -103,3 +103,3 @@ | ||
*/ | ||
export function isDoubleQuote(code) { | ||
export function isDoubleQuoteLike(code) { | ||
// the first check double quotes, since that occurs most often | ||
@@ -110,6 +110,14 @@ return code === codeDoubleQuote || code === codeDoubleQuoteLeft || code === codeDoubleQuoteRight; | ||
/** | ||
* Test whether the given character is a double quote character. | ||
* Does NOT test for special variants of double quotes. | ||
*/ | ||
export function isDoubleQuote(code) { | ||
return code === codeDoubleQuote; | ||
} | ||
/** | ||
* Test whether the given character is a single quote character. | ||
* Also tests for special variants of single quotes. | ||
*/ | ||
export function isSingleQuote(code) { | ||
export function isSingleQuoteLike(code) { | ||
return code === codeQuote || code === codeQuoteLeft || code === codeQuoteRight || code === codeGraveAccent || code === codeAcuteAccent; | ||
@@ -116,0 +124,0 @@ } |
export { jsonrepair } from './jsonrepair.js'; | ||
export { JSONRepairError } from './JSONRepairError.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export declare class JSONRepairError extends Error { |
@@ -59,2 +59,7 @@ export declare const codeBackslash = 92; | ||
*/ | ||
export declare function isDoubleQuoteLike(code: number): boolean; | ||
/** | ||
* Test whether the given character is a double quote character. | ||
* Does NOT test for special variants of double quotes. | ||
*/ | ||
export declare function isDoubleQuote(code: number): boolean; | ||
@@ -65,3 +70,3 @@ /** | ||
*/ | ||
export declare function isSingleQuote(code: number): boolean; | ||
export declare function isSingleQuoteLike(code: number): boolean; | ||
/** | ||
@@ -68,0 +73,0 @@ * Strip last occurrence of textToStrip from text |
@@ -8,4 +8,6 @@ (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, descriptor.key, descriptor); } } | ||
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"); } } | ||
@@ -129,3 +131,3 @@ 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); } | ||
// the first check double quotes, since that occurs most often | ||
return isDoubleQuote(code) || isSingleQuote(code); | ||
return isDoubleQuoteLike(code) || isSingleQuoteLike(code); | ||
} | ||
@@ -137,3 +139,3 @@ | ||
*/ | ||
function isDoubleQuote(code) { | ||
function isDoubleQuoteLike(code) { | ||
// the first check double quotes, since that occurs most often | ||
@@ -144,6 +146,14 @@ return code === codeDoubleQuote || code === codeDoubleQuoteLeft || code === codeDoubleQuoteRight; | ||
/** | ||
* Test whether the given character is a double quote character. | ||
* Does NOT test for special variants of double quotes. | ||
*/ | ||
function isDoubleQuote(code) { | ||
return code === codeDoubleQuote; | ||
} | ||
/** | ||
* Test whether the given character is a single quote character. | ||
* Also tests for special variants of single quotes. | ||
*/ | ||
function isSingleQuote(code) { | ||
function isSingleQuoteLike(code) { | ||
return code === codeQuote || code === codeQuoteLeft || code === codeQuoteRight || code === codeGraveAccent || code === codeAcuteAccent; | ||
@@ -467,4 +477,5 @@ } | ||
if (isQuote(text.charCodeAt(i))) { | ||
var isEndQuote = isSingleQuote(text.charCodeAt(i)) ? isSingleQuote : isDoubleQuote; | ||
if (text.charCodeAt(i) !== codeDoubleQuote) ; | ||
var isEndQuote = isSingleQuoteLike(text.charCodeAt(i)) ? isSingleQuoteLike : isDoubleQuote(text.charCodeAt(i)) ? isDoubleQuote // eslint-disable-line indent | ||
: isDoubleQuoteLike; // eslint-disable-line indent | ||
output += '"'; | ||
@@ -471,0 +482,0 @@ i++; |
@@ -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 i(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,n.key,n)}}function u(r){var n=c();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=c()?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 c(){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 y=function(t){var e=c;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(c);function c(t,e){if(this instanceof c)return(t=o.call(this,t+" at position "+e)).position=e,t;throw new TypeError("Cannot call a class as a function")}return e=c,r&&i(e.prototype,r),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(e(Error)),r=32,C=10,A=9,v=13,g=8,w=12,O=34,l=39,j=48,m=49,x=57,h=65,d=97,s=70,p=102,S=160,P=8192,$=8202,B=8239,M=8287,U=12288,b=8220,D=8221,q=8216,z=8217,G=96,H=180;function R(t){return j<=t&&t<=x||h<=t&&t<=s||d<=t&&t<=p}function _(t){return j<=t&&t<=x}var K=/^[,:[\]{}()\n]$/;function E(t){return L.test(t)||t&&N(t.charCodeAt(0))}var L=/^[[{\w-]$/;function T(t){return t===r||t===C||t===A||t===v}function N(t){return J(t)||k(t)}function J(t){return t===O||t===b||t===D}function k(t){return t===l||t===q||t===z||t===G||t===H}function I(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 F(t,e){var r=t.length;if(!T(t.charCodeAt(r-1)))return t+e;for(;T(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}var Q={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},V={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=y,t.jsonrepair=function(u){var f=0,a="";if(!n())throw new y("Unexpected end of json string",u.length);var t=c(44);if(t&&l(),E(u[f])&&/[,\n][ \t\r]*$/.test(a)){t||(a=F(a,","));for(var e=!0,r=!0;r;)e?e=!1:c(44)||(a=F(a,",")),r=n();r||(a=I(a,",")),a="[\n".concat(a,"\n]")}else t&&(a=I(a,","));if(f>=u.length)return a;throw new y("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:(c(44)||(a=F(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=I(a,","):function(){throw new y("Object key expected",f)}();break}l();var e=c(58);e||(E(u[f])?a=F(a,":"):b()),n()||(e?function(){throw new y("Object value expected",f)}:b)()}125===u.charCodeAt(f)?(a+="}",f++):a=F(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:c(44)||(a=F(a,",")),!n()){a=I(a,",");break}93===u.charCodeAt(f)?(a+="]",f++):a=F(a,"]");return!0}()||d()||function(){var t=f;45===u.charCodeAt(f)&&(f++,p(t));if(u.charCodeAt(f)===j)f++;else if(function(t){return m<=t&&t<=x}(u.charCodeAt(f)))for(f++;_(u.charCodeAt(f));)f++;if(46===u.charCodeAt(f))for(f++,p(t);_(u.charCodeAt(f));)f++;if(101===u.charCodeAt(f)||69===u.charCodeAt(f))for(f++,45!==u.charCodeAt(f)&&43!==u.charCodeAt(f)||f++,p(t);_(u.charCodeAt(f));)f++;if(t<f)return a+=u.slice(t,f),!0;return!1}()||i("true","true")||i("false","false")||i("null","null")||i("True","true")||i("False","false")||i("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)!==C;)f++}return!0}()&&o(););}function o(){for(var t,e,r="";(t=T(u.charCodeAt(f)))||(e=u.charCodeAt(f))===S||P<=e&&e<=$||e===B||e===M||e===U;)r+=t?u[f]:" ",f++;return 0<r.length&&(a+=r,!0)}function c(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=k(u.charCodeAt(f))?k:J;for(u.charCodeAt(f),a+='"',f++;f<u.length&&!r(u.charCodeAt(f));){if(92===u.charCodeAt(f)){var n=u[f+1];if(void 0!==V[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)))){c=o=void 0;for(var o=f,c=o+2;/\w/.test(u[c]);)c++;throw o=u.slice(o,c),new y('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===O&&92!==u.charCodeAt(f-1))a+="\\"+o;else if((t=n)===C||t===v||t===A||t===g||t===w)a+=Q[o];else{if(!(32<=(t=n)&&t<=1114111))throw new y("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 i=(a=I(a,'"',!0)).length;d(),a=function(t,e,r){return t.substring(0,e)+t.substring(e+r)}(a,i,1)}return!0}return!1}function i(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],!(K.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(;T(u.charCodeAt(f-1))&&0<f;)f--;e=u.slice(e,f);a+=JSON.stringify(e)}return!0}}function p(t){if(!_(u.charCodeAt(f)))throw t=u.slice(t,f),new y("Invalid number '".concat(t,"', expecting a digit ").concat(u[f]?"but got '".concat(u[f],"'"):"but reached end of input"),2)}function b(){throw new y("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";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 i(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=c();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=c()?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 c(){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 y=function(t){var e=c;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(c);function c(t,e){if(this instanceof c)return(t=o.call(this,t+" at position "+e)).position=e,t;throw new TypeError("Cannot call a class as a function")}return e=c,r&&i(e.prototype,r),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(e(Error)),r=32,C=10,A=9,v=13,g=8,w=12,O=34,l=39,m=48,j=49,S=57,h=65,d=97,s=70,p=102,x=160,$=8192,B=8202,M=8239,U=8287,D=12288,b=8220,q=8221,z=8216,G=8217,H=96,K=180;function P(t){return m<=t&&t<=S||h<=t&&t<=s||d<=t&&t<=p}function R(t){return m<=t&&t<=S}var L=/^[,:[\]{}()\n]$/;function E(t){return Q.test(t)||t&&_(t.charCodeAt(0))}var Q=/^[[{\w-]$/;function T(t){return t===r||t===C||t===A||t===v}function _(t){return N(t)||k(t)}function N(t){return t===O||t===b||t===q}function J(t){return t===O}function k(t){return t===l||t===z||t===G||t===H||t===K}function I(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 F(t,e){var r=t.length;if(!T(t.charCodeAt(r-1)))return t+e;for(;T(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=y,t.jsonrepair=function(u){var f=0,a="";if(!n())throw new y("Unexpected end of json string",u.length);var t=c(44);if(t&&l(),E(u[f])&&/[,\n][ \t\r]*$/.test(a)){t||(a=F(a,","));for(var e=!0,r=!0;r;)e?e=!1:c(44)||(a=F(a,",")),r=n();r||(a=I(a,",")),a="[\n".concat(a,"\n]")}else t&&(a=I(a,","));if(f>=u.length)return a;throw new y("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:(c(44)||(a=F(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=I(a,","):function(){throw new y("Object key expected",f)}();break}l();var e=c(58);e||(E(u[f])?a=F(a,":"):b()),n()||(e?function(){throw new y("Object value expected",f)}:b)()}125===u.charCodeAt(f)?(a+="}",f++):a=F(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:c(44)||(a=F(a,",")),!n()){a=I(a,",");break}93===u.charCodeAt(f)?(a+="]",f++):a=F(a,"]");return!0}()||d()||function(){var t=f;45===u.charCodeAt(f)&&(f++,p(t));if(u.charCodeAt(f)===m)f++;else if(function(t){return j<=t&&t<=S}(u.charCodeAt(f)))for(f++;R(u.charCodeAt(f));)f++;if(46===u.charCodeAt(f))for(f++,p(t);R(u.charCodeAt(f));)f++;if(101===u.charCodeAt(f)||69===u.charCodeAt(f))for(f++,45!==u.charCodeAt(f)&&43!==u.charCodeAt(f)||f++,p(t);R(u.charCodeAt(f));)f++;if(t<f)return a+=u.slice(t,f),!0;return!1}()||i("true","true")||i("false","false")||i("null","null")||i("True","true")||i("False","false")||i("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)!==C;)f++}return!0}()&&o(););}function o(){for(var t,e,r="";(t=T(u.charCodeAt(f)))||(e=u.charCodeAt(f))===x||$<=e&&e<=B||e===M||e===U||e===D;)r+=t?u[f]:" ",f++;return 0<r.length&&(a+=r,!0)}function c(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),_(u.charCodeAt(f))){var r=k(u.charCodeAt(f))?k:J(u.charCodeAt(f))?J:N;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(!(P(u.charCodeAt(f+2))&&P(u.charCodeAt(f+3))&&P(u.charCodeAt(f+4))&&P(u.charCodeAt(f+5)))){c=o=void 0;for(var o=f,c=o+2;/\w/.test(u[c]);)c++;throw o=u.slice(o,c),new y('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===O&&92!==u.charCodeAt(f-1))a+="\\"+o;else if((t=n)===C||t===v||t===A||t===g||t===w)a+=V[o];else{if(!(32<=(t=n)&&t<=1114111))throw new y("Invalid character "+JSON.stringify(o),f);a+=o}f++}e&&h()}_(u.charCodeAt(f))?(u.charCodeAt(f),a+='"',f++):a+='"';for(l();43===u.charCodeAt(f);){f++,l();var i=(a=I(a,'"',!0)).length;d(),a=function(t,e,r){return t.substring(0,e)+t.substring(e+r)}(a,i,1)}return!0}return!1}function i(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&&_(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(;T(u.charCodeAt(f-1))&&0<f;)f--;e=u.slice(e,f);a+=JSON.stringify(e)}return!0}}function p(t){if(!R(u.charCodeAt(f)))throw t=u.slice(t,f),new y("Invalid number '".concat(t,"', expecting a digit ").concat(u[f]?"but got '".concat(u[f],"'"):"but reached end of input"),2)}function b(){throw new y("Colon expected",f)}}}); |
{ | ||
"name": "jsonrepair", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Repair broken JSON documents", | ||
@@ -46,7 +46,8 @@ "repository": { | ||
"build-and-test": "npm run lint && npm run build && npm run test:it", | ||
"release": "npm-run-all release:**", | ||
"release:build-and-test": "npm run build-and-test", | ||
"release:version": "standard-version", | ||
"release:push": "git push && git push --tag", | ||
"prepublishOnly": "npm-run-all release:**", | ||
"publish-dry-run": "npm run build-and-test && standard-version --dry-run", | ||
"release:publish": "npm publish", | ||
"release-dry-run": "npm run build-and-test && standard-version --dry-run", | ||
"prepare": "husky install" | ||
@@ -62,32 +63,32 @@ }, | ||
"devDependencies": { | ||
"@babel/cli": "7.19.3", | ||
"@babel/core": "7.20.2", | ||
"@babel/plugin-transform-typescript": "7.20.2", | ||
"@babel/preset-env": "7.20.2", | ||
"@babel/preset-typescript": "7.18.6", | ||
"@commitlint/cli": "17.3.0", | ||
"@commitlint/config-conventional": "17.3.0", | ||
"@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", | ||
"@types/mocha": "10.0.1", | ||
"@types/node": "18.11.13", | ||
"@typescript-eslint/eslint-plugin": "5.46.0", | ||
"@typescript-eslint/parser": "5.46.0", | ||
"@types/node": "18.15.11", | ||
"@typescript-eslint/eslint-plugin": "5.58.0", | ||
"@typescript-eslint/parser": "5.58.0", | ||
"benchmark": "2.1.4", | ||
"cpy-cli": "4.2.0", | ||
"del-cli": "5.0.0", | ||
"eslint": "8.27.0", | ||
"eslint": "8.38.0", | ||
"eslint-config-standard": "17.0.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-n": "15.5.1", | ||
"eslint-plugin-import": "2.27.5", | ||
"eslint-plugin-n": "15.7.0", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "6.1.1", | ||
"husky": "8.0.2", | ||
"mocha": "10.1.0", | ||
"husky": "8.0.3", | ||
"mocha": "10.2.0", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "2.8.1", | ||
"rollup": "3.3.0", | ||
"prettier": "2.8.7", | ||
"rollup": "3.20.4", | ||
"standard-version": "9.5.0", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.4", | ||
"typescript": "5.0.4", | ||
"uglify-js": "3.17.4" | ||
} | ||
} |
@@ -164,8 +164,8 @@ # jsonrepair | ||
### Publish | ||
### Release | ||
To publish: | ||
To release a new version: | ||
``` | ||
$ npm publish | ||
$ npm run release | ||
``` | ||
@@ -185,3 +185,3 @@ | ||
``` | ||
$ npm run publish-dry-run | ||
$ npm run release-dry-run | ||
``` | ||
@@ -188,0 +188,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
269061
2325