Created
March 18, 2017 15:51
-
-
Save mafintosh/f29ce167045a297e2d57045d3067fd65 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 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