ipfs-block

2019-08-16 admin

ipfs-block是什么

什么是ipfs-block,JavaScript Implementation of IPFS Block

ipfs-block使用教程帮助文档

IPLD Block JavaScript Implementation

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
  • Usage
    • Node.js
      • Example
    • Browser: Browserify, Webpack, other bundlers
    • Browser: <script> Tag
  • API
    • Block
      • new Block(data, cid)
      • block.data
      • block.cid
  • Contribute
  • License

Install

npm

> npm install ipld-block

Usage

Node.js

const Block = require('ipld-block')

Example

const Block = require('ipld-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('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: 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

你可能感兴趣的文章:

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-72651.html

文章标题:ipfs-block

回到顶部