fs-chunk-store
Filesystem (fs) chunk store that is abstract-chunk-store compliant
Last updated 3 months ago by feross .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fs-chunk-store 
SYNC missed versions from official npm registry.

fs-chunk-store travis npm downloads javascript style guide

Filesystem (fs) chunk store that is abstract-chunk-store compliant

abstract chunk store

Install

npm install fs-chunk-store

Usage

Back the store with a single file

var FSChunkStore = require('fs-chunk-store')

var chunks = new FSChunkStore(10, {
  path: '/tmp/my_file', // optional: path to file (default: temp file will be used)
  length: 100 // optional: file length in bytes (default: file expands based on `put`s)
})

Back the store with multiple files

var FSChunkStore = require('fs-chunk-store')

var chunks = new FSChunkStore(10, {
  files: [
    { path: 'folder/file1.txt', length: 12 },
    { path: 'folder/file2.txt', length: 8 },
    { path: 'folder/file3.txt', length: 30 }
  ]
})

put, get, close, destroy

chunks.put(0, Buffer.from('0123456789'), function (err) {
  if (err) throw err

  chunks.get(0, function (err, chunk) {
    if (err) throw err
    console.log(chunk) // '0123456789' as a buffer

    chunks.close(function (err) {
      if (err) throw err
      console.log('/tmp/my_file file descriptor is closed')

      chunks.destroy(function (err) {
        if (err) throw err
        console.log('/tmp/my_file fileĀ is deleted')
      })
    })
  })
})

License

MIT. Copyright (c) Feross Aboukhadijeh.

Current Tags

  • 2.0.1                                ...           latest (3 months ago)

20 Versions

  • 2.0.1                                ...           3 months ago
  • 2.0.0                                ...           3 months ago
  • 1.7.0                                ...           2 years ago
  • 1.6.5                                ...           3 years ago
  • 1.6.4                                ...           3 years ago
  • 1.6.3                                ...           3 years ago
  • 1.6.2                                ...           4 years ago
  • 1.6.1                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.5                                ...           4 years ago
  • 1.3.4                                ...           4 years ago
  • 1.3.3                                ...           4 years ago
  • 1.3.2                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 5
This Week 24
This Month 80
Last Day 12
Last Week 41
Last Month 191
Dependencies (5)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |