🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

cbor-js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor-js

The Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript.

0.1.0
latest
Source
npm
Version published
Weekly downloads
239K
-1.85%
Maintainers
1
Weekly downloads
 
Created
Source

cbor-js

The Concise Binary Object Representation (CBOR) data format (RFC 7049) implemented in pure JavaScript.

Build Status Coverage Status Dependency status Dev Dependency Status Selenium Test Status

Selenium Test Status

API

The CBOR-object provides the following two functions:

CBOR.decode(data)

Take the ArrayBuffer object data and return it decoded as a JavaScript object.

CBOR.encode(data)

Take the JavaScript object data and return it encoded as a ArrayBuffer object.

Usage

Include cbor.js in your or HTML page:

<script src="path/to/cbor.js" type="text/javascript"></script>

Then you can use it via the CBOR-object in your code:

var initial = { Hello: "World" };
var encoded = CBOR.encode(initial);
var decoded = CBOR.decode(encoded);

After running this example initial and decoded represent the same value.

Combination with WebSocket

The API was designed to play well with the WebSocket object in the browser:

var websocket = new WebSocket(url);
websocket.binaryType = "arraybuffer";
...
websocket.onmessage = function(event) {
  var message = CBOR.decode(event.data);
};
...
websocket.send(CBOR.encode(message));

Keywords

cbor

FAQs

Package last updated on 08 Jan 2016

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