Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
/ dag-cbor-sync Public archive

Synchronous serialize/deserialize for IPLD dag-cbor.

Notifications You must be signed in to change notification settings

mikeal/dag-cbor-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synchronous seralization/deserialization for dag-cbor nodes

Usage:

let cbor = require('dag-cbor-sync')()
let buffer = cbor.serialize({test: 1234})
let obj = cbor.deserialize(buffer)

With links

let buffer = cbor.serialize(
  /* Object with single '/' property of a base encoded CID represents
     a link
  */
  {test: {'/': 'zdpuAkv7jA671owT26AnJiFXG9usHmCAW6MTzpwFJw46X1PLG'}}
)
let obj = cbor.deserialize(buffer)
Buffer.isBuffer(obj.test['/']) // true

require('dag-cbor-sync')([maxsize])

Optionally set the maximum size of the cbor node. Node's larger will throw an exception.

serialize(object)

Returns a buffer of the binary representation of the object.

deserialize(buffer)

Returns the native representation.

Note the link CID's will already be converted to buffers.

About

Synchronous serialize/deserialize for IPLD dag-cbor.

Resources

Stars

Watchers

Forks

Packages

No packages published