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

a-msgpack

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-msgpack

A minimalistic MessagePack encoder and decoder for JavaScript.

  • 0.1.42
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
increased by425%
Maintainers
1
Weekly downloads
 
Created
Source

a-msgpack

A minimalistic MessagePack encoder and decoder for JavaScript.

  • Tiny Size (2.63 kB minified and gzipped)
  • Fast performance (Slightly faster than msgpack-lite)
  • Extension support
  • No other bells or whistles

By default, msgpack can encode numbers, strings, booleans, nulls, arrays, objects, and binary data (Uint8Array). However, additional types can be registered by using extensions.

Installation

npm install --save tiny-msgpack

Usage

var msgpack = require('tiny-msgpack');

var uint8array = msgpack.encode({foo: 'bar', baz: 123});
var object = msgpack.decode(uint8array);

Extensions

var msgpack = require('tiny-msgpack');
var codec = new msgpack.Codec;

function encodeDate(date) {
  return msgpack.encode(+date);
}
function decodeDate(uint8array) {
  return new Date(msgpack.decode(uint8array));
}
codec.register(0x42, Date, encodeDate, decodeDate);

var uint8array = msgpack.encode({timestamp: new Date}, codec);
var object = msgpack.decode(uint8array, codec);
console.log(object.timestamp instanceof Date); // => true

Browser Support

In the browser, tiny-msgpack requires the Encoding API, which is currently only implemented by Chrome and Firefox. However, if you polyfill it, this package is supported by the following browsers:

  • Chrome 9+
  • Firefox 15+
  • Safari 5.1+
  • Opera 12.1+
  • Internet Explorer 10+

Zero copy

In the MessagePack format, binary data is encoded as... binary data! To maximize performance, tiny-msgpack does not copy binary data when encoding or decoding it. So after decoding, the contents of a returned Uint8Array can be affected by modifying the input Uint8Array (the same can happen with encoding).

License

MIT

Keywords

FAQs

Package last updated on 04 Sep 2019

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