All Projects → ipld → js-ipld-block

ipld / js-ipld-block

Licence: MIT license
Implementation of the Block data structure in JavaScript.

Programming Languages

javascript
184084 projects - #8 most used programming language

IPLD Block JavaScript Implementation

This project is no longer maintained and has been archived. See https://github.com/multiformats/js-multiformats or https://ipld.io for details on the latest methods for interacting with IPLD data in JavaScript.

standard-readme compliant Travis CI Coverage Status Dependency Status js-standard-style

IPLD implementation of the Block data structure in JavaScript.

Block - A block is a blob of binary data combined with a CID.

Lead Maintainer

Volker Mische

Table of Contents

Install

npm

> npm install ipld-block

Usage

Node.js

const Block = require('ipld-block')

Example

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())

Browser: Browserify, Webpack, other bundlers

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.

const Block = require('ipld-block')

Browser: <script> Tag

Loading this module through a script tag will make the IpldBlock obj available in the global namespace.

<script src="https://unpkg.com/ipld-block/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipld-block/dist/index.js"></script>

API

const Block = require('ipld-block')

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.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].