beeson codec for multiformats
Block codec for multiformats
Warning: This project is in alpha state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.
npm install @fairdatasociety/beeson-multiformats
import * as Block from 'multiformats/block'
import { codec, hasher } from '@fairdatasociety/beeson-multiformats'
import { BeeSon, Type } from '@fairdatasociety/beeson'
let json = [0, '1', false, { name: 'john coke' }, 5]
const beeson = new BeeSon({ json })
const value = beeson
// encode a block
const block = await Block.encode({ value, codec, hasher })
// cid: `bah6acgzakjrglswz3olz3tvelmgypkn2r67ofl6jh3cnuqsy6zysmc7rqkcq`
// decode a block
const block2 = await Block.decode({
bytes: block.bytes,
codec,
hasher,
})
let bs = await block2.value
// json: [0, '1', false, { name: 'john coke' }, 5]
Support for beeson supertypes and container types is not available.