node package manager

ipld

JavaScript implementation of the IPLD (InterpPlanetary Linked Data)

js-ipld

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

JavaScript implementation of the IPLD spec.

Installation

npm

> npm i ipld

Use in Node.js

const ipld = require('ipld')

Use in a browser with browserify, webpack or any other bundler

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 ipld = require('ipld')

Use in a browser Using a script tag

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

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

Usage

const ipld = require('ipld')
 
const file = {
  name: 'hello.txt',
  size: 11
}
 
// CBOR encoded Buffer 
const marshalled = ipld.marshal(file)
 
console.log(ipld.multihash(marshalled))
// => QmQtX5JVbRa25LmQ1LHFChkXWW5GaWrp7JpymN4oPuBSmL 
 
// Convert CBOR object to JavaScript object 
console.log(ipld.unmarshal(marshalled) === file)
// => true