Skip to content

Instantly share code, notes, and snippets.

@andrewosh
Created June 12, 2016 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewosh/1938bfda88403c336673ddc679fdeb6e to your computer and use it in GitHub Desktop.
Save andrewosh/1938bfda88403c336673ddc679fdeb6e to your computer and use it in GitHub Desktop.
var memdb = require('memdb')
var crypto = require('crypto')
var hyperdrive = require('hyperdrive')
var drive = hyperdrive(memdb())
var archive = drive.createArchive(crypto.randomBytes(32).toString('hex'), { live: true })
archive.list({ live: false }, function (err, entries) {
console.log('err:', err)
console.log('entries:', entries)
})
var stream = archive.list({ live: false })
stream.on('end', function () {
console.log('end')
})
stream.on('data', function (data) {
console.log('data')
})
stream.on('finish', function () {
console.log('finish')
})
stream.on('close', function () {
console.log('close')
})
archive.list({ live: true }, function (err, entries) {
console.log('err:', err)
console.log('entries:', entries)
})
var liveStream = archive.list({ live: true })
liveStream.on('end', function () {
console.log('end')
})
liveStream.on('data', function (data) {
console.log('data')
})
liveStream.on('finish', function () {
console.log('finish')
})
liveStream.on('close', function () {
console.log('close')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment