sparse-chunk-store

1.2.0 • Public • Published

sparse-chunk-store

populate and query a chunk store with sparse blocks

example

put

var sparse = require('sparse-chunk-store')
var fdstore = require('fd-chunk-store')
var sp = sparse(32, fdstore(32, '/tmp/chunks'))
 
var n = Number(process.argv[2])
var buf = Buffer(process.argv[3])
sp.put(n, buf, function (err) {
  if (err) console.error(err)
})

get

var sparse = require('sparse-chunk-store')
var fdstore = require('fd-chunk-store')
var sp = sparse(32, fdstore(32, '/tmp/chunks'))
 
var n = Number(process.argv[2])
sp.get(n, function (err, buf) {
  if (err) console.error(err)
  else console.log(buf.toString())
})

api

var sparse = require('sparse-chunk-store')

var sp = sparse(size, store, opts)

var sp = sparse(store, opts)

Return a sparse chunk store sp from a non-sparse chunk store store.

If store.size is defined, size can be omitted as an explicit parameter.

Set opts.cache to true to buffer index tables in memory for a speed boost.

sp.get(index, opts={}, cb)

Read the block data at index as cb(err, buf).

sp.put(index, opts={}, cb)

Write block data at index.

install

npm install sparse-chunk-store

license

MIT

Package Sidebar

Install

npm i sparse-chunk-store

Weekly Downloads

0

Version

1.2.0

License

MIT

Last publish

Collaborators

  • nopersonsmodules