Skip to content

Commit 69e8161

Browse files
use export default
1 parent 15976b8 commit 69e8161

File tree

6 files changed

+21
-33
lines changed

6 files changed

+21
-33
lines changed

JSONCrush.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Typescript type definition for JSONCrush
2-
export type JSONCrush = {
2+
export default class {
33
crush(input: string, maxSubstringLength?: number): string;
44
uncrush(input: string): string;
55
};

JSONCrush.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
///////////////////////////////////////////////////////////////////////
2-
// JSONCrush v1.1.2 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush
2+
// JSONCrush v1.1.3 by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush
33
///////////////////////////////////////////////////////////////////////
44

5-
"use strict";
5+
'use strict';
66

7-
// ==ClosureCompiler==
8-
// @compilation_level ADVANCED_OPTIMIZATIONS
9-
// @language_out ECMASCRIPT_2019
10-
// @js_externs JSONCrush, JSONCrush.crush, JSONCrush.uncrush
11-
// ==/ClosureCompiler==
12-
13-
export const JSONCrush =
7+
export default
148
{
159

1610
crush: function(string, maxSubstringLength=50)

JSONCrush.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This simple system allows for excellent compression of uri encoded JSON strings
1414
# How to Use
1515

1616
* Download from github or use `npm install jsoncrush`
17-
* Import JSONCrush as a module to your JavaScript program.
17+
* Import JSONCrush as a module with something like `import JSONCrush from './JSONCrush.js'`
1818
* Just pass a JSON string to `JSONCrush.crush()` to compress it!
1919
* To decode just pass the crushed string to `JSONCrush.uncrush()`
2020
* See [index.html](https://github.com/KilledByAPixel/JSONCrush/blob/master/index.html) for a demonstration.

index.html

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
44
JSONCrush by Frank Force [MIT] https://github.com/KilledByAPixel/JSONCrush
55
- Based on JavaScript Crusher by @aivopaas [MIT] http://www.iteral.com/jscrush
6-
- GitHub Corner is Copyright (c) 2016 Tim Holman - http://tholman.com
76
87
-->
98
<html><head><title>JSONCrush Demo</title></head><body></body>
109
<h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
1110
This simple system allows for excellent compression of URI encoded JSON strings using JSCrush.
12-
<br>No additional libraries are used and minified code is less than 2k.
11+
<br>No additional libraries are used and minified code is less than 2k!
12+
<br><a href=https://github.com/KilledByAPixel/JSONCrush>See GitHub for more info.</a>
1313
<br>
1414
<br>Type JSON here: (or any string really)
15-
<br><textarea id=textarea_JSON cols=80 oninput=RunDemo() rows=8 placeholder="Enter JSON here."></textarea>
15+
<br><textarea id=textarea_JSON cols=80 rows=8 placeholder="Enter JSON here."></textarea>
1616
<br>
1717
<br>Crushed: (your string crushed with JSONCrush)
1818
<br><textarea disabled id=textarea_crushed_uri cols=80 rows=8></textarea>
@@ -21,24 +21,20 @@ <h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
2121
<br><textarea disabled id=textarea_uncrushed cols=80 rows=8></textarea>
2222
<br>
2323
<div id=div_crush_result></div>
24-
<br><button onclick=PreformUnitTests()>Preform Unit Tests</button>
25-
<br><br><br><div id=div_unit_test_results></div>
24+
<br><button id=button_unitTests>Preform Unit Tests</button>
25+
<br><br><div id=div_unit_test_results></div>
2626
<script type=module>
2727

28-
// Load JSONCrush module into global scope!
29-
import {JSONCrush} from './JSONCrush.js';
30-
window.JSONCrush = JSONCrush;
28+
'use strict';
3129

32-
</script>
33-
<script>
30+
// Here is an example of how to use JSON crush...
3431

35-
"use strict";
32+
// First import JSONCrush as a module.
33+
import JSONCrush from './JSONCrush.js';
3634

37-
function RunDemo()
35+
textarea_JSON.oninput =()=>
3836
{
39-
// Here is an example of how to use JSON crush...
40-
41-
// First get your string to crush.
37+
// Get your string to crush.
4238
const stringToCrush = textarea_JSON.value;
4339

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

56-
function PreformUnitTests()
52+
button_unitTests.onclick =()=>
5753
{
5854
// Some tests that can be run to ensure that JSONCrush is working correctly...
5955
let output = 'Unit Test Results...';
@@ -101,6 +97,4 @@ <h1>JSONCrush Demo - Compress JSON into URL friendly strings</h1>
10197
'aaaaaaaa',
10298
'This test should fail because delimiters \u0001\u0001\u0001\u0001 (\\u0001) will be removed.',
10399
];
104-
</script>
105-
<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>
106-
</body></html>
100+
</script></body></html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsoncrush",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Compress JSON in URL friendly strings",
55
"main": "JSONCrush.js",
66
"types": "JSONCrush.d.ts",

0 commit comments

Comments
 (0)