ipfs-block

2019-08-16

JavaScript Implementation of IPFS Block

IPFS Block JavaScript Implementation

standard-readme compliantTravis CICoverage StatusDependency Statusjs-standard-style

IPFSimplementation of the Block data structure in JavaScript.

Block- A block is a blob of binary data.

Lead Maintainer

Volker Mische

Table of Contents

Install

npm

> npm install ipfs-block

Usage

Node.js

const Block = require('ipfs-block')

Example

const Block = require('ipfs-block')

// create a block
const block = new Block(new Buffer('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('ipfs-block')

Browser: <script>Tag

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

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

API

const Block = require('ipfs-block')

Block

new Block(data, cid)

  • data: Buffer

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

HomePage

https://github.com/ipfs/js-ipfs-block#readme

Repository

https+https://github.com/ipfs/js-ipfs-block


上一篇:ipfs-utils
下一篇:flatmap
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部