{"id":13483147,"url":"https://github.com/emilbayes/hypercore-dag","last_synced_at":"2025-09-13T15:32:24.247Z","repository":{"id":57270153,"uuid":"70547380","full_name":"emilbayes/hypercore-dag","owner":"emilbayes","description":"DAGs on top of hypercore, allowing verified random-access to graph nodes","archived":false,"fork":false,"pushed_at":"2016-10-11T03:37:26.000Z","size":7,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T00:15:42.979Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emilbayes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-11T02:21:48.000Z","updated_at":"2022-12-28T19:40:53.000Z","dependencies_parsed_at":"2022-08-25T02:51:35.608Z","dependency_job_id":null,"html_url":"https://github.com/emilbayes/hypercore-dag","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilbayes%2Fhypercore-dag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilbayes%2Fhypercore-dag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilbayes%2Fhypercore-dag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilbayes%2Fhypercore-dag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emilbayes","download_url":"https://codeload.github.com/emilbayes/hypercore-dag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232889164,"owners_count":18592314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:08.602Z","updated_at":"2025-01-07T13:48:42.186Z","avatar_url":"https://github.com/emilbayes.png","language":"JavaScript","funding_links":[],"categories":["Modules"],"sub_categories":[],"readme":"# `hypercore-dag`\n\n\u003e DAGs on top of hypercore, allowing verified random-access to graph nodes\n\n## Usage\n\n```js\n'use strict'\n\nvar assert = require('assert')\n\nvar hypercore = require('hypercore')\nvar memdb = require('memdb')\nvar hypercoreDag = require('.')\n\nvar core = hypercore(memdb())\nvar dag = hypercoreDag(core.createFeed({\n  sparse: true // Set this to true if you only want to download nodes as you're walking the graph\n}))\n\n// We're building the following graph (Time on x axis, depth on y axis)\n// 0     2\n// \\- 1  \\\n//    \\--\\-- 3\n\ndag.add(null, 'Root', function (err, ref0) {\n  assert.ifError(err)\n\n  dag.add(ref0, 'Child 1', function (err, ref1) {\n    assert.ifError(err)\n\n    dag.add(null, 'Another root', function (err, ref2) {\n      assert.ifError(err)\n\n      dag.add([ref0, ref1, ref2], 'Tie them', function (err, ref3) {\n        assert.ifError(err)\n\n        dag.get(ref3, function (err, node) {\n          assert.ifError(err)\n\n          assert.deepEqual(node.links, [0, 1, 2])\n          assert.equal(node.depth, 2)\n          assert.equal(node.value, 'Tie them')\n        })\n      })\n    })\n  })\n})\n\n```\n\n## API\n\n### `hypercoreDag(feed, [opts])`\n\n`opts` being `{lock: mutexify()}`\n\n### `dag.add(links, value, [callback])`\n\n### `dag.get(index, callback)`\n\n### `dag.createReadStream([opts])`\n\n## Extras\n\n### `require('hypercore-dag/bfs-stream')(startIndex, [opts])`\n\nPreform a [Breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search)\nfrom `startIndex`\n\n### `require('hypercore-dag/dfs-stream')(startIndex, [opts])`\n\nPreform a [Depth-first search](https://en.wikipedia.org/wiki/Depth-first_search)\nfrom `startIndex`\n\n## Install\n\n```sh\nnpm install hypercore-dag\n```\n\n## License\n\n[ISC](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilbayes%2Fhypercore-dag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femilbayes%2Fhypercore-dag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilbayes%2Fhypercore-dag/lists"}