@asaidimu/utils-database 3.1.3 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +12 -2
- package/index.d.ts +12 -2
- package/package.json +2 -2
package/index.d.mts
CHANGED
|
@@ -816,16 +816,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
|
|
|
816
816
|
* Subscribes to a specific event by name.
|
|
817
817
|
* @param eventName - The name of the event to subscribe to.
|
|
818
818
|
* @param callback - The function to call when the event is emitted.
|
|
819
|
+
* @param options - Extra options to determine the behaviour of the
|
|
820
|
+
* subscription
|
|
819
821
|
* @returns A function to unsubscribe from the event.
|
|
820
822
|
*/
|
|
821
|
-
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
823
|
+
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
822
824
|
/**
|
|
823
825
|
* Subscribes to an event and automatically unsubscribes after it fires once.
|
|
824
826
|
* @param eventName - The name of the event to subscribe to.
|
|
825
827
|
* @param callback - The function to call when the event is emitted.
|
|
826
828
|
* @returns A function to cancel the one-shot subscription before it fires.
|
|
827
829
|
*/
|
|
828
|
-
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
830
|
+
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
829
831
|
/**
|
|
830
832
|
* Emits an event with a payload to all subscribed listeners.
|
|
831
833
|
* @param event - An object containing the event name and payload.
|
|
@@ -859,6 +861,14 @@ interface EventMetrics {
|
|
|
859
861
|
/** Average duration of event dispatch in milliseconds. */
|
|
860
862
|
averageEmitDuration: number;
|
|
861
863
|
}
|
|
864
|
+
interface SubscribeOptions {
|
|
865
|
+
/**
|
|
866
|
+
* Debounce delay in milliseconds. When multiple events arrive in quick
|
|
867
|
+
* succession, the callback runs only after the quiet period ends, using the
|
|
868
|
+
* latest payload. Default = no debouncing.
|
|
869
|
+
*/
|
|
870
|
+
debounce?: number;
|
|
871
|
+
}
|
|
862
872
|
|
|
863
873
|
interface MiddlewareContext {
|
|
864
874
|
collection?: string;
|
package/index.d.ts
CHANGED
|
@@ -816,16 +816,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
|
|
|
816
816
|
* Subscribes to a specific event by name.
|
|
817
817
|
* @param eventName - The name of the event to subscribe to.
|
|
818
818
|
* @param callback - The function to call when the event is emitted.
|
|
819
|
+
* @param options - Extra options to determine the behaviour of the
|
|
820
|
+
* subscription
|
|
819
821
|
* @returns A function to unsubscribe from the event.
|
|
820
822
|
*/
|
|
821
|
-
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
823
|
+
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
822
824
|
/**
|
|
823
825
|
* Subscribes to an event and automatically unsubscribes after it fires once.
|
|
824
826
|
* @param eventName - The name of the event to subscribe to.
|
|
825
827
|
* @param callback - The function to call when the event is emitted.
|
|
826
828
|
* @returns A function to cancel the one-shot subscription before it fires.
|
|
827
829
|
*/
|
|
828
|
-
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
830
|
+
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
829
831
|
/**
|
|
830
832
|
* Emits an event with a payload to all subscribed listeners.
|
|
831
833
|
* @param event - An object containing the event name and payload.
|
|
@@ -859,6 +861,14 @@ interface EventMetrics {
|
|
|
859
861
|
/** Average duration of event dispatch in milliseconds. */
|
|
860
862
|
averageEmitDuration: number;
|
|
861
863
|
}
|
|
864
|
+
interface SubscribeOptions {
|
|
865
|
+
/**
|
|
866
|
+
* Debounce delay in milliseconds. When multiple events arrive in quick
|
|
867
|
+
* succession, the callback runs only after the quiet period ends, using the
|
|
868
|
+
* latest payload. Default = no debouncing.
|
|
869
|
+
*/
|
|
870
|
+
debounce?: number;
|
|
871
|
+
}
|
|
862
872
|
|
|
863
873
|
interface MiddlewareContext {
|
|
864
874
|
collection?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asaidimu/utils-database",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "A collection of database utilities.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@asaidimu/anansi": "4.0.2",
|
|
39
|
-
"@asaidimu/utils-events": "1.
|
|
39
|
+
"@asaidimu/utils-events": "^1.0.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"registry": "https://registry.npmjs.org/",
|