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

any-signal

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-signal - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

8

index.d.ts

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

declare function anySignal(signals: AbortSignal[]): AbortSignal;
interface ClearableSignal extends AbortSignal {
clear(): void
}
export {anySignal};
declare function anySignal(signals: Array<AbortSignal | undefined | null>): ClearableSignal;
export {anySignal, type ClearableSignal};
export default anySignal;

@@ -5,3 +5,3 @@ /**

* @param {Array<AbortSignal>} signals
* @returns {AbortSignal}
* @returns {ClearableSignal}
*/

@@ -29,3 +29,17 @@ function anySignal (signals) {

return controller.signal
function clear () {
for (const signal of signals) {
if (!signal || !signal.removeEventListener) continue
signal.removeEventListener('abort', onAbort)
}
}
return new Proxy(controller.signal, {
get (target, p) {
if (p === 'clear') {
return clear
}
return target[p]
}
})
}

@@ -32,0 +46,0 @@

{
"name": "any-signal",
"version": "3.0.1",
"version": "4.0.0",
"description": "Combines an array of AbortSignals into a single signal that is aborted when any signal is",

@@ -5,0 +5,0 @@ "main": "index.js",

# any-signal
[![Build Status](https://travis-ci.org/jacobheun/any-signal.svg?branch=master)](https://travis-ci.org/jacobheun/any-signal) [![dependencies Status](https://david-dm.org/jacobheun/any-signal/status.svg)](https://david-dm.org/jacobheun/any-signal) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Build Status](https://github.com/jacobheun/any-signal/actions/workflows/node.js.yml/badge.svg?branch=master)](https://travis-ci.org/jacobheun/any-signal) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

@@ -30,2 +30,5 @@ > Combines an array of AbortSignals into a single signal that is aborted when any signal is.

clearTimeout(timeoutId)
// Clear will clean up internal event handlers
combinedSignal.clear()
```

@@ -47,6 +50,9 @@

|------|-------------|
| [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) | A Signal that will be aborted as soon as any one of its parent signals are aborted. |
| `ClearableSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) | A Signal that will be aborted as soon as any one of its parent signals are aborted. Extends AbortSignal with the `clear` function for cleanup |
The returned [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) will only be aborted once, and as soon as one of its parent signals is aborted.
The returned [`ClearableSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) will only be aborted once, and as soon as one of its parent signals is aborted.
### `ClearableSignal.clear()`
Removes all internal event handlers. This **must** be called after abort has been called, or the signals have successfully executed, otherwise there is a risk of leaking event handlers.
## Acknowledgements

@@ -53,0 +59,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