2.0.0 • Published 7 years ago

ls-chunk-store v2.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

ls-chunk-store travis npm downloads

Greenkeeper badge

Browser localStorage chunk store that is abstract-chunk-store compliant

abstract chunk store

Features

  • Chunks that don't fit in localStorage remain in memory
  • Works as a persistent cache of chunks
  • Oldest ls-chunk-store chunks are removed when store is full

Install

npm install ls-chunk-store

####You can also use the browserified version from jsDelivr:

<script src="https://cdn.jsdelivr.net/ls-chunk-store/latest/ls-chunk-store.min.js"></script>

Build

The following command will build ls-chunk-store.min.js in the dist folder

npm run-script build

The following command will build ls-chunk-store.js in the root folder

npm run-script build-dev

Usage

Generate random prefix

var LSChunkStore = require('ls-chunk-store')

var chunks = new LSChunkStore(10)

Use specified prefix

var LSChunkStore = require('ls-chunk-store')

var chunks = new LSChunkStore(10, {
  prefix: 'myFile.txt'
})

put, get, close, destroy

chunks.put(0, new Buffer('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('storage is closed')

      chunks.destroy(function (err) {
        if (err) throw err
        console.log('files is deleted')
      })
    })
  })
})

License

MIT. Copyright (c) Diego Rodríguez Baquero.

2.0.0

7 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago