Last active
October 26, 2024 17:42
-
-
Save mafintosh/80f28829b629befc051b2a6af307c903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hypercore = require('hypercore') | |
var ram = require('random-access-memory') | |
var feed = hypercore(ram) | |
feed.append('hello world') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swarm = require('webrtc-swarm') | |
var signalhub = require('signalhub') | |
feed.on('ready', function () { | |
var hub = signalhub(feed.discoveryKey.toString('hex'), ['https://signalhub.mafintosh.com']) | |
var sw = swarm(hub) | |
sw.on('peer', function (peer, id) { | |
console.log('connected to a new peer:', id) | |
peer.pipe(feed.replicate({encrypt: false})).pipe(peer) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have an example on how to use hypercore in the browser with persistent storage? I tried to load my data into the hyperbee with random-access-web and it got too big and crashed in firefox. The same data is already persistent in the webstorage idb and works without a problem.
I don't want to load all my data into the RAM every time I run the application and then replicate all changes back to the idb.