Package Exports
- ipld-dag-cbor
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-dag-cbor) 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-dag-cbor
JavaScript implementation of the IPLD spec.
Table of Contents
Install
npm
> npm i ipldUse 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://unpkg.com/ipld/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.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)
// => trueContribute
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
