Giter VIP home page Giter VIP logo

js-string-compression's Introduction

js-string-compression

Package provides javascript for string compression

Build Status Coverage Status

Install

npm install js-string-compression

Usage

var jsscompress = require("js-string-compression");

var raw_text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";

var hm = new jsscompress.Hauffman();
var compressed = hm.compress(raw_text);

console.log("before compressed: " + raw_text);
console.log("length: " + raw_text.length);
console.log("after compressed: " + compressed);
console.log("length: " + compressed.length);

console.log("decompressed: " + hm.decompress(compressed));

js-string-compression's People

Contributors

cschen1205 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

js-string-compression's Issues

compress repeated chains

> const c = require('js-string-compression');
> const h = new c.Hauffman();
> h.compress('foo'.repeat(10)).length
7
> h.compress('foo'.repeat(1000)).length
378

Decompress wrong with data JSON.stringify

Code

var jsscompress = require("js-string-compression");

var raw_text = `{"data":"test"}`;

var hm = new jsscompress.Hauffman();
var compressed = hm.compress(raw_text);

console.log("before compressed: " + raw_text);
console.log("length: " + raw_text.length);
console.log("length: " + compressed.length);

console.log("decompressed: " + hm.decompress(compressed));

Output

before compressed: {"data":"test"}
raw length: 15
compressed length: 17
decompressed: {"data":"test"}t
decompressed length: 16

Expected:

before compressed: {"data":"test"}
raw length: 15
compressed length: <=15
decompressed: {"data":"test"}
decompressed length: 15

In this case, compressed length > before compressed!

initialization fails

Hi there, interesting library, It can't seem to initialize in my react native app, I keep getting this error 'undefined is not a constructor (evaluating 'new jsscompress.Hauffman())'. please your kind help will be appreciated. thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.