Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created March 18, 2017 15:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mafintosh/f29ce167045a297e2d57045d3067fd65 to your computer and use it in GitHub Desktop.
Save mafintosh/f29ce167045a297e2d57045d3067fd65 to your computer and use it in GitHub Desktop.
var hyperdrive = require('./')
var ram = require('random-access-memory')
var drive = hyperdrive(ram)
drive.history({live: true}).on('data', console.log)
drive.writeFile('/hello', 'world', function () {
drive.writeFile('/hello', 'verden', function () {
replicate()
})
})
function replicate () {
var clone = hyperdrive(ram, drive.key)
var stream = clone.replicate()
stream.pipe(drive.replicate()).pipe(stream).on('end', function () {
clone.createReadStream('/hello').on('data', console.log)
clone.readFile('/hello', 'utf-8', console.log)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment