JSPM

  • Created
  • Published
  • Downloads 7860
  • Score
    100M100P100Q48448F
  • License MIT

JavaScript implementation of the IPLD (InterpPlanetary Linked Data)

Package Exports

  • ipld

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 (ipld) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

js-ipld

JavaScript implementation of the IPLD spec.

Description

Usage

IPLD contexts and types

console.log(ipld.context)
# { merkleweb: { mlink: 'http://merkle-link' } }
console.log(ipld.type)
# { mlink: 'http://merkle-link' }

expand an obj

var node = {
  data: 'aaah the data',
  mlink: 'QmdasdSHJKDADHAgimethehasssssh' // should be a valid IPFS hash
}

node['@context'] = ipld.context.merkleweb
console.log(ipld.expand(node))
# { data: 'aaah the data', 'http://merkle-link': 'QmdasdSHJKDADHAgimethehasssssh'}

marshal and unmarshal

var encoded = ipld.marshal(obj) // returns Buffer with CBOR encoded obj
var decoded = ipld.unmarshal(encoded)
ipld.unmarshalAsync(buf, function (err, decoded) {})