@fairdatasociety/beeson-multiformats
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

beeson-multiformats

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.

Table of Contents

Install

npm install @fairdatasociety/beeson-multiformats

Usage

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]

Notes

Support for beeson supertypes and container types is not available.

Maintainers

License

MIT

Package Sidebar

Install

npm i @fairdatasociety/beeson-multiformats

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

524 kB

Total Files

20

Last publish

Collaborators