deferred-chunk-store

1.0.1 • Public • Published

deferred-chunk-store

expose a child store interface to delay providing an implementation

This module is similar in spirit to deferred-leveldown

example

var defstore = require('deferred-chunk-store')
var fdstore = require('fd-chunk-store')
var mkdirp = require('mkdirp')
 
var store = defstore(9)
store.put(0, Buffer('whatever\n'), function (err) {
  if (err) console.error(err)
  else console.log('wrote bytes')
})
 
mkdirp('/tmp/defstore', function (err) {
  if (err) return console.error(err)
  console.log('made directory')
  store.setStore(fdstore(9, '/tmp/defstore/store'))
})

api

var deferredStore = require('deferred-chunk-store')

var store = deferredStore(chunkSize)

Present a chunk store interface store with chunkSize.

store.setStore(otherStore)

Set the underlying implementation to otherStore, sending buffered and future operations in order.

store.put(n, buf, opts={}, cb)

Write a buffer buf at chunk index n.

store.get(n, opts={}, cb)

Read a buffer at chunk index n as cb(err, buf).

store.destroy()

Destroy the underlying resource.

store.close()

Close the underlying resource.

license

BSD

Package Sidebar

Install

npm i deferred-chunk-store

Weekly Downloads

3

Version

1.0.1

License

BSD

Last publish

Collaborators

  • nopersonsmodules