lzwfloss.js

1.2.5 • Public • Published

About

Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978.

lzwFloss is a multithreaded javascript implementation using the Hamsters.js multithreading library.

Since processing happens in the background on the client in a non blocking fashion you can use this to compress any data going back and forth through typical xhr request while still providing a seamless user experience, also effective for compressing data for session & local storage.

Getting Started

Obtain a copy of the library by using one of the options below,

Node.js

  1. Install the library by running npm install lzwfloss.js
  2. Require the library into your app.js file
	var lzwFloss = require("lzwfloss.js");
  1. Ensure you have also required and initiated Hamsters.js as well like so
	var hamsters = require('hamsters.js');
	hamsters.init();

HTML

  1. Head over to the read me page for Hamsters.js and follow the instructions to add the library to your project
  2. Download a copy of the latest lzwFloss release version, or clone the repo locally
  3. Upload the lzwFloss.js library file to your server and add the script to your project as described below
	<!-- HTML4 and (x)HTML -->
	<script type="text/javascript" src="path/to/lzwFloss.js">

	<!-- HTML5 -->
	<script src="path/to/lzwFloss.js"></script>

Usage

  • Encode a string on a background thread
  lzwFloss.encode(stringToEncode, function(encodedString) {
    //Do something with encoded string
  });
  • Decode an already encoded string on a background thread
  lzwFloss.decode(stringToDecode, function(decodedString) {
    //Do something with decodedString
  });

Demo

You can find a jsfiddle demo example here demonstrating text encoding and decoding using Hamsters.js using a single background thread for encoding and decoding.

Dependents (0)

Package Sidebar

Install

npm i lzwfloss.js

Weekly Downloads

1

Version

1.2.5

License

Artistic-2.0

Last publish

Collaborators

  • advanced.kinetic.systems