Socket
Socket
Sign inDemoInstall

fs-chunk-store

Package Overview
Dependencies
22
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fs-chunk-store

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


Version published
Maintainers
1
Install size
283 kB
Created

Readme

Source

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.

Keywords

FAQs

Last updated on 14 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc