Comparing version 1.1.1 to 1.1.2
/////////////////////////////////////////////////////////////////////// | ||
// JSONCrush v1.1.1 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
// JSONCrush v1.1.2 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
/////////////////////////////////////////////////////////////////////// | ||
@@ -4,0 +4,0 @@ |
@@ -1,2 +0,2 @@ | ||
// JSONCrush v1.1.1 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
// JSONCrush v1.1.2 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
'use strict';export const JSONCrush={crush:function(a,b=50){var f=[];for(var d=127;--d;)(48<=d&&57>=d||65<=d&&90>=d||97<=d&&122>=d||"-_.!~*'()".includes(String.fromCharCode(d)))&&f.push(String.fromCharCode(d));for(d=32;255>d;++d){var h=String.fromCharCode(d);"\\"==h||f.includes(h)||f.unshift(h)}a=a.replace(/\u0001/g,"");a=q(a);d=f.length;h="";var c={};for(var g=2;g<b;g++)for(var k=0;k<a.length-g;++k){var e=a.substr(k,g);if(!c[e]){var m=e.charCodeAt(0),n=e.charCodeAt(e.length-1);if(!(56320<=m&&57343>=m||55296<=n&&56319>=n)){m=1;for(n=a.indexOf(e,k+g);0<=n;++m)n=a.indexOf(e,n+g);1<m&&(c[e]=m)}}}for(;;){for(;d--&&a.includes(f[d]););if(0>d)break;b=f[d];var l=void 0;g=0;k=encodeURI(encodeURIComponent(b)).replace(/%../g,"i").length;for(let p in c)e=c[p],e=(e-1)*encodeURI(encodeURIComponent(p)).replace(/%../g,"i").length-(e+1)*k,h.length||(e-=encodeURI(encodeURIComponent("\u0001")).replace(/%../g,"i").length),0>=e?delete c[p]:e>g&&(l=p,g=e);if(!l)break;a=a.split(l).join(b)+b+l;h=b+h;g={};for(let p in c){c=p.split(l).join(b);k=0;for(e=a.indexOf(c);0<=e;++k)e=a.indexOf(c,e+c.length);1<k&&(g[c]=k)}c=g}f=h;l=a;f.length&&(l+="\u0001"+f);return l+"_"},uncrush:function(a){a=a.substring(0,a.length-1);var b=a.split("\u0001");a=b[0];if(1<b.length){b=b[1];for(let f of b)a=a.split(f),a=a.join(a.pop())}return q(a,0)}};function q(a,b=1){const f=[['"',"'"],["':","!"],[",'","~"],["}",")","\\","\\"],["{","(","\\","\\"]],d=(h,c)=>h.replace(new RegExp(`${(c[2]?c[2]:"")+c[0]}|${(c[3]?c[3]:"")+c[1]}`,"g"),g=>g===c[0]?c[1]:c[0]);if(b)for(b=0;b<f.length;++b)a=d(a,f[b]);else for(b=f.length;b--;)a=d(a,f[b]);return a} |
{ | ||
"name": "jsoncrush", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Compress JSON in URL friendly strings", | ||
"main": "JSONCrush.js", | ||
"types": "JSONCrush.d.ts", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
@@ -16,5 +16,6 @@ # JSONCrush - Compress JSON into URL friendly strings | ||
* Download from github or use `npm install jsoncrush` | ||
* Import JSONCrush as a module to your JavaScript program. | ||
* Just pass a JSON string to JSONCrush.crush() to compress it! | ||
* To decode just pass the crushed string to JSONCrush.uncrush(). | ||
* Just pass a JSON string to `JSONCrush.crush()` to compress it! | ||
* To decode just pass the crushed string to `JSONCrush.uncrush()` | ||
* See [index.html](https://github.com/KilledByAPixel/JSONCrush/blob/master/index.html) for a demonstration. | ||
@@ -36,3 +37,3 @@ | ||
### JSONCrushed - 82 bytes! 59% smaller | ||
### JSONCrushed and URI Encoded - 82 bytes! 59% smaller | ||
@@ -39,0 +40,0 @@ * `('students!%5B*Jack-7.Jill-6.Sue-6)%5D~class!'math')*('name!'-'~age!1.)%2C*%01.-*_` |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27674
7
185
73
0