Giter VIP home page Giter VIP logo

abstract-chunk-store's Introduction

abstract-chunk-store npm downloads

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

Install

npm install abstract-chunk-store

Some modules that use this

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.

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'))

License

MIT

abstract-chunk-store's People

Contributors

feross avatar mafintosh avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.