@lazy-ipfs/ipfs-versidag
v0.1.3
Published
Concurrent version history based on a Merkle-DAG on top of IPFS and IPLD
Downloads
3
Maintainers
Readme
ipfs-versidag
Concurrent version history based on a Merkle-DAG on top of IPFS and IPLD.
This module wraps versidag and automatically configures readNode
and writeNode
to use IPFS and IPLD.
version + dag = versidag
Installation
$ npm install ipfs-versidag
You must also install ipfs
as it is a peer dependency of this module.
Usage
import IPFS from 'ipfs';
import createIpfsVersidag from 'ipfs-versidag';
const ipfs = new IPFS();
ipfs.on('ready', async () => {
const myVersidag = createIpfsVersidag({
ipfs,
tieBreaker: (node1, node2) => /* */,
});
const myVersidagA = await myVersidag.add('Hi', 1);
const myVersidagB = await myVersidagA.add('Hello', 2);
const myVersidagC = await myVersidagA.add('Hi World', 3);
const myVersidagD = await myVersidagB.merge(myVersidagC.headCids, 'Hello World');
const versions = await myVersidagD.resolve();
// [
// { version: 'Hello World' },
// { version: 'Hi World', meta: 3 }
// { version: 'Hello', meta: 2 }
// { version: 'Hi', meta: 1 }
// ]
});
You may use the IPLD explorer to inspect the Merkle DAG.
API
Please refer to the versidag API.
Tests
$ npm test
$ npm test -- --watch # during development
License
Released under the MIT License.