Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from paroga/cbor-js

An up-to-date (2020) fork of paroga/cbor-js that merges the open pull requests of the original and aims to resolve remaining open issues. Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript.

License

Notifications You must be signed in to change notification settings

spaceify/cbor-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an up-to-date fork of the paroga/cbor-js by Patrick Gansterer. In early 2020, we were searching for a Javascript CBOR library, and found the excellent paroga/cbor-js, which sadly had not been updated for several years. Because we really needed a CBOR library in our projects, we decided to fork the repository and bring it up-to-date.

Goals of this fork:

  • Merge all open pull requests of the original paroga/cbor-js (DONE)
  • Resolve open issues of the original paroga/cbor-js (PARTLY DONE)
  • Optimize for speed (TBD)
  • Add more tests and benchamrking (TBD)
  • Add support for tagging (TBD)
  • Publish on npm (TBD)

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));

About

An up-to-date (2020) fork of paroga/cbor-js that merges the open pull requests of the original and aims to resolve remaining open issues. Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 95.1%
  • HTML 4.9%