Socket
Socket
Sign inDemoInstall

@jsenv/abort

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/abort - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

2

package.json
{
"name": "@jsenv/abort",
"version": "3.1.0",
"version": "3.1.1",
"description": "Help to write code compatible with abort signals",

@@ -5,0 +5,0 @@ "license": "MIT",

export const createCallbackListCalledOnce = () => {
let callbacks = []
let status = "pending"
let currentCallbackIndex = -1

@@ -31,6 +32,22 @@ const add = (callback) => {

}
const index = callbacks.indexOf(callback)
if (index > -1) {
callbacks.splice(index, 1)
if (index === -1) {
return
}
if (status === "calling") {
if (index <= currentCallbackIndex) {
// The callback was already called (or is the current callback)
// We don't want to mutate the callbacks array
// or it would alter the looping done in "call" and the next callback
// would be skipped
return
}
// Callback is part of the next callback to call,
// we mutate the callbacks array to prevent this callback to be called
}
callbacks.splice(index, 1)
}

@@ -45,3 +62,4 @@ }

status = "calling"
const values = callbacks.map((callback) => {
const values = callbacks.map((callback, index) => {
currentCallbackIndex = index
return callback(param)

@@ -53,2 +71,3 @@ })

callbacks = null
currentCallbackIndex = -1

@@ -55,0 +74,0 @@ return values

@@ -6,3 +6,3 @@ /*

export const raceCallbacks = (raceDescription, winnerCallback) => {
const cleanCallbacks = []
let cleanCallbacks = []
let done = false

@@ -12,7 +12,6 @@

done = true
const cleanCallbacksCopy = cleanCallbacks.slice()
cleanCallbacks.length = 0
cleanCallbacksCopy.forEach((clean) => {
cleanCallbacks.forEach((clean) => {
clean()
})
cleanCallbacks = null
}

@@ -19,0 +18,0 @@

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