forked from paroga/cbor-js
-
-
Notifications
You must be signed in to change notification settings - Fork 4
The Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript.
License
arduino/cbor-js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The Concise Binary Object Representation (CBOR) data format (RFC 7049) implemented in pure JavaScript.
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.
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.
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
The Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript.
Resources
License
Security policy
Stars
Watchers
Forks
Sponsor this project
Packages 0
No packages published
Languages
- JavaScript 95.6%
- HTML 4.4%