Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fairdatasociety/beeson-multiformats

codec for multiformats
https://github.com/fairdatasociety/beeson-multiformats

Last synced: 7 days ago
JSON representation

codec for multiformats

Awesome Lists containing this project

README

        

# 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](#install)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)

## Install

`npm install @fairdatasociety/beeson-multiformats`

## Usage

```typescript
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

- [molekilla](https://github.com/molekilla)

## License

[MIT](./LICENSE)