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

codecs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codecs

Create an binary encoder/decoder for json, utf-8 or custom types

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
decreased by-65.22%
Maintainers
1
Weekly downloads
 
Created
Source

codecs

Create an binary encoder/decoder for Node's build in types like, json, utf-8, hex.

npm install codecs

build status

Useful to support value encodings similar to leveldb's.

Usage

var codecs = require('codecs')
var json = codecs('json')

console.log(json.encode({hello: 'world'})) // new Buffer('{"hello":"world"}')
console.log(json.decode(new Buffer('{"hello":"world"}'))) // {hello: 'world'}

API

var codec = codecs(type)

Create a new codec.

Supported types are

  • utf8
  • json
  • binary
  • hex
  • ascii
  • base64
  • ucs2
  • ucs-2
  • utf16le
  • utf-16le
  • binary

If an unknown type is passed in binary is used. If you want to use a custom codec you can pass in an object containing a an encode and decode method and that will be returned.

var buf = codec.encode(value)

Encode a value to a buffer.

var value = codec.decode(buf)

Decode a buffer to a value.

License

MIT

FAQs

Package last updated on 11 Mar 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