hyperdrive-named-archives
create hyperdrive archives that store and load link keys from names
Last updated 3 years ago by substack .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hyperdrive-named-archives 
SYNC missed versions from official npm registry.

hyperdrive-named-archives

create hyperdrive archives that store and load link keys from names

example

var namedArchives = requre('hyperdrive-named-archives')
var hyperdrive = require('hyperdrive')
var level = require('level')
var sub = require('subleveldown')

var db = level('/tmp/drive.db')

var named = namedArchives({
  drive: hyperdrive(sub(db, 'drive')),
  db: sub(db, 'archives')
})

var archive = named.createArchive('default')
if (process.argv[2] === 'write') {
  var file = process.argv[3]
  var stream = archive.createFileWriteStream(file)
  process.stdin.pipe(stream)
} else if (process.argv[2] === 'read') {
  var file = process.argv[3]
  var stream = archive.createFileReadStream(file)
  stream.pipe(process.stdout)
}

api

var namedArchives = require('hyperdrive-named-archives')

var named = namedArchives(opts)

Create a new named archive instance named from:

  • opts.drive - a hyperdrive instance
  • opts.db - a leveldb instance to store archive links

var archive = named.createArchive(name, opts)

Create an archive from a string name. The first time name is used, the archive link will be saved so that subsequent calls to createArchive() under the same name will use the same stored archive link.

opts are passed to the underlying drive.createArchive(opts) method.

named.getLink(name, cb)

Get the archive link for name as cb(err, link). name is a string and link is a buffer from the underlying archive.key.

var stream = named.list(opts, cb)

Return a readable object stream with stored name and link properties for each stored link.

install

npm install hyperdrive-named-archives

license

BSD

Current Tags

  • 1.2.0                                ...           latest (3 years ago)

4 Versions

  • 1.2.0                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |