@wooksjs/event-core 0.5.4 → 0.5.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/dist/index.cjs CHANGED
@@ -4,9 +4,8 @@ var crypto = require('crypto');
4
4
  var node_async_hooks = require('node:async_hooks');
5
5
  var logger = require('@prostojs/logger');
6
6
 
7
- class Hookable extends node_async_hooks.AsyncResource {
7
+ class Hookable {
8
8
  constructor() {
9
- super('hookable');
10
9
  this.hooks = {};
11
10
  }
12
11
  hook(name, cb) {
@@ -22,7 +21,7 @@ class Hookable extends node_async_hooks.AsyncResource {
22
21
  if (this.hooks[name]) {
23
22
  for (const cb of this.hooks[name]) {
24
23
  try {
25
- this.runInAsyncScope(cb, null, ...args);
24
+ cb(...args);
26
25
  }
27
26
  catch (error) {
28
27
  console.error(`Error in hook ${name}:`, error);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _prostojs_logger from '@prostojs/logger';
2
2
  import { TProstoLoggerOptions, ProstoLogger } from '@prostojs/logger';
3
- import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
3
+ import { AsyncLocalStorage } from 'node:async_hooks';
4
4
 
5
5
  declare function useEventId(): {
6
6
  getId: () => string;
@@ -292,8 +292,7 @@ declare function useRouteParams<T extends object = Record<string, string | strin
292
292
  };
293
293
 
294
294
  type HookCallback = (...args: any[]) => any;
295
- declare class Hookable extends AsyncResource {
296
- constructor();
295
+ declare class Hookable {
297
296
  private hooks;
298
297
  /**
299
298
  * Registers a callback to a specific hook name.
package/dist/index.mjs CHANGED
@@ -1,10 +1,9 @@
1
1
  import { randomUUID } from 'crypto';
2
- import { AsyncResource, AsyncLocalStorage } from 'node:async_hooks';
2
+ import { AsyncLocalStorage } from 'node:async_hooks';
3
3
  import { ProstoLogger, createConsoleTransort, coloredConsole } from '@prostojs/logger';
4
4
 
5
- class Hookable extends AsyncResource {
5
+ class Hookable {
6
6
  constructor() {
7
- super('hookable');
8
7
  this.hooks = {};
9
8
  }
10
9
  hook(name, cb) {
@@ -20,7 +19,7 @@ class Hookable extends AsyncResource {
20
19
  if (this.hooks[name]) {
21
20
  for (const cb of this.hooks[name]) {
22
21
  try {
23
- this.runInAsyncScope(cb, null, ...args);
22
+ cb(...args);
24
23
  }
25
24
  catch (error) {
26
25
  console.error(`Error in hook ${name}:`, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-core",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "@wooksjs/event-core",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",