JavaScript Implementation of IPLD Block
npm install ipld-block









> [IPLD][ipld] implementation of the Block data structure in JavaScript.
Block - A block is a blob of binary data combined with a [CID].
- IPLD Block JavaScript Implementation
- Lead Maintainer
- Table of Contents
- Install
- npm
- Usage
- Node.js
- Example
- Browser: Browserify, Webpack, other bundlers
- Browser: Tag
- API
- Block
- new Block(data, cid)
- block.data
- block.cid
- Contribute
- License
``sh`
> npm install ipld-block
`js`
const Block = require('ipld-block')
#### Example
`js
const Block = require('ipld-block')
const encoder = new TextEncoder('utf8')
// create a block
const block = new Block(encoder.encode('hello world'), cid)
console.log(block.data.toString())
`
The code published to npm that gets loaded on require is in fact a ES5
transpiled version with the right shims added. This means that you can require
it and use with your favourite bundler without having to adjust asset management
process.
`js`
const Block = require('ipld-block')
Loading this module through a script tag will make the IpldBlock obj available in
the global namespace.
`html`
`js`
const Block = require('ipld-block')
#### new Block(data, cid)
- data: Uint8Array
Creates a new block with raw data data.
#### block.data
The raw data of the block. Its format matches whatever was provided in its constructor.
#### block.cid`
The cid of the block.
[ipld]: https://ipld.io/
[multihash]: https://github.com/multiformats/js-multihash
[CID]: https://github.com/multiformats/js-cid
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
