diff --git a/JSONCrush.d.ts b/JSONCrush.d.ts index 8e8c1cd..f4b3b09 100644 --- a/JSONCrush.d.ts +++ b/JSONCrush.d.ts @@ -1,5 +1,5 @@ // Typescript type definition for JSONCrush -export type JSONCrush = { +export default class { crush(input: string, maxSubstringLength?: number): string; uncrush(input: string): string; }; \ No newline at end of file diff --git a/JSONCrush.js b/JSONCrush.js index d61dd9b..1e169a3 100644 --- a/JSONCrush.js +++ b/JSONCrush.js @@ -1,16 +1,10 @@ /////////////////////////////////////////////////////////////////////// -// 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 { crush: function(string, maxSubstringLength=50) diff --git a/JSONCrush.min.js b/JSONCrush.min.js index ed9fd96..04af5bd 100644 --- a/JSONCrush.min.js +++ b/JSONCrush.min.js @@ -1,2 +1,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=m||55296<=n&&56319>=n)){m=1;for(n=a.indexOf(e,k+g);0<=n;++m)n=a.indexOf(e,n+g);1d)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);1h.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=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=m||55296<=n&&56319>=n)){m=1;for(n=a.indexOf(e,k+g);0<=n;++m)n=a.indexOf(e,n+g);1d)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);1h.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 JSONCrush Demo

JSONCrush Demo - Compress JSON into URL friendly strings

This simple system allows for excellent compression of URI encoded JSON strings using JSCrush. -
No additional libraries are used and minified code is less than 2k. +
No additional libraries are used and minified code is less than 2k! +
See GitHub for more info.

Type JSON here: (or any string really) -
+


Crushed: (your string crushed with JSONCrush)
@@ -21,24 +21,20 @@

JSONCrush Demo - Compress JSON into URL friendly strings



-
-


+
+

- - - \ No newline at end of file + \ No newline at end of file diff --git a/package.json b/package.json index e002e46..50fcf72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsoncrush", - "version": "1.1.2", + "version": "1.1.3", "description": "Compress JSON in URL friendly strings", "main": "JSONCrush.js", "types": "JSONCrush.d.ts",