Skip to content

Instantly share code, notes, and snippets.

@okdistribute
Last active July 19, 2016 19:42
Show Gist options
  • Save okdistribute/a904dccd4ffa8bbe6e8607b81f98222c to your computer and use it in GitHub Desktop.
Save okdistribute/a904dccd4ffa8bbe6e8607b81f98222c to your computer and use it in GitHub Desktop.
var hyperdrive = require('hyperdrive')
var swarm = require('hyperdrive-archive-swarm')
var memdb = require('memdb')
var level = require('level')
var archive = drive.createArchive({live: true})
archive.open(function () {
var ws = archive.createFileWriteStream('hello.txt')
ws.write('we say hello to the following:\n')
ws.write('world\n')
ws.end()
ws = archive.createFileWriteStream('hello.txt')
ws.write('verden\n')
ws.end()
ws = archive.createFileWriteStream('hello.txt')
ws.write('mundo')
ws.end()
archive.list({live: false}, function (err, entries) {
console.log(entries)
})
{ name: 'hello.txt',
linkname: '',
length: 37,
blocks: 1,
mode: 0,
uid: 0,
gid: 0,
mtime: 0,
ctime: 0,
content: { blockOffset: 0, bytesOffset: 0 },
type: 'file' }
{ name: 'hello.txt',
linkname: '',
length: 6,
blocks: 1,
mode: 0,
uid: 0,
gid: 0,
mtime: 0,
ctime: 0,
content: { blockOffset: 1, bytesOffset: 37 },
type: 'file' }
{ name: 'hello.txt',
linkname: '',
length: 5,
blocks: 1,
mode: 0,
uid: 0,
gid: 0,
mtime: 0,
ctime: 0,
content: { blockOffset: 2, bytesOffset: 43 },
type: 'file' }
var hyperdrive = require('hyperdrive')
var swarm = require('hyperdrive-archive-swarm')
var level = require('level')
var hyperclone = require('./')
var db = level('./hyperclone')
var drive = hyperdrive(db)
var archive = drive.createArchive({live: true})
archive.open(function () {
var stream = archive.list({live: true})
stream.on('data', function (data) {
console.log(data)
})
var ws = archive.createFileWriteStream('hello.txt')
ws.write('we say hello to the following:\n')
ws.write('world\n')
ws.end()
ws = archive.createFileWriteStream('hello.txt')
ws.write('verden')
ws.end()
ws = archive.createFileWriteStream('hello.txt')
ws.write('mundo')
ws.end()
//var clone = hyperclone(archive)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment