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 2.0.1 to 2.1.0

bin/cli.js

5

CHANGELOG.md
# Changelog
## 2021-04-01, version 2.1.0
- Implemented command line interface (CLI), see #34.
## 2021-03-01, version 2.0.1

@@ -4,0 +9,0 @@

2

lib/umd/jsonrepair.min.js

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

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).jsonrepair=e()}(this,function(){"use strict";function t(n,e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.message=n+" (char "+e+")",this.char=e,this.stack=(new Error).stack}(t.prototype=new Error).constructor=Error;var i={"'":!0,"‘":!0,"’":!0,"`":!0,"´":!0},f={'"':!0,"“":!0,"”":!0};function o(n){return e.test(n)}var e=/^[a-zA-Z_]$/;var u=/^[0-9a-fA-F]$/;function c(n){return r.test(n)}var r=/^[0-9]$/;function s(n){return" "===n||"\t"===n||"\n"===n||"\r"===n}function a(n){return" "===n||" "<=n&&n<=" "||" "===n||" "===n||" "===n}function l(n){return!0===i[n]}function h(n){return!0===f[n]}function d(n){return!0===i[n]?"'":!0===f[n]?'"':n}function n(n,e){e=n.lastIndexOf(e);return-1!==e?n.substring(0,e)+n.substring(e+1):n}function w(n,e){var r=n.length;if(!s(n[r-1]))return n+e;for(;s(n[r-1]);)r--;return n.substring(0,r)+e+n.substring(r)}var g=0,b=1,p=2,v=3,x=4,m=5,y=6,k={"":!0,"{":!0,"}":!0,"[":!0,"]":!0,":":!0,",":!0,"(":!0,")":!0,";":!0,"+":!0},I={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},E={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},j={null:"null",true:"true",false:"false"},A={None:"null",True:"true",False:"false"},$="",O="",T=0,C="",F="",S=y;function U(){T++,C=$.charAt(T)}function z(){return S===g&&("["===F||"{"===F)||S===p||S===b||S===v}function N(){O+=F,S=y,F="",k[C]?(S=g,F=C,U()):function(){if(c(C)||"-"===C){if(S=b,"-"===C){if(F+=C,U(),!c(C))throw new t("Invalid number, digit expected",T)}else"0"===C&&(F+=C,U());for(;c(C);)F+=C,U();if("."===C){if(F+=C,U(),!c(C))throw new t("Invalid number, digit expected",T);for(;c(C);)F+=C,U()}if("e"===C||"E"===C){if(F+=C,U(),"+"!==C&&"-"!==C||(F+=C,U()),!c(C))throw new t("Invalid number, digit expected",T);for(;c(C);)F+=C,U()}}else!function(){if(function(n){return!0===i[n]||!0===f[n]}(C)){var n=d(C),e=l(C)?l:h;for(F+='"',S=p,U();""!==C&&!e(C);)if("\\"===C)if(U(),void 0!==I[C])F+="\\"+C,U();else if("u"===C){F+="\\u",U();for(var r=0;r<4;r++){if(!function(n){return u.test(n)}(C))throw new t("Invalid unicode character",T-F.length);F+=C,U()}}else{if("'"!==C)throw new t('Invalid escape character "\\'+C+'"',T);F+="'",U()}else E[C]?F+=E[C]:F+='"'===C?'\\"':C,U();if(d(C)!==n)throw new t("End of string expected",T-F.length);return F+='"',U(),0}!function(){if(o(C))for(S=v;o(C)||c(C)||"$"===C;)F+=C,U();else!function(){if(s(C)||a(C))for(S=x;s(C)||a(C);)F+=C,U();else!function(){if("/"===C&&"*"===$[T+1]){for(S=m;""!==C&&("*"!==C||"*"===C&&"/"!==$[T+1]);)F+=C,U();return"*"===C&&"/"===$[T+1]&&(F+=C,U(),F+=C,U())}if("/"!==C||"/"!==$[T+1])!function(){for(S=y;""!==C;)F+=C,U();throw new t('Syntax error in part "'+F+'"',T-F.length)}();else for(S=m;""!==C&&"\n"!==C;)F+=C,U()}()}()}()}()}(),S===x&&(F=function(n){for(var e="",r=0;r<n.length;r++){var t=n[r];e+=a(t)?" ":t}return e}(F),N()),S===m&&(S=y,F="",N())}function V(){if(S!==g||"{"!==F)!function(){if(S===g&&"["===F){if(N(),S===g&&"]"===F)return N();for(;;)if(V(),S===g&&","===F){if(N(),S===g&&"]"===F){O=n(O,",");break}}else{if(!z())break;O=w(O,",")}return S===g&&"]"===F?N():O=w(O,"]")}!function(){if(S!==p)!(S===b?N():void function(){if(S===v){if(j[F])return N();if(A[F])return F=A[F],N();var n=F,e=O.length;if(F="",N(),S===g&&"("===F)return F="",N(),V(),S===g&&")"===F&&(F="",N(),S===g&&";"===F&&(F="",N()));for(O=function(n,e,r){return n.substring(0,r)+e+n.substring(r)}(O,'"'.concat(n),e);S===v||S===b;)N();return O+='"'}!function(){throw new t(""===F?"Unexpected end of json string":"Value expected",T-F.length)}()}());else for(N();S===g&&"+"===F;){var n;F="",N(),S===p&&(n=O.lastIndexOf('"'),O=O.substring(0,n)+F.substring(1),F="",N())}}()}();else if(N(),S!==g||"}"!==F){for(;;){if(S!==v&&S!==b||(S=p,F='"'.concat(F,'"')),S!==p)throw new t("Object key expected",T-F.length);if(N(),S===g&&":"===F)N();else{if(!z())throw new t("Colon expected",T-F.length);O=w(O,":")}if(V(),S===g&&","===F){if(N(),S===g&&"}"===F){O=n(O,",");break}}else{if(S!==p&&S!==b&&S!==v)break;O=w(O,",")}}S===g&&"}"===F?N():O=w(O,"}")}else N()}return function(n){if(O="",T=0,C=($=n).charAt(0),F="",S=y,N(),n=S===g&&"{"===F,V(),""===F)return O;if(n&&z()){for(var e="";z();)e+=O=w(O,","),O="",V();return"[\n".concat(e).concat(O,"\n]")}throw new t("Unexpected characters",T-F.length)}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).jsonrepair=n()}(this,function(){"use strict";function r(e,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.message=e+" (char "+n+")",this.char=n,this.stack=(new Error).stack}(r.prototype=new Error).constructor=Error;var f={"'":!0,"‘":!0,"’":!0,"`":!0,"´":!0},i={'"':!0,"“":!0,"”":!0};function o(e){return n.test(e)}var n=/^[a-zA-Z_]$/;var u=/^[0-9a-fA-F]$/;function c(e){return t.test(e)}var t=/^[0-9]$/;function s(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function a(e){return" "===e||" "<=e&&e<=" "||" "===e||" "===e||" "===e}function l(e){return!0===f[e]}function h(e){return!0===i[e]}function d(e){return!0===f[e]?"'":!0===i[e]?'"':e}function e(e,n){n=e.lastIndexOf(n);return-1!==n?e.substring(0,n)+e.substring(n+1):e}function w(e,n){var t=e.length;if(!s(e[t-1]))return e+n;for(;s(e[t-1]);)t--;return e.substring(0,t)+n+e.substring(t)}var g=0,b=1,p=2,v=3,x=4,m=5,y=6,k={"":!0,"{":!0,"}":!0,"[":!0,"]":!0,":":!0,",":!0,"(":!0,")":!0,";":!0,"+":!0},I={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},E={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},j={null:"null",true:"true",false:"false"},A={None:"null",True:"true",False:"false"},$="",O="",T=0,C="",F="",S=y;function U(){T++,C=$.charAt(T)}function z(){return S===g&&("["===F||"{"===F)||S===p||S===b||S===v}function N(){O+=F,S=y,F="",k[C]?(S=g,F=C,U()):function(){if(c(C)||"-"===C){if(S=b,"-"===C){if(F+=C,U(),!c(C))throw new r("Invalid number, digit expected",T)}else"0"===C&&(F+=C,U());for(;c(C);)F+=C,U();if("."===C){if(F+=C,U(),!c(C))throw new r("Invalid number, digit expected",T);for(;c(C);)F+=C,U()}if("e"===C||"E"===C){if(F+=C,U(),"+"!==C&&"-"!==C||(F+=C,U()),!c(C))throw new r("Invalid number, digit expected",T);for(;c(C);)F+=C,U()}}else!function(){if(function(e){return!0===f[e]||!0===i[e]}(C)){var e=d(C),n=l(C)?l:h;for(F+='"',S=p,U();""!==C&&!n(C);)if("\\"===C)if(U(),void 0!==I[C])F+="\\"+C,U();else if("u"===C){F+="\\u",U();for(var t=0;t<4;t++){if(!function(e){return u.test(e)}(C))throw new r("Invalid unicode character",T-F.length);F+=C,U()}}else{if("'"!==C)throw new r('Invalid escape character "\\'+C+'"',T);F+="'",U()}else E[C]?F+=E[C]:F+='"'===C?'\\"':C,U();if(d(C)!==e)throw new r("End of string expected",T-F.length);F+='"',U()}else!function(){if(o(C))for(S=v;o(C)||c(C)||"$"===C;)F+=C,U();else!function(){if(s(C)||a(C))for(S=x;s(C)||a(C);)F+=C,U();else!function(){if("/"!==C||"*"!==$[T+1])if("/"!==C||"/"!==$[T+1])!function(){S=y;for(;""!==C;)F+=C,U();throw new r('Syntax error in part "'+F+'"',T-F.length)}();else for(S=m;""!==C&&"\n"!==C;)F+=C,U();else{for(S=m;""!==C&&("*"!==C||"*"===C&&"/"!==$[T+1]);)F+=C,U();"*"===C&&"/"===$[T+1]&&(F+=C,U(),F+=C,U())}}()}()}()}()}(),S===x&&(F=function(e){for(var n="",t=0;t<e.length;t++){var r=e[t];n+=a(r)?" ":r}return n}(F),N()),S===m&&(S=y,F="",N())}function V(){if(S!==g||"{"!==F)!function(){if(S!==g||"["!==F)!function(){if(S!==p)(S!==b?function(){if(S!==v)!function(){throw new r(""===F?"Unexpected end of json string":"Value expected",T-F.length)}();else if(j[F])N();else{if(A[F])return F=A[F],N();var e=F,n=O.length;if(F="",N(),S===g&&"("===F)return F="",N(),V(),S===g&&")"===F&&(F="",N(),S===g&&";"===F&&(F="",N()));for(O=function(e,n,t){return e.substring(0,t)+n+e.substring(t)}(O,'"'.concat(e),n);S===v||S===b;)N();O+='"'}}:N)();else for(N();S===g&&"+"===F;){var e;F="",N(),S===p&&(e=O.lastIndexOf('"'),O=O.substring(0,e)+F.substring(1),F="",N())}}();else if(N(),S!==g||"]"!==F){for(;;)if(V(),S===g&&","===F){if(N(),S===g&&"]"===F){O=e(O,",");break}}else{if(!z())break;O=w(O,",")}S===g&&"]"===F?N():O=w(O,"]")}else N()}();else if(N(),S!==g||"}"!==F){for(;;){if(S!==v&&S!==b||(S=p,F='"'.concat(F,'"')),S!==p)throw new r("Object key expected",T-F.length);if(N(),S===g&&":"===F)N();else{if(!z())throw new r("Colon expected",T-F.length);O=w(O,":")}if(V(),S===g&&","===F){if(N(),S===g&&"}"===F){O=e(O,",");break}}else{if(S!==p&&S!==b&&S!==v)break;O=w(O,",")}}S===g&&"}"===F?N():O=w(O,"}")}else N()}return function(e){if(O="",T=0,C=($=e).charAt(0),F="",S=y,N(),e=S===g&&"{"===F,V(),""===F)return O;if(e&&z()){for(var n="";z();)n+=O=w(O,","),O="",V();return"[\n".concat(n).concat(O,"\n]")}throw new r("Unexpected characters",T-F.length)}});
{
"name": "jsonrepair",
"version": "2.0.1",
"version": "2.1.0",
"description": "Repair broken JSON documents",

@@ -21,2 +21,5 @@ "repository": {

],
"bin": {
"jsonrepair": "./bin/cli.js"
},
"scripts": {

@@ -45,8 +48,8 @@ "test": "mocha",

"devDependencies": {
"@babel/cli": "7.12.16",
"@babel/core": "7.12.16",
"@babel/preset-env": "7.12.16",
"@babel/cli": "7.13.14",
"@babel/core": "7.13.14",
"@babel/preset-env": "7.13.12",
"cpy-cli": "3.1.1",
"del-cli": "3.0.1",
"eslint": "7.20.0",
"eslint": "7.23.0",
"eslint-config-standard": "16.0.2",

@@ -56,6 +59,6 @@ "eslint-plugin-import": "2.22.1",

"eslint-plugin-promise": "4.3.1",
"mocha": "8.3.0",
"rollup": "2.39.0",
"uglify-js": "3.12.8"
"mocha": "8.3.2",
"rollup": "2.44.0",
"uglify-js": "3.13.3"
}
}

@@ -58,2 +58,33 @@ # jsonrepair

### Command Line Interface (CLI)
When `jsonrepair` is installed globally using npm, it can be used on the command line. To install `jsonrepair` globally:
```bash
$ npm install -g jsonrepair
```
Usage:
```
$ jsonrepair [filename] {OPTIONS}
```
Options:
```
--version, -v Show application version
--help, -h Show help
```
Example usage:
```
$ jsonrepair broken.json # Repair a file, output to console
$ jsonrepair broken.json > repaired.json # Repair a file, output to file
$ jsonrepair broken.json --overwrite # Repair a file, replace the file itself
$ cat broken.json | jsonrepair # Repair data from an input stream
$ cat broken.json | jsonrepair > repaired.json # Repair data from an input stream, output to file
```
### Develop

@@ -60,0 +91,0 @@

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