0.15.3
Installable via npm install --save ipld-dag-cbor
, it can also be used directly in the browser.
The source is available for download from GitHub. Alternatively, you can install using npm:
$ npm install --save ipld-dag-cbor
You can then require()
ipld-dag-cbor as normal:
const ipldDagCbor = require('ipld-dag-cbor')
Ipld-dag-cbor should work in any ES2015 environment out of the box.
Usage:
<script type="text/javascript" src="index.js"></script>
The portable versions of ipld-dag-cbor, including index.js
and index.min.js
, are included in the /dist
folder. Ipld-dag-cbor can also be found on unpkg.com under
Configure the underlying CBOR decoder.
(Object?)
The options the decoder takes. The decoder will reset to the defaul values if no options are given.
Name | Description |
---|---|
options.size number
(default 65536 )
|
The current heap size used in CBOR parsing, this may grow automatically as larger blocks are encountered up to
maxSize
|
options.maxSize number
(default 67108864 )
|
The maximum size the CBOR parsing heap is allowed to grow to before
dagCBOR.util.deserialize()
returns an error
|
options.tags Object?
|
An object whose keys are CBOR tag numbers and values are transform functions that accept a
value
and return a decoded representation of that
value
|
Serialize internal representation into a binary CBOR block.
(Object)
Internal representation of a CBOR block
Buffer
:
The encoded binary representation
Deserialize CBOR block into the internal representation.
(Buffer)
Binary representation of a CBOR block
Object
:
An object that conforms to the IPLD Data Model
Calculate the CID of the binary blob.
(Object)
Encoded IPLD Node
Promise<CID>
:
Resolves a path within a CBOR block.
Returns the value or a link and the partial mising path. This way the IPLD Resolver can fetch the link and continue to resolve.
(Buffer)
Binary representation of a CBOR block
(string
= '/'
)
Path that should be resolved
Object
:
result - Result of the path it it was resolved successfully
any
:
result.value - Value the path resolves to
string
:
result.remainderPath - If the path resolves half-way to a
link, then the
remainderPath
is the part after the link that can be used
for further resolving
Return all available paths of a block.
(Buffer)
Binary representation of a CBOR block