Skip to content

Commit

Permalink
Prep for patch
Browse files Browse the repository at this point in the history
  • Loading branch information
zerodevx committed Sep 26, 2024
1 parent e0d8b29 commit fe6f358
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 143 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

> Generate **gzip** web-safe strings on the browser. Built in 10 minutes. :smile:
Dead simple mash-up of [pako](https://github.com/nodeca/pako) and
[js-base64](https://github.com/dankogai/js-base64) to create **gzipped** URL-safe base64 strings
Dead simple mash-up of [`pako`](https://github.com/nodeca/pako) and
[`js-base64`](https://github.com/dankogai/js-base64) to create **gzipped** URL-safe base64 strings
from any data on the browser. Very useful for passing large datasets via shareable web links.

48kb minified, 15kb **gzipped**, pun not intended.
Expand All @@ -14,7 +14,7 @@ This package is used in [JSON Pretty Print Online](https://zerodevx.github.io/js
compress and share stringified JSON with URL query params.

See it in action
[here](https://zerodevx.github.io/json-pretty-print/?data=H4sIAAAAAAAAA7WaXXOkNhaG7_MrtK692FQaAgIE8tU4tmfjxJ7MepykUklqS4Do1g4NHT5sd1L73_foC2g3bXs83krF0wLpICHpOe854tcvEPoL_kfo6N8iPzpGR8SLKWFBESakIJnvJYkfZn4YHS10NVHl_B4qeqa87E27mMShz1InS7PQCUmWOkkUJg4hHityFjCSpoON9iTrxC2Hdl3Tc3M1ZSWrMnnx6O94QXDiJtS22Iis6xt1b9V1m-Ovv96ULOOrusxd0X0d4PsA27psKesFoSnyLT-ty7qRbdOmvqtsvYqtlcHLuqkY-lDWbLi15DBK1aLga1Zyez2r1xtWbeWN9z9c31ycntg7UE2U8noprbXS2JtN3XQiYy60Gsaxqiv10K989A_qh1-i0KMOjnAy9D7PG962so4fxOikgr6d1n3TLdB5Kf5kt6Is-QK943foit-LrF4g6sX-0Dyt-042Pu9QLofNEavEGq3ZEgyxUvzRM9SKqkObphY5hx9rISuIHG1YIxi8ZsR7aIu4vMxysRGtyES1dNHJmnfTK6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JByc3XhIGWvqvaq5qtOQaWV-VrUkVBz_IeELqOOOCHo8kGo3Nd4-l8DX2DBOlAwWIFW_tbUHLCSMhcr74AN4s9hhaWMEaL24TYYtzdsZlL7hdmljkGDdtda2g-j3BdOfySQNRmmlkqNWo9xYe-PDn6kmoWJ-8RRtKq2Ap1uCqrqjOnoFGy84LoZ0z2dPnKshhnvHEUIGzbpEY29nmg5d1TMCRbdkzEhY-GoG5whO4JtkSlyMaan2BnlE3aGeQG7xQTOOSDPGo9C4sc4SJY4CoLEJywl1OURYHj0KroFNX43mWtXw8WV6J_J5gJD4EgACrWwSCscuuZtt-dgTcC9tOv5XI6uQW-PJT4cwb3U1DwaeEQ0okVURiyL0yiJk5k_dM58lJjmBFMv41nsRRHLvbQoC09EAVdvZuAAKJ97A4OJyjx9WiJ3EXhcN01xQl_BgjX3_PQkgL68evv2-vK1w5-Dqry3dV9lsMQHUawRCCdAoAR8dPKnACSKGTqHcVRyeg8DfrbtxvcwTdvv1ZWmkopDJMap-y5mNXtpXISR9ZixNOKyjseqRccAU64AsPNaJUaACDpBMr0gMa0pOU4BjjYX8xsUAwXTOJBDSdQWnbMwk1dZxEoLxBkvMqWHDXXAkU0QWHR4Svy6PkSXWI5yfvKEFsszY60-OM9U5sdCbGKTJo6BnH7UlGge2_XRrXmgcoyKZMa4jeUmf7c8LTo5xYE--g_Uml-SaaeoH2gMn15IA9XVI8G-fHMG8Rj8Eg_UhwF-wVlAz-LVHIyXJCrbgnG0wF-sMo5RyIjrxhZcG5aZGHWawIfdJYoleis-Db9vZAv9rdEl7I6m71fodyN3uw5Oa167eWHixIQCTAsHRQ_A5nUALjXvMDB-CQN_-T_JtmU7hx4AAA/).

## Install

Expand All @@ -26,10 +26,10 @@ $ npm i -D zipurl

### In the browser

#### Use locally
#### Via CDN

```html
<script src="path/to/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/zipurl@1"></script>
<script>
console.log(zipurl('hello world!')) // H4sIAAAAAAAAA8tIzcnJVyjPL8pJUQQAbcK0AwwAAAA
console.log(unzipurl('H4sIAAAAAAAAA8tIzcnJVyjPL8pJUQQAbcK0AwwAAAA')) // hello world!
Expand All @@ -38,10 +38,10 @@ $ npm i -D zipurl

The functions `zipurl()` and `unzipurl()` are available in the global (`window`) scope.

#### Or without installation via CDN
### Or locally

```html
<script src="https://cdn.jsdelivr.net/npm/zipurl@1"></script>
<script src="path/to/dist/index.min.js"></script>
```

#### Or with a bundler
Expand All @@ -52,7 +52,7 @@ import { zipurl, unzipurl } from 'zipurl'

### In Node.js

#### With ESM
#### ESM

```js
import { zipurl, unzipurl } from 'zipurl'
Expand All @@ -61,7 +61,7 @@ console.log(zipurl('hello world!')) // H4sIAAAAAAAAA8tIzcnJVyjPL8pJUQQAbcK0AwwAA
console.log(unzipurl('H4sIAAAAAAAAA8tIzcnJVyjPL8pJUQQAbcK0AwwAAAA')) // hello world!
```

#### With CJS
#### CJS

```js
const { zipurl, unzipurl } = require('zipurl')
Expand Down Expand Up @@ -107,17 +107,16 @@ That's it!

Ok, so it works much better with larger datasets:

<!-- prettier-ignore -->
```js
const a = JSON.stringify(`{"students":[{"name":"Jack","age":17},{"name":"Jill","age":16},
{"name":"Sue","age":16}],"class":"math"}`)
const a = JSON.stringify({"students":[{"name":"Jack","age":17},{"name":"Jill","age":16},{"name":"Sue","age":16}],"class":"math"})

console.log(a.length) // 103 bytes
console.log(encodeURIComponent(a).length) // 199 bytes
console.log(zipurl(a).length) // 116 bytes

// Let's try something bigger (3122 bytes)
const b =
JSON.stringify(`{"shaderStatements":[{"output":"b","outputSwizzle":"zxyw","assignmentOperator":"-=",
const b = JSON.stringify({"shaderStatements":[{"output":"b","outputSwizzle":"zxyw","assignmentOperator":"-=",
"functionName":"","parameter":"a","valueX":6.62,"valueY":6.165,"valueZ":-0.974,"valueW":-4.233,"parameterSwizzle":"xzyy"},
{"output":"b","outputSwizzle":"ywxz","assignmentOperator":"-=","functionName":"","parameter":"a","valueX":-4.88,
"valueY":0.649,"valueZ":0.171,"valueW":-0.084,"parameterSwizzle":"yzwx"},{"output":"a","outputSwizzle":"xzwy",
Expand All @@ -144,8 +143,9 @@ const b =
"randSeedString":"1574121532870","iterationCount":1,"gridPosX":4,"gridPosY":0,"generation":17,"subGeneration":1,
"hueOffset":0.218,"hueScale":-0.789,"saturationScale":0.493,"uvOffsetX":-0.36,"uvOffsetY":0.559,"uvScaleX":1.02,
"uvScaleY":-1.143,"rotate":0,"usePalette":0,"paletteColors":[{"x":0.041,"y":0.01,"z":0.584},{"x":0.131,"y":0.102,
"z":0.658},{"x":0.9,"y":0.855,"z":0.917},{"x":0.797,"y":0.882,"z":0.478}],"saveListIndex":-1,"uniqueID":361315861}`)
"z":0.658},{"x":0.9,"y":0.855,"z":0.917},{"x":0.797,"y":0.882,"z":0.478}],"saveListIndex":-1,"uniqueID":361315861})

console.log(b.length) // 3122 bytes
console.log(encodeURIComponent(b).length) // 4952 bytes
console.log(zipurl(b).length) // 1120 bytes - 77.4% reduction in size :)
```
Expand Down
Loading

0 comments on commit fe6f358

Please sign in to comment.