Package Exports
- ipfs-block
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ipfs-block) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
IPFS Block JavaScript Implementation
IPFS implementation of the Block data structure in JavaScript.
Description
Block - A block is a blob of binary data.
Example
const Block = require('ipfs-block')
// create a block
const block = new Block('hello world')
console.log(block.data)
console.log(block.key)
Installation
npm
> npm i ipfs-block
Setup
Node.js
const Block = require('ipfs-block')
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.
var Block = require('ipfs-block')
Browser: <script>
Tag
Loading this module through a script tag will make the IpfsBlock
obj available in
the global namespace.
<script src="https://npmcdn.com/ipfs-block/dist/index.min.js"></script>
<!-- OR -->
<script src="https://npmcdn.com/ipfs-block/dist/index.js"></script>
API
const Block = require('ipfs-block')
Block
new Block(data, [type])
Creates a new block with raw data data
. type
can be either 'protobuf'
or 'ipld'
block.data
The raw data of the block. Its format matches whatever was provided in its constructor.
block.key
The multihash of the block's data, as a buffer.
block.extension
The extension on how to store the blog, depends on the type:
'protobuf'
:'data'
'ipld'
:'ipld'
License
MIT