🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

signal-controller

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signal-controller - npm Package Compare versions

Comparing version
0.5.0
to
0.6.0
+4
-0
dist/index.d.ts

@@ -5,2 +5,3 @@ declare const ONCE_SYMBOL: unique symbol;

declare const CLEAR_ALL_SIGNALS: unique symbol;
declare const COUNT_LISTENERS: unique symbol;
interface ListenerFunction {

@@ -41,2 +42,3 @@ (...args: any[]): unknown;

[CLEAR_ALL_SIGNALS](): void;
[COUNT_LISTENERS](signalName: keyof T): number;
}

@@ -65,4 +67,6 @@ interface SignalControllerOptions {

destroy(): void;
/** Checks whether there are listeners attached for the specified signal. */
testSignal(signalName: keyof T): boolean;
/** Creates a writable stream that produces signals of the specified type for each chunk of data it receives. */
createWritableStream<K extends keyof T>(signalName: K): WritableStream<Parameters<T[K]>>;
}

@@ -5,2 +5,3 @@ const ONCE_SYMBOL = Symbol('once');

const CLEAR_ALL_SIGNALS = Symbol('clear');
const COUNT_LISTENERS = Symbol('countListeners');
/** This class is used to listen to signals. */

@@ -118,2 +119,5 @@ class SignalEmitter {

}
[COUNT_LISTENERS](signalName) {
return this.#listeners.get(signalName)?.size ?? 0;
}
}

@@ -178,2 +182,6 @@ /** This class is used to emit signals. */

}
/** Checks whether there are listeners attached for the specified signal. */
testSignal(signalName) {
return this.emitter[COUNT_LISTENERS](signalName) > 0;
}
/** Creates a writable stream that produces signals of the specified type for each chunk of data it receives. */

@@ -180,0 +188,0 @@ createWritableStream(signalName) {

+1
-1
{
"name": "signal-controller",
"version": "0.5.0",
"version": "0.6.0",
"description": "A lightweight event emitter with separation of concerns between emitter and listener inspired by the AbortController interface.",

@@ -5,0 +5,0 @@ "author": "Leonardo Raele <leonardoraele@gmail.com>",