tiny-essentials 1.27.1 → 1.28.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.
Files changed (60) hide show
  1. package/README.md +1 -0
  2. package/changelog/1/28/0.md +16 -0
  3. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  4. package/dist/v1/TinyBasicsEs.min.js +1 -2
  5. package/dist/v1/TinyEssentials.min.js +1 -2
  6. package/dist/v1/TinyIframeEvents.min.js +1 -1
  7. package/dist/v1/TinyLocalStorage.min.js +1 -1
  8. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  9. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  10. package/dist/v1/TinyRadioFm.min.js +1 -1
  11. package/dist/v1/TinySmartScroller.min.js +1 -1
  12. package/dist/v1/TinyUploadClicker.min.js +1 -2
  13. package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
  14. package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
  15. package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
  16. package/dist/v1/basics/objFilter.cjs +0 -11
  17. package/dist/v1/basics/objFilter.mjs +0 -10
  18. package/dist/v1/index.cjs +0 -2
  19. package/dist/v1/index.d.mts +1 -2
  20. package/dist/v1/index.mjs +1 -2
  21. package/dist/v1/libs/TinyAdvancedRaffle.cjs +7 -205
  22. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +2 -121
  23. package/dist/v1/libs/TinyAdvancedRaffle.mjs +7 -179
  24. package/dist/v1/libs/TinyIframeEvents.cjs +8 -195
  25. package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
  26. package/dist/v1/libs/TinyIframeEvents.mjs +8 -170
  27. package/dist/v1/libs/TinyLocalStorage.cjs +5 -205
  28. package/dist/v1/libs/TinyLocalStorage.d.mts +3 -130
  29. package/dist/v1/libs/TinyLocalStorage.mjs +5 -178
  30. package/dist/v1/libs/TinyMediaPlayer.cjs +2 -2
  31. package/dist/v1/libs/TinyMediaPlayer.d.mts +2 -2
  32. package/dist/v1/libs/TinyMediaPlayer.mjs +2 -2
  33. package/dist/v1/libs/TinyNewWinEvents.cjs +10 -197
  34. package/dist/v1/libs/TinyNewWinEvents.d.mts +3 -122
  35. package/dist/v1/libs/TinyNewWinEvents.mjs +10 -172
  36. package/dist/v1/libs/TinyRadioFm.cjs +2 -3
  37. package/dist/v1/libs/TinyRadioFm.d.mts +2 -3
  38. package/dist/v1/libs/TinyRadioFm.mjs +2 -3
  39. package/dist/v1/libs/TinySmartScroller.cjs +4 -202
  40. package/dist/v1/libs/TinySmartScroller.d.mts +8 -143
  41. package/dist/v1/libs/TinySmartScroller.mjs +4 -176
  42. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  43. package/docs/v1/Exports.md +0 -1
  44. package/docs/v1/README.md +0 -1
  45. package/docs/v1/basics/objFilter.md +1 -1
  46. package/docs/v1/libs/TinyIframeEvents.md +8 -8
  47. package/docs/v1/libs/TinyLocalStorage.md +3 -3
  48. package/docs/v1/libs/TinyNewWinEvents.md +8 -9
  49. package/package.json +6 -5
  50. package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
  51. package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
  52. package/dist/v1/TinyEvents.min.js +0 -1
  53. package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
  54. package/dist/v1/build/TinyEvents.cjs +0 -7
  55. package/dist/v1/build/TinyEvents.d.mts +0 -3
  56. package/dist/v1/build/TinyEvents.mjs +0 -2
  57. package/dist/v1/libs/TinyEvents.cjs +0 -395
  58. package/dist/v1/libs/TinyEvents.d.mts +0 -164
  59. package/dist/v1/libs/TinyEvents.mjs +0 -360
  60. package/docs/v1/libs/TinyEvents.md +0 -187
@@ -1,5 +1,5 @@
1
+ import { EventEmitter } from 'events';
1
2
  import { isJsonObject } from '../basics/objChecker.mjs';
2
- import TinyEvents from './TinyEvents.mjs';
3
3
  /** @type {WeakMap<Window, TinyIframeEvents>} */
4
4
  const instances = new WeakMap();
5
5
  /**
@@ -39,170 +39,7 @@ const instances = new WeakMap();
39
39
  * - Queue management for messages sent before the connection is established.
40
40
  * - Auto-reconnects and resets ports if the target iframe is reloaded.
41
41
  */
42
- class TinyIframeEvents {
43
- #events = new TinyEvents();
44
- /**
45
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
46
- *
47
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
48
- */
49
- setThrowOnMaxListeners(shouldThrow) {
50
- return this.#events.setThrowOnMaxListeners(shouldThrow);
51
- }
52
- /**
53
- * Checks whether an error will be thrown when the max listener limit is exceeded.
54
- *
55
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
56
- */
57
- getThrowOnMaxListeners() {
58
- return this.#events.getThrowOnMaxListeners();
59
- }
60
- /////////////////////////////////////////////////////////////
61
- /**
62
- * Adds a listener to the beginning of the listeners array for the specified event.
63
- *
64
- * @param {string|string[]} event - Event name.
65
- * @param {handler} handler - The callback function.
66
- */
67
- prependListener(event, handler) {
68
- return this.#events.prependListener(event, handler);
69
- }
70
- /**
71
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
72
- *
73
- * @param {string|string[]} event - Event name.
74
- * @param {handler} handler - The callback function.
75
- * @returns {handler[]} - The wrapped handler used internally.
76
- */
77
- prependListenerOnce(event, handler) {
78
- return this.#events.prependListenerOnce(event, handler);
79
- }
80
- //////////////////////////////////////////////////////////////////////
81
- /**
82
- * Adds a event listener.
83
- *
84
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
85
- * @param {handler} handler - Callback function to be called when event fires.
86
- */
87
- appendListener(event, handler) {
88
- return this.#events.appendListener(event, handler);
89
- }
90
- /**
91
- * Registers an event listener that runs only once, then is removed.
92
- *
93
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
94
- * @param {handler} handler - The callback function to run on event.
95
- * @returns {handler[]} - The wrapped version of the handler.
96
- */
97
- appendListenerOnce(event, handler) {
98
- return this.#events.appendListenerOnce(event, handler);
99
- }
100
- /**
101
- * Adds a event listener.
102
- *
103
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
104
- * @param {handler} handler - Callback function to be called when event fires.
105
- */
106
- on(event, handler) {
107
- return this.#events.on(event, handler);
108
- }
109
- /**
110
- * Registers an event listener that runs only once, then is removed.
111
- *
112
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
113
- * @param {handler} handler - The callback function to run on event.
114
- * @returns {handler[]} - The wrapped version of the handler.
115
- */
116
- once(event, handler) {
117
- return this.#events.once(event, handler);
118
- }
119
- ////////////////////////////////////////////////////////////////////
120
- /**
121
- * Removes a previously registered event listener.
122
- *
123
- * @param {string|string[]} event - The name of the event to remove the handler from.
124
- * @param {handler} handler - The specific callback function to remove.
125
- */
126
- off(event, handler) {
127
- return this.#events.off(event, handler);
128
- }
129
- /**
130
- * Removes all event listeners of a specific type from the element.
131
- *
132
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
133
- */
134
- offAll(event) {
135
- return this.#events.offAll(event);
136
- }
137
- /**
138
- * Removes all event listeners of all types from the element.
139
- */
140
- offAllTypes() {
141
- return this.#events.offAllTypes();
142
- }
143
- ////////////////////////////////////////////////////////////
144
- /**
145
- * Returns the number of listeners for a given event.
146
- *
147
- * @param {string} event - The name of the event.
148
- * @returns {number} Number of listeners for the event.
149
- */
150
- listenerCount(event) {
151
- return this.#events.listenerCount(event);
152
- }
153
- /**
154
- * Returns a copy of the array of listeners for the specified event.
155
- *
156
- * @param {string} event - The name of the event.
157
- * @returns {handler[]} Array of listener functions.
158
- */
159
- listeners(event) {
160
- return this.#events.listeners(event);
161
- }
162
- /**
163
- * Returns a copy of the array of listeners for the specified event.
164
- *
165
- * @param {string} event - The name of the event.
166
- * @returns {handler[]} Array of listener functions.
167
- */
168
- onceListeners(event) {
169
- return this.#events.onceListeners(event);
170
- }
171
- /**
172
- * Returns a copy of the internal listeners array for the specified event,
173
- * including wrapper functions like those used by `.once()`.
174
- * @param {string | symbol} event - The event name.
175
- * @returns {handler[]} An array of raw listener functions.
176
- */
177
- allListeners(event) {
178
- return this.#events.allListeners(event);
179
- }
180
- /**
181
- * Returns an array of event names for which there are registered listeners.
182
- *
183
- * @returns {string[]} Array of registered event names.
184
- */
185
- eventNames() {
186
- return this.#events.eventNames();
187
- }
188
- //////////////////////////////////////////////////////
189
- /**
190
- * Sets the maximum number of listeners per event before a warning is shown.
191
- *
192
- * @param {number} n - The maximum number of listeners.
193
- */
194
- setMaxListeners(n) {
195
- return this.#events.setMaxListeners(n);
196
- }
197
- /**
198
- * Gets the maximum number of listeners allowed per event.
199
- *
200
- * @returns {number} The maximum number of listeners.
201
- */
202
- getMaxListeners() {
203
- return this.#events.getMaxListeners();
204
- }
205
- ///////////////////////////////////////////////////
42
+ class TinyIframeEvents extends EventEmitter {
206
43
  /** @type {Window} */
207
44
  #targetWindow;
208
45
  get targetWindow() {
@@ -241,7 +78,7 @@ class TinyIframeEvents {
241
78
  handler();
242
79
  }
243
80
  else {
244
- this.#events.once(this.#readyEventName, handler);
81
+ this.once(this.#readyEventName, handler);
245
82
  }
246
83
  }
247
84
  /** @type {MessagePort | null} */
@@ -263,6 +100,7 @@ class TinyIframeEvents {
263
100
  * @param {TinyIframeEventsConfig} config - Configuration object.
264
101
  */
265
102
  constructor({ targetIframe, targetOrigin = window.location.origin, secretEventName = '__tinyIframeEvent__', handshakeEventName = '__tinyIframeHandshake__', readyEventName = '__tinyIframeReady__', } = {}) {
103
+ super();
266
104
  if (targetIframe !== undefined &&
267
105
  (!(targetIframe instanceof HTMLIFrameElement) || !targetIframe.contentWindow)) {
268
106
  throw new TypeError(`[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received ${typeof targetIframe}`);
@@ -404,7 +242,7 @@ class TinyIframeEvents {
404
242
  (this.#selfType === 'parent' && direction !== 'parent')) {
405
243
  return;
406
244
  }
407
- this.#events.emit(eventName, payload, event);
245
+ this.emit(`win:${eventName}`, payload, event);
408
246
  }
409
247
  /**
410
248
  * Marks the communication as ready, flushes any queued messages,
@@ -415,7 +253,7 @@ class TinyIframeEvents {
415
253
  return;
416
254
  this.#ready = true;
417
255
  this.#flushQueue();
418
- this.#events.emit(this.#readyEventName);
256
+ this.emit(this.#readyEventName);
419
257
  }
420
258
  /**
421
259
  * Sends all pending messages queued before the secure port was established.
@@ -437,7 +275,7 @@ class TinyIframeEvents {
437
275
  * @throws {TypeError} If `eventName` is not a string.
438
276
  * @throws {Error} If instance has been destroyed.
439
277
  */
440
- emit(eventName, payload) {
278
+ winEmit(eventName, payload) {
441
279
  if (typeof eventName !== 'string')
442
280
  throw new TypeError('Event name must be a string.');
443
281
  if (this.#isDestroyed)
@@ -478,7 +316,7 @@ class TinyIframeEvents {
478
316
  this.#port.close();
479
317
  this.#port = null;
480
318
  }
481
- this.#events.offAllTypes();
319
+ this.removeAllListeners();
482
320
  this.#pendingQueue = [];
483
321
  instances.delete(this.#targetWindow);
484
322
  }
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var events = require('events');
3
4
  var objChecker = require('../basics/objChecker.cjs');
4
- var TinyEvents = require('./TinyEvents.cjs');
5
5
 
6
6
  /** @type {Map<any, EncodeFn>} */
7
7
  const customEncoders = new Map();
@@ -84,7 +84,7 @@ const customTypesFreezed = new Set([
84
84
  * - Type-specific `set` and `get` methods (`setDate`, `getBool`, etc.)
85
85
  * - `getValue()` to retrieve any structure regardless of type
86
86
  * - Auto-encoding/decoding with support for custom types via `registerJsonType`
87
- * - Built-in event system (`TinyEvents`) to listen for changes
87
+ * - Built-in event system to listen for changes
88
88
  * - Optional fallback values on decoding errors
89
89
  *
90
90
  * Supports registering and unregistering custom types via:
@@ -93,208 +93,7 @@ const customTypesFreezed = new Set([
93
93
  *
94
94
  * This class is suitable for applications that require structured persistence in the browser.
95
95
  */
96
- class TinyLocalStorage {
97
- /** @typedef {import('./TinyEvents.mjs').handler} handler */
98
-
99
- #events = new TinyEvents();
100
-
101
- /**
102
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
103
- *
104
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
105
- */
106
- setThrowOnMaxListeners(shouldThrow) {
107
- return this.#events.setThrowOnMaxListeners(shouldThrow);
108
- }
109
-
110
- /**
111
- * Checks whether an error will be thrown when the max listener limit is exceeded.
112
- *
113
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
114
- */
115
- getThrowOnMaxListeners() {
116
- return this.#events.getThrowOnMaxListeners();
117
- }
118
-
119
- /////////////////////////////////////////////////////////////
120
-
121
- /**
122
- * Adds a listener to the beginning of the listeners array for the specified event.
123
- *
124
- * @param {string|string[]} event - Event name.
125
- * @param {handler} handler - The callback function.
126
- */
127
- prependListener(event, handler) {
128
- return this.#events.prependListener(event, handler);
129
- }
130
-
131
- /**
132
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
133
- *
134
- * @param {string|string[]} event - Event name.
135
- * @param {handler} handler - The callback function.
136
- * @returns {handler[]} - The wrapped handler used internally.
137
- */
138
- prependListenerOnce(event, handler) {
139
- return this.#events.prependListenerOnce(event, handler);
140
- }
141
-
142
- //////////////////////////////////////////////////////////////////////
143
-
144
- /**
145
- * Adds a event listener.
146
- *
147
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
148
- * @param {handler} handler - Callback function to be called when event fires.
149
- */
150
- appendListener(event, handler) {
151
- return this.#events.appendListener(event, handler);
152
- }
153
-
154
- /**
155
- * Registers an event listener that runs only once, then is removed.
156
- *
157
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
158
- * @param {handler} handler - The callback function to run on event.
159
- * @returns {handler[]} - The wrapped version of the handler.
160
- */
161
- appendListenerOnce(event, handler) {
162
- return this.#events.appendListenerOnce(event, handler);
163
- }
164
-
165
- /**
166
- * Adds a event listener.
167
- *
168
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
169
- * @param {handler} handler - Callback function to be called when event fires.
170
- */
171
- on(event, handler) {
172
- return this.#events.on(event, handler);
173
- }
174
-
175
- /**
176
- * Registers an event listener that runs only once, then is removed.
177
- *
178
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
179
- * @param {handler} handler - The callback function to run on event.
180
- * @returns {handler[]} - The wrapped version of the handler.
181
- */
182
- once(event, handler) {
183
- return this.#events.once(event, handler);
184
- }
185
-
186
- ////////////////////////////////////////////////////////////////////
187
-
188
- /**
189
- * Removes a previously registered event listener.
190
- *
191
- * @param {string|string[]} event - The name of the event to remove the handler from.
192
- * @param {handler} handler - The specific callback function to remove.
193
- */
194
- off(event, handler) {
195
- return this.#events.off(event, handler);
196
- }
197
-
198
- /**
199
- * Removes all event listeners of a specific type from the element.
200
- *
201
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
202
- */
203
- offAll(event) {
204
- return this.#events.offAll(event);
205
- }
206
-
207
- /**
208
- * Removes all event listeners of all types from the element.
209
- */
210
- offAllTypes() {
211
- return this.#events.offAllTypes();
212
- }
213
-
214
- ////////////////////////////////////////////////////////////
215
-
216
- /**
217
- * Returns the number of listeners for a given event.
218
- *
219
- * @param {string} event - The name of the event.
220
- * @returns {number} Number of listeners for the event.
221
- */
222
- listenerCount(event) {
223
- return this.#events.listenerCount(event);
224
- }
225
-
226
- /**
227
- * Returns a copy of the array of listeners for the specified event.
228
- *
229
- * @param {string} event - The name of the event.
230
- * @returns {handler[]} Array of listener functions.
231
- */
232
- listeners(event) {
233
- return this.#events.listeners(event);
234
- }
235
-
236
- /**
237
- * Returns a copy of the array of listeners for the specified event.
238
- *
239
- * @param {string} event - The name of the event.
240
- * @returns {handler[]} Array of listener functions.
241
- */
242
- onceListeners(event) {
243
- return this.#events.onceListeners(event);
244
- }
245
-
246
- /**
247
- * Returns a copy of the internal listeners array for the specified event,
248
- * including wrapper functions like those used by `.once()`.
249
- * @param {string | symbol} event - The event name.
250
- * @returns {handler[]} An array of raw listener functions.
251
- */
252
- allListeners(event) {
253
- return this.#events.allListeners(event);
254
- }
255
-
256
- /**
257
- * Returns an array of event names for which there are registered listeners.
258
- *
259
- * @returns {string[]} Array of registered event names.
260
- */
261
- eventNames() {
262
- return this.#events.eventNames();
263
- }
264
-
265
- //////////////////////////////////////////////////////
266
-
267
- /**
268
- * Emits an event, triggering all registered handlers for that event.
269
- *
270
- * @param {string} event - The event name to emit.
271
- * @param {...any} payload - Optional data to pass to each handler.
272
- * @returns {boolean[]} True if any listeners were called, false otherwise.
273
- */
274
- emit(event, ...payload) {
275
- return this.#events.emit(event, ...payload);
276
- }
277
-
278
- /**
279
- * Sets the maximum number of listeners per event before a warning is shown.
280
- *
281
- * @param {number} n - The maximum number of listeners.
282
- */
283
- setMaxListeners(n) {
284
- return this.#events.setMaxListeners(n);
285
- }
286
-
287
- /**
288
- * Gets the maximum number of listeners allowed per event.
289
- *
290
- * @returns {number} The maximum number of listeners.
291
- */
292
- getMaxListeners() {
293
- return this.#events.getMaxListeners();
294
- }
295
-
296
- ///////////////////////////////////////////////////
297
-
96
+ class TinyLocalStorage extends events.EventEmitter {
298
97
  /**
299
98
  * Checks whether a JSON-serializable type is already registered.
300
99
  *
@@ -436,6 +235,7 @@ class TinyLocalStorage {
436
235
  * @param {string} [dbName] - Unique database name.
437
236
  */
438
237
  constructor(dbName) {
238
+ super();
439
239
  if (typeof dbName !== 'undefined' && typeof dbName !== 'string')
440
240
  throw new TypeError('TinyLocalStorage: dbName must be a string if provided.');
441
241
  if (typeof dbName === 'string') this.#dbKey = `LSDB::${dbName}`;
@@ -895,7 +695,7 @@ class TinyLocalStorage {
895
695
  */
896
696
  destroy() {
897
697
  window.removeEventListener('storage', this.#storageEvent);
898
- this.#events.offAllTypes();
698
+ this.removeAllListeners();
899
699
  }
900
700
  }
901
701
 
@@ -91,7 +91,7 @@ export type LocalStorageJsonValue = (Record<string | number | symbol, any> | any
91
91
  * - Type-specific `set` and `get` methods (`setDate`, `getBool`, etc.)
92
92
  * - `getValue()` to retrieve any structure regardless of type
93
93
  * - Auto-encoding/decoding with support for custom types via `registerJsonType`
94
- * - Built-in event system (`TinyEvents`) to listen for changes
94
+ * - Built-in event system to listen for changes
95
95
  * - Optional fallback values on decoding errors
96
96
  *
97
97
  * Supports registering and unregistering custom types via:
@@ -100,7 +100,7 @@ export type LocalStorageJsonValue = (Record<string | number | symbol, any> | any
100
100
  *
101
101
  * This class is suitable for applications that require structured persistence in the browser.
102
102
  */
103
- declare class TinyLocalStorage {
103
+ declare class TinyLocalStorage extends EventEmitter<any> {
104
104
  /**
105
105
  * Checks whether a JSON-serializable type is already registered.
106
106
  *
@@ -137,134 +137,6 @@ declare class TinyLocalStorage {
137
137
  * @param {string} [dbName] - Unique database name.
138
138
  */
139
139
  constructor(dbName?: string);
140
- /**
141
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
142
- *
143
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
144
- */
145
- setThrowOnMaxListeners(shouldThrow: boolean): void;
146
- /**
147
- * Checks whether an error will be thrown when the max listener limit is exceeded.
148
- *
149
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
150
- */
151
- getThrowOnMaxListeners(): boolean;
152
- /**
153
- * Adds a listener to the beginning of the listeners array for the specified event.
154
- *
155
- * @param {string|string[]} event - Event name.
156
- * @param {handler} handler - The callback function.
157
- */
158
- prependListener(event: string | string[], handler: import("./TinyEvents.mjs").handler): void;
159
- /**
160
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
161
- *
162
- * @param {string|string[]} event - Event name.
163
- * @param {handler} handler - The callback function.
164
- * @returns {handler[]} - The wrapped handler used internally.
165
- */
166
- prependListenerOnce(event: string | string[], handler: import("./TinyEvents.mjs").handler): import("./TinyEvents.mjs").handler[];
167
- /**
168
- * Adds a event listener.
169
- *
170
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
171
- * @param {handler} handler - Callback function to be called when event fires.
172
- */
173
- appendListener(event: string | string[], handler: import("./TinyEvents.mjs").handler): void;
174
- /**
175
- * Registers an event listener that runs only once, then is removed.
176
- *
177
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
178
- * @param {handler} handler - The callback function to run on event.
179
- * @returns {handler[]} - The wrapped version of the handler.
180
- */
181
- appendListenerOnce(event: string | string[], handler: import("./TinyEvents.mjs").handler): import("./TinyEvents.mjs").handler[];
182
- /**
183
- * Adds a event listener.
184
- *
185
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
186
- * @param {handler} handler - Callback function to be called when event fires.
187
- */
188
- on(event: string | string[], handler: import("./TinyEvents.mjs").handler): void;
189
- /**
190
- * Registers an event listener that runs only once, then is removed.
191
- *
192
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
193
- * @param {handler} handler - The callback function to run on event.
194
- * @returns {handler[]} - The wrapped version of the handler.
195
- */
196
- once(event: string | string[], handler: import("./TinyEvents.mjs").handler): import("./TinyEvents.mjs").handler[];
197
- /**
198
- * Removes a previously registered event listener.
199
- *
200
- * @param {string|string[]} event - The name of the event to remove the handler from.
201
- * @param {handler} handler - The specific callback function to remove.
202
- */
203
- off(event: string | string[], handler: import("./TinyEvents.mjs").handler): void;
204
- /**
205
- * Removes all event listeners of a specific type from the element.
206
- *
207
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
208
- */
209
- offAll(event: string | string[]): void;
210
- /**
211
- * Removes all event listeners of all types from the element.
212
- */
213
- offAllTypes(): void;
214
- /**
215
- * Returns the number of listeners for a given event.
216
- *
217
- * @param {string} event - The name of the event.
218
- * @returns {number} Number of listeners for the event.
219
- */
220
- listenerCount(event: string): number;
221
- /**
222
- * Returns a copy of the array of listeners for the specified event.
223
- *
224
- * @param {string} event - The name of the event.
225
- * @returns {handler[]} Array of listener functions.
226
- */
227
- listeners(event: string): import("./TinyEvents.mjs").handler[];
228
- /**
229
- * Returns a copy of the array of listeners for the specified event.
230
- *
231
- * @param {string} event - The name of the event.
232
- * @returns {handler[]} Array of listener functions.
233
- */
234
- onceListeners(event: string): import("./TinyEvents.mjs").handler[];
235
- /**
236
- * Returns a copy of the internal listeners array for the specified event,
237
- * including wrapper functions like those used by `.once()`.
238
- * @param {string | symbol} event - The event name.
239
- * @returns {handler[]} An array of raw listener functions.
240
- */
241
- allListeners(event: string | symbol): import("./TinyEvents.mjs").handler[];
242
- /**
243
- * Returns an array of event names for which there are registered listeners.
244
- *
245
- * @returns {string[]} Array of registered event names.
246
- */
247
- eventNames(): string[];
248
- /**
249
- * Emits an event, triggering all registered handlers for that event.
250
- *
251
- * @param {string} event - The event name to emit.
252
- * @param {...any} payload - Optional data to pass to each handler.
253
- * @returns {boolean[]} True if any listeners were called, false otherwise.
254
- */
255
- emit(event: string, ...payload: any[]): boolean[];
256
- /**
257
- * Sets the maximum number of listeners per event before a warning is shown.
258
- *
259
- * @param {number} n - The maximum number of listeners.
260
- */
261
- setMaxListeners(n: number): void;
262
- /**
263
- * Gets the maximum number of listeners allowed per event.
264
- *
265
- * @returns {number} The maximum number of listeners.
266
- */
267
- getMaxListeners(): number;
268
140
  /**
269
141
  * Updates the version of the storage and triggers migration if needed.
270
142
  *
@@ -446,4 +318,5 @@ declare class TinyLocalStorage {
446
318
  destroy(): void;
447
319
  #private;
448
320
  }
321
+ import { EventEmitter } from 'events';
449
322
  //# sourceMappingURL=TinyLocalStorage.d.mts.map