Socket
Socket
Sign inDemoInstall

immediate-chunk-store

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immediate-chunk-store - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

30

index.js

@@ -17,38 +17,36 @@ /*! immediate-chunk-store. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

put (index, buf, cb) {
put (index, buf, cb = () => {}) {
this.mem[index] = buf
this.store.put(index, buf, err => {
this.mem[index] = null
if (cb) cb(err)
cb(err)
})
}
get (index, opts, cb) {
get (index, opts, cb = () => {}) {
if (typeof opts === 'function') return this.get(index, null, opts)
let memoryBuffer = this.mem[index]
let buf = this.mem[index]
// if the chunk isn't in the immediate memory cache
if (!memoryBuffer) {
if (!buf) {
return this.store.get(index, opts, cb)
}
if (opts) {
const start = opts.offset || 0
const end = opts.length ? (start + opts.length) : memoryBuffer.length
if (!opts) opts = {}
memoryBuffer = memoryBuffer.slice(start, end)
const offset = opts.offset || 0
const len = opts.length || (buf.length - offset)
if (offset !== 0 || len !== buf.length) {
buf = buf.slice(offset, len + offset)
}
// queueMicrotask to ensure the function is async
queueMicrotask(() => {
if (cb) cb(null, memoryBuffer)
})
queueMicrotask(() => cb(null, buf))
}
close (cb) {
close (cb = () => {}) {
this.store.close(cb)
}
destroy (cb) {
destroy (cb = () => {}) {
this.store.destroy(cb)

@@ -55,0 +53,0 @@ }

{
"name": "immediate-chunk-store",
"description": "Immediate put/get for abstract-chunk-store compliant stores",
"version": "2.1.1",
"version": "2.2.0",
"author": {

@@ -14,10 +14,10 @@ "name": "Feross Aboukhadijeh",

"dependencies": {
"queue-microtask": "^1.2.0"
"queue-microtask": "^1.2.3"
},
"devDependencies": {
"abstract-chunk-store": "^1.4.0",
"fs-chunk-store": "^2.0.2",
"memory-chunk-store": "^1.3.0",
"abstract-chunk-store": "^1.5.0",
"fs-chunk-store": "^2.0.3",
"memory-chunk-store": "^1.3.3",
"standard": "*",
"tape": "^5.0.1"
"tape": "^5.2.2"
},

@@ -24,0 +24,0 @@ "homepage": "https://github.com/feross/immediate-chunk-store",

@@ -1,5 +0,5 @@

# immediate-chunk-store [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
# immediate-chunk-store [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/immediate-chunk-store/master.svg
[travis-url]: https://travis-ci.org/feross/immediate-chunk-store
[ci-image]: https://img.shields.io/github/workflow/status/feross/immediate-chunk-store/ci/master
[ci-url]: https://github.com/feross/immediate-chunk-store/actions
[npm-image]: https://img.shields.io/npm/v/immediate-chunk-store.svg

@@ -6,0 +6,0 @@ [npm-url]: https://npmjs.org/package/immediate-chunk-store

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