Comparing version 1.1.2 to 1.1.3
// Typescript type definition for JSONCrush | ||
export type JSONCrush = { | ||
export default class { | ||
crush(input: string, maxSubstringLength?: number): string; | ||
uncrush(input: string): string; | ||
}; |
/////////////////////////////////////////////////////////////////////// | ||
// JSONCrush v1.1.2 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
// JSONCrush v1.1.3 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
/////////////////////////////////////////////////////////////////////// | ||
"use strict"; | ||
'use strict'; | ||
// ==ClosureCompiler== | ||
// @compilation_level ADVANCED_OPTIMIZATIONS | ||
// @language_out ECMASCRIPT_2019 | ||
// @js_externs JSONCrush, JSONCrush.crush, JSONCrush.uncrush | ||
// ==/ClosureCompiler== | ||
export const JSONCrush = | ||
export default | ||
{ | ||
@@ -15,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
// 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} | ||
// JSONCrush v1.1.3 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush | ||
'use strict';export default {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.2", | ||
"version": "1.1.3", | ||
"description": "Compress JSON in URL friendly strings", | ||
@@ -5,0 +5,0 @@ "main": "JSONCrush.js", |
@@ -17,3 +17,3 @@ # JSONCrush - Compress JSON into URL friendly strings | ||
* Download from github or use `npm install jsoncrush` | ||
* Import JSONCrush as a module to your JavaScript program. | ||
* Import JSONCrush as a module with something like `import JSONCrush from './JSONCrush.js'` | ||
* Just pass a JSON string to `JSONCrush.crush()` to compress it! | ||
@@ -20,0 +20,0 @@ * To decode just pass the crushed string to `JSONCrush.uncrush()` |
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
36440
8
180