Skip to content

Commit

Permalink
use export default
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Aug 7, 2021
1 parent 15976b8 commit 69e8161
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion JSONCrush.d.ts
Original file line number Diff line number Diff line change
@@ -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;
};
12 changes: 3 additions & 9 deletions JSONCrush.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions JSONCrush.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This simple system allows for excellent compression of uri encoded JSON strings
# How to Use

* 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!
* 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.
Expand Down
32 changes: 13 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

JSONCrush by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush
- Based on JavaScript Crusher by @aivopaas [MIT] http://www.iteral.com/jscrush
- GitHub Corner is Copyright (c) 2016 Tim Holman - http://tholman.com

-->
<html><head><title>JSONCrush Demo</title></head><body></body>
<h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
This simple system allows for excellent compression of URI encoded JSON strings using JSCrush.
<br>No additional libraries are used and minified code is less than 2k.
<br>No additional libraries are used and minified code is less than 2k!
<br><a href=https://github.com/KilledByAPixel/JSONCrush>See GitHub for more info.</a>
<br>
<br>Type JSON here: (or any string really)
<br><textarea id=textarea_JSON cols=80 oninput=RunDemo() rows=8 placeholder="Enter JSON here."></textarea>
<br><textarea id=textarea_JSON cols=80 rows=8 placeholder="Enter JSON here."></textarea>
<br>
<br>Crushed: (your string crushed with JSONCrush)
<br><textarea disabled id=textarea_crushed_uri cols=80 rows=8></textarea>
Expand All @@ -21,24 +21,20 @@ <h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
<br><textarea disabled id=textarea_uncrushed cols=80 rows=8></textarea>
<br>
<div id=div_crush_result></div>
<br><button onclick=PreformUnitTests()>Preform Unit Tests</button>
<br><br><br><div id=div_unit_test_results></div>
<br><button id=button_unitTests>Preform Unit Tests</button>
<br><br><div id=div_unit_test_results></div>
<script type=module>

// Load JSONCrush module into global scope!
import {JSONCrush} from './JSONCrush.js';
window.JSONCrush = JSONCrush;
'use strict';

</script>
<script>
// Here is an example of how to use JSON crush...

"use strict";
// First import JSONCrush as a module.
import JSONCrush from './JSONCrush.js';

function RunDemo()
textarea_JSON.oninput =()=>
{
// Here is an example of how to use JSON crush...

// First get your string to crush.
// Get your string to crush.
const stringToCrush = textarea_JSON.value;

// Just call JSON crush to crush your string!
Expand All @@ -53,7 +49,7 @@ <h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
textarea_uncrushed.value = uncrushed;
}

function PreformUnitTests()
button_unitTests.onclick =()=>
{
// Some tests that can be run to ensure that JSONCrush is working correctly...
let output = 'Unit Test Results...';
Expand Down Expand Up @@ -101,6 +97,4 @@ <h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
'aaaaaaaa',
'This test should fail because delimiters \u0001\u0001\u0001\u0001 (\\u0001) will be removed.',
];
</script>
<a href="https://github.com/KilledByAPixel/JSONCrush" target="_blank" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#5AF; color:#222; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
</body></html>
</script></body></html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 69e8161

Please sign in to comment.