@adonisjs/events 10.1.0 → 10.2.0

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.
@@ -19,6 +19,10 @@ var __exportAll = (all, no_symbols) => {
19
19
  var debug_default = debuglog("adonisjs:events");
20
20
  var EventsBuffer = class {
21
21
  #events = [];
22
+ #restoreFn;
23
+ constructor(restoreFn) {
24
+ this.#restoreFn = restoreFn;
25
+ }
22
26
  add(event, data) {
23
27
  this.#events.push({
24
28
  event,
@@ -79,6 +83,9 @@ var EventsBuffer = class {
79
83
  flush() {
80
84
  this.#events = [];
81
85
  }
86
+ [Symbol.dispose]() {
87
+ this.#restoreFn();
88
+ }
82
89
  };
83
90
  var tracing_channels_exports = /* @__PURE__ */ __exportAll({ eventDispatch: () => eventDispatch });
84
91
  const eventDispatch = diagnostics_channel.tracingChannel("adonisjs.event.dispatch");
@@ -243,7 +250,7 @@ var Emitter = class {
243
250
  }
244
251
  fake(events) {
245
252
  this.restore();
246
- this.#eventsBuffer = new EventsBuffer();
253
+ this.#eventsBuffer = new EventsBuffer(() => this.restore());
247
254
  if (!events) {
248
255
  debug_default("faking all events");
249
256
  this.#eventsToFake.add("*");
@@ -1,4 +1,4 @@
1
- import { t as Emitter } from "../emitter-4sSh--Yh.js";
1
+ import { t as Emitter } from "../emitter-BaiN6nb0.js";
2
2
  var EmitterFactory = class {
3
3
  create(app) {
4
4
  return new Emitter(app);
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as tracing_channels_exports, t as Emitter } from "./emitter-4sSh--Yh.js";
1
+ import { n as tracing_channels_exports, t as Emitter } from "./emitter-BaiN6nb0.js";
2
2
  import { RuntimeException } from "@poppinss/utils/exception";
3
3
  var BaseEvent = class {
4
4
  constructor(..._) {}
@@ -10,6 +10,7 @@ type EventFinderCallback<EventsList extends Record<string | symbol | number, any
10
10
  */
11
11
  export declare class EventsBuffer<EventsList extends Record<string | symbol | number, any>> {
12
12
  #private;
13
+ constructor(restoreFn: () => void);
13
14
  /**
14
15
  * Track emitted event
15
16
  *
@@ -79,5 +80,6 @@ export declare class EventsBuffer<EventsList extends Record<string | symbol | nu
79
80
  * Flush events collected within memory
80
81
  */
81
82
  flush(): void;
83
+ [Symbol.dispose](): void;
82
84
  }
83
85
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/events",
3
3
  "description": "An implementation of the event emitter built on top of emittery",
4
- "version": "10.1.0",
4
+ "version": "10.2.0",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },