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.0.0 to 2.1.0

30

index.js

@@ -0,1 +1,4 @@

// TODO: remove when window.queueMicrotask() is well supported
const queueMicrotask = require('queue-microtask')
class ImmediateStore {

@@ -24,9 +27,20 @@ constructor (store) {

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

@@ -43,8 +57,2 @@

function nextTick (cb, err, val) {
process.nextTick(() => {
if (cb) cb(err, val)
})
}
module.exports = ImmediateStore
{
"name": "immediate-chunk-store",
"description": "Immediate put/get for abstract-chunk-store compliant stores",
"version": "2.0.0",
"version": "2.1.0",
"author": {

@@ -13,6 +13,8 @@ "name": "Feross Aboukhadijeh",

},
"dependencies": {},
"dependencies": {
"queue-microtask": "^1.1.2"
},
"devDependencies": {
"abstract-chunk-store": "^1.0.0",
"fs-chunk-store": "^1.3.0",
"fs-chunk-store": "^2.0.0",
"memory-chunk-store": "^1.1.1",

@@ -19,0 +21,0 @@ "standard": "*",

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