Skip to content

Latest commit

 

History

History

lzw

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

LZW

LZW is a compression algorithm which can be used to compress a configuration into a smaller format for sharing. The LZW Utility offers two methods, .encode() and .decode().

Usage

import LZW from '@nycopportunity/pttrn-scripts/src/lzw/lzw';

Encode

let myConfig = {
  'key': 'value'
};

let myConfigBase64 = btoa(JSON.strinify(myConfig));

// Accepts a Base64 encoded string.
let myConfigLZW = LZW.encode(myConfigBase64);

Decode

let myConfig = JSON.parse(atob(LZW.decode(myConfigLZW)));

// Accepts a Base64 decoded string.
LZW.decode(myConfig);