ipfs-versidag

0.1.1 • Public • Published

ipfs-versidag

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

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.

Package Sidebar

Install

npm i ipfs-versidag

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

9.16 kB

Total Files

6

Last publish

Collaborators

  • satazor