Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chunk-store-tool

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chunk-store-tool

A test suite and interface you can use to implement a chunk based storage backend

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

chunk-store-tool

A test suite and interface you can use to implement a chunk based storage backend

Install

npm install chunk-store-tool

Some modules that use this

Recommended chunk stores:

  • memory-chunk-store
  • fs-chunk-store
  • idb-chunk-store
  • fs-access-chunk-store

Recommended chunk store utilities:

Other modules that follow the chunk store spec:

Send a PR adding yours if you write a new one.

API

chunkStore = new ChunkStore(chunkLength)

Create a new chunk store. Chunks must have a length of chunkLength.

chunkStore.put(index, chunkBuffer, [cb])

Add a new chunk to the storage. Index should be an integer.

chunkStore.get(index, [options], cb)

Retrieve a chunk stored. Index should be an integer. Options include:

{
  offset: chunkByteOffset,
  length: byteLength
}

If the index doesn't exist in the storage an error should be returned.

chunkStore.close([cb])

Close the underlying resource, e.g. if the store is backed by a file, this would close the file descriptor.

chunkStore.destroy([cb])

Destroy the file data, e.g. if the store is backed by a file, this would delete the file from the filesystem.

chunkStore.chunkLength

Expose the chunk length from the constructor so that code that receives a chunk store can know what size of chunks to write.

Test Suite

Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.

To use the test suite from this module you can require('abstract-chunk-store/tests').

An example of this can be found in the memory-chunk-store test suite.

To run the tests simply pass your test module (tap or tape or any other compatible modules are supported) and your store's constructor (or a setup function) in:

var tests = require('abstract-chunk-store/tests')
tests(require('tape'), require('your-custom-chunk-store'))

Background

An abstract chunk store is a binary data store that allows you to interact with individual chunks of a larger blob (a.k.a. binary file). A chunk can be thought of as a small partial blob that fits in memory.

Related:

License

MIT

FAQs

Package last updated on 02 Mar 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc