Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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 4.1.0 to 4.1.1

2

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

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

@@ -99,6 +99,14 @@ /*

const addAbortSignal = (signal, cancel = cancelNoop) => {
const addAbortSignal = (
signal,
{ onAbort = callbackNoop, onRemove = callbackNoop } = {},
) => {
const callback = (fn) => {
onAbort = onRemove = callbackNoop
fn()
}
if (operationSignal.aborted) {
cancel()
return cancel
callback(onAbort)
return callbackNoop
}

@@ -108,3 +116,4 @@

operationAbortController.abort()
return cancel
callback(onAbort)
return callbackNoop
}

@@ -134,3 +143,3 @@

operation_abort: () => {
cancel()
callback(onAbort)
},

@@ -142,5 +151,6 @@ operation_end: () => {

// - call any custom cancel function
cancel()
callback(onRemove)
},
child_abort: () => {
callback(onAbort)
operationAbortController.abort()

@@ -155,3 +165,3 @@ },

cancelRace()
cancel()
callback(onRemove)
}

@@ -167,3 +177,3 @@ }

signal: abortSourceSignal,
remove: cancelNoop,
remove: callbackNoop,
}

@@ -175,6 +185,10 @@ }

})
const cancelEffect =
typeof returnValue === "function" ? returnValue : cancelNoop
const removeAbortSource =
typeof returnValue === "function" ? returnValue : callbackNoop
const removeAbortSignal = addAbortSignal(abortSourceSignal, cancelEffect)
const removeAbortSignal = addAbortSignal(abortSourceSignal, {
onRemove: () => {
removeAbortSource()
},
})
return {

@@ -201,3 +215,7 @@ signal: abortSourceSignal,

const signal = abortController.signal
const removeAbortSignal = addAbortSignal(signal)
const removeAbortSignal = addAbortSignal(signal, {
onAbort: () => {
abortController.abort()
},
})
try {

@@ -216,3 +234,7 @@ const value = await asyncCallback(signal)

const signal = abortController.signal
const removeAbortSignal = addAbortSignal(signal)
const removeAbortSignal = addAbortSignal(signal, {
onAbort: () => {
abortController.abort()
},
})
try {

@@ -247,3 +269,3 @@ const value = callback(signal)

const cancelNoop = () => {}
const callbackNoop = () => {}

@@ -250,0 +272,0 @@ const addEventListener = (target, eventName, cb) => {

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