Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dictionary-encoding

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dictionary-encoding

Simple binary dictionary compression scheme

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

dictionary-encoding stability

npm version build status test coverage downloads js-standard-style

Simple binary dictionary compression scheme. It takes a dictionary whose ids are integers, and a string or array of strings to compress according to the dictionary provided. Decomposing strings into parts that may be represented by the dictionary is left to a higher order module which would use this one to manage efficient encoding.

Usage

const encode = require('dictionary-encoding').encode
const decode = require('dictionary-encoding').decode


const dictionary = {
  'hello': '1',
  'world': '2',
  'ya\'ll': '3',
  ',': '4'
}

const invertedDictionary = {
  '1': 'hello',
  '2': 'world',
  '3': 'ya\'ll',
  '4': ','
}

encode(dictionary, ['hello', 'world', ',', 'ya\'ll'], function (err, buffer) {
  decode(invertedDictionary, buffer, function (err, arr) {
    console.log(arr) // ['hello', 'world', ',', 'ya\'ll']
  })
})

API

dictionaryEncoding

  • encode(dictionary, data, [cb]) Encode takes a dictionary and swaps each item with the value stored under the dictionary key. This function either returns a length prefixed stream of VLQ encoded buffers, or takes a callback which is provided a concatenation of the buffers that would otherwise be streamed.

  • decode(dictionary, data, [cb]) Encode takes a dictionary and swaps each item with the value stored under the dictionary key. This function either returns an object stream of strings, or takes a callback which is provided an array of the strings that would otherwise be streamed.

Installation

$ npm install dictionary-encoding

License

MIT

FAQs

Package last updated on 06 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc