Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipfs-block

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-block

JavaScript Implementation of IPFS Block

  • 0.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.1K
decreased by-26.2%
Maintainers
2
Weekly downloads
 
Created
Source

IPFS Block JavaScript Implementation

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

Sauce Test Status

IPFS implementation of the Block data structure in JavaScript.

Block - A block is a blob of binary data.

Table of Contents

Install

npm

> npm i ipfs-block

Usage

Node.js

const Block = require('ipfs-block')
Example
const Block = require('ipfs-block')

// create a block
const block = new Block('hello world')
console.log(block.data)
block.key((err, key) => console.log(err, key))

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 IpfsBlock obj 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)
  • data: Buffer|String

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.key([hashAlg,] callback)
  • hashAlg: String, optional. Default sha2-256.
  • callback: Function

The callback will be called with the multihash of the block's data, as a buffer.

Contribute

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

This repository falls under the IPFS Code of Conduct.

License

MIT

Keywords

FAQs

Package last updated on 11 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc