Package Exports
- @kunigi/string-compression
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@kunigi/string-compression) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
string-compression
Reduces the size of strings. Has zero dependencies. Made possible by the very efficient JSCrush algorithm.
Install
npm install @kunigi/string-compressionUsage
Here's an example with a simple string
import {encode, encodeURI, decode, decodeURI } from '@kunigi/string-compression'
encode('hello world!') // hello world':_
encodeURI('hello world!') // hello%20world':_
decode(`hello world':_`) // hello world!
decodeURI(`hello%20world':_`) // hello world!Here's an example with an JSON object.
import {encode, encodeURI, decode, decodeURI } from '@kunigi/string-compression'
const simpleObject = { x: 1, y: 2 }
const encodedJSON = encode(JSON.stringify(simpleObject)) // ('x!1~y!2)_
const encodedURLSafeJSON = encodeURI(JSON.stringify(simpleObject)) // %7B!x(1,!y(2%7D!%22(!:(!_
JSON.parse(decode(encodedJSON)) //
JSON.parse(decodeURI(encodedURLSafeJSON)) //Credits
This project involved work of others. All referred source code and including this project are licensed under MIT.
A special shoutout to
- JSONCrush by Frank Force (KilledByAPixel)
- JSCrush by aivopaas