Skip to content

JavaScript implementation of the IPLD spec.

License

Notifications You must be signed in to change notification settings

psichi/js-ipld

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) {})

About

JavaScript implementation of the IPLD spec.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%