{"id":15483492,"url":"https://github.com/hackergrrl/hyperswarm","last_synced_at":"2025-06-22T00:40:15.524Z","repository":{"id":147533704,"uuid":"53162957","full_name":"hackergrrl/hyperswarm","owner":"hackergrrl","description":":ant: Create a p2p webrtc swarm around a hyperlog.","archived":false,"fork":false,"pushed_at":"2016-03-04T20:18:43.000Z","size":2,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-28T21:43:54.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackergrrl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-04T20:18:37.000Z","updated_at":"2023-01-31T16:42:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"662e5fa4-4fef-486c-9aa8-e0a307b0dbef","html_url":"https://github.com/hackergrrl/hyperswarm","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/hackergrrl%2Fhyperswarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fhyperswarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fhyperswarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fhyperswarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackergrrl","download_url":"https://codeload.github.com/hackergrrl/hyperswarm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232891057,"owners_count":18592587,"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-10-02T05:17:03.815Z","updated_at":"2025-01-07T14:26:31.701Z","avatar_url":"https://github.com/hackergrrl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hyperswarm\n\nCreate a p2p webrtc swarm around a [hyperlog][4].\n\n## background\n\nThis is a fork of [substack/swarmlog](https://github.com/substack/swarmlog) that\nchanges the API a bit. The key difference is that `hyperswarm` consumes a\nhyperlog rather than producing it. This makes it easy to supply your own\nnon-standard hyperlog implementation conforming to its API, like\n[noffle/ipfs-hyperlog](https://github.com/noffle/ipfs-hyperlog).\n\n## example\n\nCreate a hyperlog publisher that will write a new message every second:\n\n`publish.js`:\n\n``` js\nvar hyperlog = require('hyperlog')\nvar hyperswarm = require('hyperswarm')\nvar memdb = require('memdb')\n\nvar log = hyperlog(memdb(), {\n  valueEncoding: 'json'\n})\n\nvar swarm = hyperswarm(log, {\n  topic: 'example',\n  hubs: [ 'https://signalhub.mafintosh.com' ]\n})\n\nvar times = 0\nsetInterval(function () {\n  log.append({ time: Date.now(), msg: 'HELLO!x' + times })\n  times++\n}, 1000)\n```\n\nand a follower that will consume the log:\n\n```js\nvar hyperlog = require('hyperlog')\nvar hyperswarm = require('hyperswarm')\nvar memdb = require('memdb')\n\nvar log = hyperlog(memdb(), {\n  valueEncoding: 'json'\n})\n\nvar swarm = hyperswarm(log, {\n  topic: 'example',\n  hubs: [ 'https://signalhub.mafintosh.com' ]\n})\n\nlog.createReadStream({ live: true })\n  .on('data', function (data) {\n    console.log('RECEIVED', data)\n  })\n```\n\n## api\n\n```\nvar hyperswarm = require('hyperswarm')\n```\n\n### var swarm = hyperswarm(log, opts)\n\nCreate a [hyperswarm][4] instance `swarm` from a hyperlog `log` and options:\n\n* `opts.topic` - a string indicating some topic to use to look for common peers\n* `opts.hubs` - array of [signalhub][1] hubs to use\n* `opts.peerStream(peer)` - optional function that should return the stream to\nuse for a peer swarm connection. Use this if you want to multiplex some other\nprotocols on the same swarm alongside the hyperlog replication.\n\nOptionally provide a [wrtc][3] instance as `opts.wrtc` to create a hyperswarm in\nNode.\n\n### swarm.hub\n\nThe underlying [signalhub][1] instance.\n\n## p2p\n\nCurrently the swarm relies on [signalhub][1] to assist in the webrtc swarm\nsetup, but ideally in the future this could be replaced or augmented with a\n[webrtc DHT][2].\n\n## install\n\n```\nnpm install hyperswarm\n```\n\n## license\n\nBSD\n\nForked from [substack/swarmlog](https://github.com/substack/swarmlog), which is\nalso BSD licensed.\n\n[1]: https://npmjs.com/package/signalhub\n[2]: https://github.com/feross/webtorrent/issues/288\n[3]: https://npmjs.com/package/wrtc\n[4]: https://npmjs.com/package/hyperlog\n[5]: https://npmjs.com/package/levelup\n[6]: https://npmjs.com/package/level-browserify\n[7]: https://npmjs.com/package/webrtc-swarm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackergrrl%2Fhyperswarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackergrrl%2Fhyperswarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackergrrl%2Fhyperswarm/lists"}