cbor-edn
v0.1.0
Published
Parse CBOR Extended Diagnostic Notation as defined by [draft-ietf-cbor-edn-literals-11](https://www.ietf.org/archive/id/draft-ietf-cbor-edn-literals-11.html) and some CBOR working group discussions.
Downloads
16
Maintainers
Readme
cbor-edn
Parse CBOR Extended Diagnostic Notation as defined by draft-ietf-cbor-edn-literals-11 and some CBOR working group discussions.
To play with this, use the CBOR2 Playground.
Installation
npm install cbor-edn
API
Full API documentation is available.
Example:
import {parseEDN} from 'cbor-edn';
const bytes = parseEDN("[_2 h'010203']");
// 9a0000000143010203 in Uint8Array
Command Line
The CLI version of cbor-edn is useful only for diagnostic purposes. Usage:
edn [options] [diagnosticString]
Positional:
diagnosticString The string to parse. If not given, reads from stdin.
Options:
-a,--always Always add encoding indicators when re-encoding.
-n,--never Never add encoding indicators when re-encoding.
-f,--file Read file as input, if diagnosticString not given.
If "-", read stdin. May be given multiple times.
Default: "-".
-s,--startRule <rule> Entry point for the grammar. Default: "one_item"
Example:
$ npx edn "[_2 h'010203']"
bytes: 9a0000000143010203
0x9a0000000143010203
9a 00000001 -- Array (Length: 1 item)
43 -- [0] Bytes (Length: 3)
010203
js: [ Uint8Array(3) [ 1, 2, 3 ] ]
diagonstic recreated from js: "[_2 h'010203']"