Giter Site home page Giter Site logo

codacy-badger / arithmetic-coding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from upupming/arithmetic-coding

0.0 0.0 0.0 572 KB

:wrench: Arithmetic coding algorithm implemented in Node.js, both API and CLI support. 算数编码 npm 包,支持 API 调用和 CLI。

License: MIT License

JavaScript 100.00%

arithmetic-coding's Introduction

arithmetic-coding

travis build status License Coveralls npm

Installation

Install as module for API usage:

npm i arithmetic-coding

Or install as global CLI:

npm i -g arithmetic-coding

API

From file path:

const ariCoding = require('arithmetic-coding');
// Encode from file
ariCoding.encode(__dirname + '/txt/long.txt', __dirname + '/txt/long-encoded.txt');
// Decode from file
ariCoding.decode(__dirname + '/txt/long-encoded.txt', __dirname + '/txt/long-decoded.txt');

From Buffer:

let data = Buffer.from('Example data', 'utf8');
// Encode from Buffer
let encoded = encode.encodeFromBuffer(data);
console.log(`encoded = ${encoded}`);
// Decode from Buffer
let decoded = decode.decodeFromBuffer(encoded);
console.log(`decoded = ${decoded}`);

Command-line interface

$ ari-coding -h
Usage: index [options] [command]

Options:
  -v, --version              output the version number
  -h, --help                 output usage information

Commands:
  encode|e [options] <file>  encode a file
  decode|d [options] <file>  decode a file

$ ari-coding encode -h
Usage: encode|e [options] <file>

encode a file

Options:
  -o, --output <file>  output file path
  -h, --help           output usage information

Performance

You can see the latest travis test for running time used by each test.

Some benchmarks are shown below:

File size (Bytes) total time encode time decode time
60640 110ms small 110ms
2130640 2940ms 426ms 2514ms

About the algorithm

  1. Wikipedia
  2. How to implement practical encoder/decoder
  3. Reference-arithmetic-coding on GitHub

arithmetic-coding's People

Contributors

upupming avatar

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.