tiny-essentials 1.27.1 → 1.28.1

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 (188) hide show
  1. package/README.md +1 -0
  2. package/changelog/1/28/0.md +16 -0
  3. package/changelog/1/28/1.md +23 -0
  4. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyAnalogClock.min.js +1 -1
  7. package/dist/v1/TinyBasicsEs.min.js +1 -2
  8. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  9. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  10. package/dist/v1/TinyDragger.min.js +1 -1
  11. package/dist/v1/TinyElementObserver.min.js +1 -1
  12. package/dist/v1/TinyEssentials.min.js +1 -2
  13. package/dist/v1/TinyGamepad.min.js +1 -1
  14. package/dist/v1/TinyHtml.min.js +1 -1
  15. package/dist/v1/TinyI18.min.js +1 -1
  16. package/dist/v1/TinyIframeEvents.min.js +1 -1
  17. package/dist/v1/TinyLocalStorage.min.js +1 -1
  18. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  19. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  20. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  21. package/dist/v1/TinyRadioFm.min.js +1 -1
  22. package/dist/v1/TinyRateLimiter.min.js +1 -1
  23. package/dist/v1/TinySmartScroller.min.js +1 -1
  24. package/dist/v1/TinyTextDiffer.min.js +1 -1
  25. package/dist/v1/TinyTextarea.min.js +1 -1
  26. package/dist/v1/TinyTimeout.min.js +1 -1
  27. package/dist/v1/TinyToastNotify.min.js +1 -1
  28. package/dist/v1/TinyUploadClicker.min.js +1 -2
  29. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  30. package/dist/v1/basics/array.cjs +57 -9
  31. package/dist/v1/basics/array.d.mts +27 -11
  32. package/dist/v1/basics/array.mjs +51 -9
  33. package/dist/v1/basics/clock.cjs +94 -42
  34. package/dist/v1/basics/clock.d.mts +10 -10
  35. package/dist/v1/basics/clock.mjs +91 -54
  36. package/dist/v1/basics/deprecated/html.cjs +246 -0
  37. package/dist/v1/basics/deprecated/html.d.mts +63 -0
  38. package/dist/v1/basics/deprecated/html.mjs +190 -0
  39. package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
  40. package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
  41. package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
  42. package/dist/v1/basics/html.cjs +149 -130
  43. package/dist/v1/basics/html.d.mts +26 -61
  44. package/dist/v1/basics/html.mjs +113 -105
  45. package/dist/v1/basics/index.cjs +2 -0
  46. package/dist/v1/basics/index.d.mts +3 -1
  47. package/dist/v1/basics/index.mjs +3 -3
  48. package/dist/v1/basics/mediaContent.cjs +51 -9
  49. package/dist/v1/basics/mediaContent.d.mts +0 -87
  50. package/dist/v1/basics/mediaContent.mjs +40 -10
  51. package/dist/v1/basics/objChecker.cjs +7 -5
  52. package/dist/v1/basics/objChecker.d.mts +3 -2
  53. package/dist/v1/basics/objChecker.mjs +6 -6
  54. package/dist/v1/basics/objFilter.cjs +40 -18
  55. package/dist/v1/basics/objFilter.d.mts +6 -6
  56. package/dist/v1/basics/objFilter.mjs +32 -17
  57. package/dist/v1/basics/simpleMath.cjs +81 -25
  58. package/dist/v1/basics/simpleMath.d.mts +2 -2
  59. package/dist/v1/basics/simpleMath.mjs +70 -27
  60. package/dist/v1/basics/text.cjs +76 -31
  61. package/dist/v1/basics/text.d.mts +69 -7
  62. package/dist/v1/basics/text.mjs +62 -31
  63. package/dist/v1/index.cjs +4 -2
  64. package/dist/v1/index.d.mts +4 -2
  65. package/dist/v1/index.mjs +4 -4
  66. package/dist/v1/libs/TinyAdvancedRaffle.cjs +71 -255
  67. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +6 -134
  68. package/dist/v1/libs/TinyAdvancedRaffle.mjs +69 -228
  69. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
  70. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
  71. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
  72. package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
  73. package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
  74. package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
  75. package/dist/v1/libs/TinyClipboard.cjs +2 -0
  76. package/dist/v1/libs/TinyClipboard.d.mts +4 -2
  77. package/dist/v1/libs/TinyClipboard.mjs +2 -0
  78. package/dist/v1/libs/TinyColorConverter.cjs +1 -0
  79. package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
  80. package/dist/v1/libs/TinyColorConverter.mjs +1 -0
  81. package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
  82. package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
  83. package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
  84. package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
  85. package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
  86. package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
  87. package/dist/v1/libs/TinyDragger.cjs +46 -19
  88. package/dist/v1/libs/TinyDragger.mjs +45 -18
  89. package/dist/v1/libs/TinyElementObserver.cjs +39 -0
  90. package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
  91. package/dist/v1/libs/TinyElementObserver.mjs +36 -0
  92. package/dist/v1/libs/TinyGamepad.cjs +131 -1
  93. package/dist/v1/libs/TinyGamepad.mjs +129 -1
  94. package/dist/v1/libs/TinyHtml.cjs +1 -1
  95. package/dist/v1/libs/TinyHtml.mjs +2 -2
  96. package/dist/v1/libs/TinyI18.cjs +61 -0
  97. package/dist/v1/libs/TinyI18.d.mts +14 -0
  98. package/dist/v1/libs/TinyI18.mjs +55 -0
  99. package/dist/v1/libs/TinyIframeEvents.cjs +26 -196
  100. package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
  101. package/dist/v1/libs/TinyIframeEvents.mjs +26 -171
  102. package/dist/v1/libs/TinyLocalStorage.cjs +53 -205
  103. package/dist/v1/libs/TinyLocalStorage.d.mts +6 -127
  104. package/dist/v1/libs/TinyLocalStorage.mjs +50 -178
  105. package/dist/v1/libs/TinyMediaPlayer.cjs +74 -2
  106. package/dist/v1/libs/TinyMediaPlayer.d.mts +12 -2
  107. package/dist/v1/libs/TinyMediaPlayer.mjs +68 -2
  108. package/dist/v1/libs/TinyNewWinEvents.cjs +39 -197
  109. package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -119
  110. package/dist/v1/libs/TinyNewWinEvents.mjs +36 -172
  111. package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
  112. package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
  113. package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
  114. package/dist/v1/libs/TinyRadioFm.cjs +40 -3
  115. package/dist/v1/libs/TinyRadioFm.d.mts +3 -3
  116. package/dist/v1/libs/TinyRadioFm.mjs +37 -3
  117. package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
  118. package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
  119. package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
  120. package/dist/v1/libs/TinySmartScroller.cjs +56 -205
  121. package/dist/v1/libs/TinySmartScroller.d.mts +19 -152
  122. package/dist/v1/libs/TinySmartScroller.mjs +55 -181
  123. package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
  124. package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
  125. package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
  126. package/dist/v1/libs/TinyTextarea.cjs +19 -0
  127. package/dist/v1/libs/TinyTextarea.d.mts +6 -0
  128. package/dist/v1/libs/TinyTextarea.mjs +17 -0
  129. package/dist/v1/libs/TinyTimeout.cjs +11 -1
  130. package/dist/v1/libs/TinyTimeout.mjs +9 -1
  131. package/dist/v1/libs/TinyToastNotify.cjs +35 -0
  132. package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
  133. package/dist/v1/libs/TinyToastNotify.mjs +31 -0
  134. package/dist/v1/libs/TinyUploadClicker.cjs +20 -0
  135. package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
  136. package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
  137. package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
  138. package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
  139. package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
  140. package/dist/v1/libs/utils.cjs +21 -0
  141. package/dist/v1/libs/utils.d.mts +2 -0
  142. package/dist/v1/libs/utils.mjs +16 -0
  143. package/docs/v1/Exports.md +0 -1
  144. package/docs/v1/README.md +1 -1
  145. package/docs/v1/basics/array.md +2 -2
  146. package/docs/v1/basics/deprecated/html.md +17 -0
  147. package/docs/v1/basics/fullScreen.md +1 -1
  148. package/docs/v1/basics/html.md +12 -26
  149. package/docs/v1/basics/mediaContent.md +1 -1
  150. package/docs/v1/basics/objChecker.md +1 -1
  151. package/docs/v1/basics/objFilter.md +1 -1
  152. package/docs/v1/basics/text.md +2 -2
  153. package/docs/v1/fileManager/main.md +1 -1
  154. package/docs/v1/libs/ColorSafeStringify.md +1 -1
  155. package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
  156. package/docs/v1/libs/TinyAnalogClock.md +1 -1
  157. package/docs/v1/libs/TinyArrayComparator.md +1 -1
  158. package/docs/v1/libs/TinyArrayPaginator.md +1 -1
  159. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
  160. package/docs/v1/libs/TinyClassManager.md +1 -1
  161. package/docs/v1/libs/TinyClipboard.md +1 -1
  162. package/docs/v1/libs/TinyCookieConsent.md +1 -1
  163. package/docs/v1/libs/TinyDomReadyManager.md +1 -1
  164. package/docs/v1/libs/TinyDragDropDetector.md +1 -1
  165. package/docs/v1/libs/TinyDragger.md +1 -1
  166. package/docs/v1/libs/TinyElementObserver.md +1 -1
  167. package/docs/v1/libs/TinyHtml.md +1 -1
  168. package/docs/v1/libs/TinyIframeEvents.md +10 -10
  169. package/docs/v1/libs/TinyLevelUp.md +1 -1
  170. package/docs/v1/libs/TinyLoadingScreen.md +1 -1
  171. package/docs/v1/libs/TinyLocalStorage.md +3 -3
  172. package/docs/v1/libs/TinyNewWinEvents.md +10 -11
  173. package/docs/v1/libs/TinyNotifications.md +1 -1
  174. package/docs/v1/libs/TinyPromiseQueue.md +2 -2
  175. package/docs/v1/libs/TinyTextDiffer.md +1 -1
  176. package/docs/v1/libs/TinyTextarea.md +1 -1
  177. package/package.json +15 -5
  178. package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
  179. package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
  180. package/dist/v1/TinyEvents.min.js +0 -1
  181. package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
  182. package/dist/v1/build/TinyEvents.cjs +0 -7
  183. package/dist/v1/build/TinyEvents.d.mts +0 -3
  184. package/dist/v1/build/TinyEvents.mjs +0 -2
  185. package/dist/v1/libs/TinyEvents.cjs +0 -395
  186. package/dist/v1/libs/TinyEvents.d.mts +0 -164
  187. package/dist/v1/libs/TinyEvents.mjs +0 -360
  188. package/docs/v1/libs/TinyEvents.md +0 -187
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var TinyEvents = require('./TinyEvents.cjs');
3
+ var events = require('events');
4
+ var utils = require('./utils.cjs');
5
+
6
+ const checkDestroy = utils.createCheckDestroyed('TinyAdvancedRaffle');
4
7
 
5
8
  /**
6
9
  * Defines the available normalization strategies for probability weight calculations.
@@ -118,206 +121,7 @@ var TinyEvents = require('./TinyEvents.cjs');
118
121
  *
119
122
  * @class
120
123
  */
121
- class TinyAdvancedRaffle {
122
- #events = new TinyEvents();
123
-
124
- /**
125
- * Emits an event, triggering all registered handlers for that event.
126
- *
127
- * @param {string|string[]} event - The event name to emit.
128
- * @param {...any} payload - Optional data to pass to each handler.
129
- * @returns {boolean[]} True if any listeners were called, false otherwise.
130
- */
131
- #emit(event, ...payload) {
132
- return this.#events.emit(event, ...payload);
133
- }
134
-
135
- /**
136
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
137
- *
138
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
139
- */
140
- setThrowOnMaxListeners(shouldThrow) {
141
- return this.#events.setThrowOnMaxListeners(shouldThrow);
142
- }
143
-
144
- /**
145
- * Checks whether an error will be thrown when the max listener limit is exceeded.
146
- *
147
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
148
- */
149
- getThrowOnMaxListeners() {
150
- return this.#events.getThrowOnMaxListeners();
151
- }
152
-
153
- /////////////////////////////////////////////////////////////
154
-
155
- /**
156
- * Adds a listener to the beginning of the listeners array for the specified event.
157
- *
158
- * @param {string|string[]} event - Event name.
159
- * @param {handler} handler - The callback function.
160
- */
161
- prependListener(event, handler) {
162
- return this.#events.prependListener(event, handler);
163
- }
164
-
165
- /**
166
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
167
- *
168
- * @param {string|string[]} event - Event name.
169
- * @param {handler} handler - The callback function.
170
- * @returns {handler[]} - The wrapped handler used internally.
171
- */
172
- prependListenerOnce(event, handler) {
173
- return this.#events.prependListenerOnce(event, handler);
174
- }
175
-
176
- //////////////////////////////////////////////////////////////////////
177
-
178
- /**
179
- * Adds a event listener.
180
- *
181
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
182
- * @param {handler} handler - Callback function to be called when event fires.
183
- */
184
- appendListener(event, handler) {
185
- return this.#events.appendListener(event, handler);
186
- }
187
-
188
- /**
189
- * Registers an event listener that runs only once, then is removed.
190
- *
191
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
192
- * @param {handler} handler - The callback function to run on event.
193
- * @returns {handler[]} - The wrapped version of the handler.
194
- */
195
- appendListenerOnce(event, handler) {
196
- return this.#events.appendListenerOnce(event, handler);
197
- }
198
-
199
- /**
200
- * Adds a event listener.
201
- *
202
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
203
- * @param {handler} handler - Callback function to be called when event fires.
204
- */
205
- on(event, handler) {
206
- return this.#events.on(event, handler);
207
- }
208
-
209
- /**
210
- * Registers an event listener that runs only once, then is removed.
211
- *
212
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
213
- * @param {handler} handler - The callback function to run on event.
214
- * @returns {handler[]} - The wrapped version of the handler.
215
- */
216
- once(event, handler) {
217
- return this.#events.once(event, handler);
218
- }
219
-
220
- ////////////////////////////////////////////////////////////////////
221
-
222
- /**
223
- * Removes a previously registered event listener.
224
- *
225
- * @param {string|string[]} event - The name of the event to remove the handler from.
226
- * @param {handler} handler - The specific callback function to remove.
227
- */
228
- off(event, handler) {
229
- return this.#events.off(event, handler);
230
- }
231
-
232
- /**
233
- * Removes all event listeners of a specific type from the element.
234
- *
235
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
236
- */
237
- offAll(event) {
238
- return this.#events.offAll(event);
239
- }
240
-
241
- /**
242
- * Removes all event listeners of all types from the element.
243
- */
244
- offAllTypes() {
245
- return this.#events.offAllTypes();
246
- }
247
-
248
- ////////////////////////////////////////////////////////////
249
-
250
- /**
251
- * Returns the number of listeners for a given event.
252
- *
253
- * @param {string} event - The name of the event.
254
- * @returns {number} Number of listeners for the event.
255
- */
256
- listenerCount(event) {
257
- return this.#events.listenerCount(event);
258
- }
259
-
260
- /**
261
- * Returns a copy of the array of listeners for the specified event.
262
- *
263
- * @param {string} event - The name of the event.
264
- * @returns {handler[]} Array of listener functions.
265
- */
266
- listeners(event) {
267
- return this.#events.listeners(event);
268
- }
269
-
270
- /**
271
- * Returns a copy of the array of listeners for the specified event.
272
- *
273
- * @param {string} event - The name of the event.
274
- * @returns {handler[]} Array of listener functions.
275
- */
276
- onceListeners(event) {
277
- return this.#events.onceListeners(event);
278
- }
279
-
280
- /**
281
- * Returns a copy of the internal listeners array for the specified event,
282
- * including wrapper functions like those used by `.once()`.
283
- * @param {string | symbol} event - The event name.
284
- * @returns {handler[]} An array of raw listener functions.
285
- */
286
- allListeners(event) {
287
- return this.#events.allListeners(event);
288
- }
289
-
290
- /**
291
- * Returns an array of event names for which there are registered listeners.
292
- *
293
- * @returns {string[]} Array of registered event names.
294
- */
295
- eventNames() {
296
- return this.#events.eventNames();
297
- }
298
-
299
- //////////////////////////////////////////////////////
300
-
301
- /**
302
- * Sets the maximum number of listeners per event before a warning is shown.
303
- *
304
- * @param {number} n - The maximum number of listeners.
305
- */
306
- setMaxListeners(n) {
307
- return this.#events.setMaxListeners(n);
308
- }
309
-
310
- /**
311
- * Gets the maximum number of listeners allowed per event.
312
- *
313
- * @returns {number} The maximum number of listeners.
314
- */
315
- getMaxListeners() {
316
- return this.#events.getMaxListeners();
317
- }
318
-
319
- ///////////////////////////////////////////////////
320
-
124
+ class TinyAdvancedRaffle extends events.EventEmitter {
321
125
  /**
322
126
  * Whether this instance has been destroyed.
323
127
  * @type {boolean}
@@ -415,6 +219,7 @@ class TinyAdvancedRaffle {
415
219
  * @returns {Record<string, number>} - Object with item IDs as keys and their respective draw counts.
416
220
  */
417
221
  get freq() {
222
+ checkDestroy(this.#isDestroyed);
418
223
  return Object.fromEntries(this.#freq);
419
224
  }
420
225
 
@@ -423,6 +228,7 @@ class TinyAdvancedRaffle {
423
228
  * @returns {number} Total count of items.
424
229
  */
425
230
  get size() {
231
+ checkDestroy(this.#isDestroyed);
426
232
  return this.#items.size;
427
233
  }
428
234
 
@@ -431,6 +237,7 @@ class TinyAdvancedRaffle {
431
237
  * @returns {Normalization} Current normalization mode.
432
238
  */
433
239
  get normalization() {
240
+ checkDestroy(this.#isDestroyed);
434
241
  return this.#normalization;
435
242
  }
436
243
 
@@ -440,7 +247,7 @@ class TinyAdvancedRaffle {
440
247
  * @throws {TypeError} If value is not a non-empty string.
441
248
  */
442
249
  set normalization(value) {
443
- this._checkDestroyed();
250
+ checkDestroy(this.#isDestroyed);
444
251
  if (typeof value !== 'string' || !value.trim()) {
445
252
  throw new TypeError(
446
253
  "normalization must be a non-empty string (e.g., 'relative', 'softmax').",
@@ -454,6 +261,7 @@ class TinyAdvancedRaffle {
454
261
  * @returns {number|null} Current seed or `null` if RNG is not seeded.
455
262
  */
456
263
  get seed() {
264
+ checkDestroy(this.#isDestroyed);
457
265
  return this.#seed;
458
266
  }
459
267
 
@@ -463,7 +271,7 @@ class TinyAdvancedRaffle {
463
271
  * @throws {TypeError} If not `null` or a finite number.
464
272
  */
465
273
  set seed(value) {
466
- this._checkDestroyed();
274
+ checkDestroy(this.#isDestroyed);
467
275
  if (value !== null && (typeof value !== 'number' || !Number.isFinite(value)))
468
276
  throw new TypeError('seed must be a finite number or null.');
469
277
  this.#seed = value;
@@ -475,6 +283,7 @@ class TinyAdvancedRaffle {
475
283
  * @returns {WeightsCallback[]} Array of registered global modifier functions.
476
284
  */
477
285
  get globalModifiers() {
286
+ checkDestroy(this.#isDestroyed);
478
287
  return [...this.#globalModifiers];
479
288
  }
480
289
 
@@ -484,7 +293,7 @@ class TinyAdvancedRaffle {
484
293
  * @throws {TypeError} If not an array of functions.
485
294
  */
486
295
  set globalModifiers(value) {
487
- this._checkDestroyed();
296
+ checkDestroy(this.#isDestroyed);
488
297
  if (!Array.isArray(value) || !value.every((fn) => typeof fn === 'function'))
489
298
  throw new TypeError('globalModifiers must be an array of functions (WeightsCallback).');
490
299
  this.#globalModifiers = value;
@@ -495,6 +304,7 @@ class TinyAdvancedRaffle {
495
304
  * @returns {TempModifier[]} Array of temporary modifier entries.
496
305
  */
497
306
  get temporaryModifiers() {
307
+ checkDestroy(this.#isDestroyed);
498
308
  return [...this.#temporaryModifiers];
499
309
  }
500
310
 
@@ -504,7 +314,7 @@ class TinyAdvancedRaffle {
504
314
  * @throws {TypeError} If structure is invalid.
505
315
  */
506
316
  set temporaryModifiers(value) {
507
- this._checkDestroyed();
317
+ checkDestroy(this.#isDestroyed);
508
318
  if (
509
319
  !Array.isArray(value) ||
510
320
  !value.every(
@@ -522,6 +332,7 @@ class TinyAdvancedRaffle {
522
332
  * @returns {WeightsCallback[]} Array of conditional rule functions.
523
333
  */
524
334
  get conditionalRules() {
335
+ checkDestroy(this.#isDestroyed);
525
336
  return [...this.#conditionalRules];
526
337
  }
527
338
 
@@ -531,7 +342,7 @@ class TinyAdvancedRaffle {
531
342
  * @throws {TypeError} If not an array of functions.
532
343
  */
533
344
  set conditionalRules(value) {
534
- this._checkDestroyed();
345
+ checkDestroy(this.#isDestroyed);
535
346
  if (!Array.isArray(value) || !value.every((fn) => typeof fn === 'function'))
536
347
  throw new TypeError('conditionalRules must be an array of functions (WeightsCallback).');
537
348
  this.#conditionalRules = value;
@@ -542,6 +353,7 @@ class TinyAdvancedRaffle {
542
353
  * @returns {Record<string, Pity>} Object keyed by system name.
543
354
  */
544
355
  get pitySystems() {
356
+ checkDestroy(this.#isDestroyed);
545
357
  return Object.fromEntries(this.#pitySystems);
546
358
  }
547
359
 
@@ -551,7 +363,7 @@ class TinyAdvancedRaffle {
551
363
  * @throws {TypeError} If structure is invalid.
552
364
  */
553
365
  set pitySystems(value) {
554
- this._checkDestroyed();
366
+ checkDestroy(this.#isDestroyed);
555
367
  if (
556
368
  !(value instanceof Map) ||
557
369
  ![...value.values()].every(
@@ -573,6 +385,7 @@ class TinyAdvancedRaffle {
573
385
  * @returns {string[]} Array of item IDs excluded from draws.
574
386
  */
575
387
  get exclusions() {
388
+ checkDestroy(this.#isDestroyed);
576
389
  return Array.from(this.#exclusions);
577
390
  }
578
391
 
@@ -582,7 +395,7 @@ class TinyAdvancedRaffle {
582
395
  * @throws {TypeError} If not a Set of strings.
583
396
  */
584
397
  set exclusions(value) {
585
- this._checkDestroyed();
398
+ checkDestroy(this.#isDestroyed);
586
399
  if (!(value instanceof Set) || ![...value].every((v) => typeof v === 'string'))
587
400
  throw new TypeError('exclusions must be a Set<string>.');
588
401
  this.#exclusions = value;
@@ -593,6 +406,7 @@ class TinyAdvancedRaffle {
593
406
  * @returns {Record<string, string[]>} Object where each key is a group name and value is an array of item IDs.
594
407
  */
595
408
  get groups() {
409
+ checkDestroy(this.#isDestroyed);
596
410
  /** @type {Record<string, string[]>} */
597
411
  const groups = {};
598
412
  this.#groups.forEach((value, key) => (groups[key] = Array.from(value)));
@@ -605,7 +419,7 @@ class TinyAdvancedRaffle {
605
419
  * @throws {TypeError} If not a valid Map<string, Set<string>>.
606
420
  */
607
421
  set groups(value) {
608
- this._checkDestroyed();
422
+ checkDestroy(this.#isDestroyed);
609
423
  if (
610
424
  !(value instanceof Map) ||
611
425
  ![...value.values()].every(
@@ -621,6 +435,7 @@ class TinyAdvancedRaffle {
621
435
  * @returns {RngGenerator} Function returning a floating-point number in [0, 1).
622
436
  */
623
437
  get rng() {
438
+ checkDestroy(this.#isDestroyed);
624
439
  return this.#rng;
625
440
  }
626
441
 
@@ -630,7 +445,7 @@ class TinyAdvancedRaffle {
630
445
  * @throws {TypeError} If not a valid function.
631
446
  */
632
447
  set rng(value) {
633
- this._checkDestroyed();
448
+ checkDestroy(this.#isDestroyed);
634
449
  if (typeof value !== 'function' || typeof value() !== 'number')
635
450
  throw new TypeError('rng must be a function returning a number (RngGenerator).');
636
451
  this.#rng = value;
@@ -641,6 +456,7 @@ class TinyAdvancedRaffle {
641
456
  * @returns {Record<string, ItemDataGetter>} Object keyed by item ID.
642
457
  */
643
458
  get items() {
459
+ checkDestroy(this.#isDestroyed);
644
460
  /** @type {Record<string, ItemDataGetter>} */
645
461
  const items = {};
646
462
  this.#items.forEach((value, key) => {
@@ -655,7 +471,7 @@ class TinyAdvancedRaffle {
655
471
  * @throws {TypeError} If structure is invalid.
656
472
  */
657
473
  set items(value) {
658
- this._checkDestroyed();
474
+ checkDestroy(this.#isDestroyed);
659
475
  if (
660
476
  !(value instanceof Map) ||
661
477
  ![...value.values()].every(
@@ -682,6 +498,7 @@ class TinyAdvancedRaffle {
682
498
  * @param {Normalization} [opts.normalization='relative'] - Probability normalization mode.
683
499
  */
684
500
  constructor(opts = {}) {
501
+ super();
685
502
  const { rng = null, seed = null, normalization = 'relative' } = opts;
686
503
  this.#normalization = normalization;
687
504
  this.#seed = seed;
@@ -691,16 +508,6 @@ class TinyAdvancedRaffle {
691
508
  this.#seed = seed ?? null;
692
509
  }
693
510
 
694
- /**
695
- * Checks if the instance has been destroyed and throws an error if so.
696
- * @private
697
- * @throws {Error} If the instance has already been destroyed.
698
- */
699
- _checkDestroyed() {
700
- if (this.#isDestroyed)
701
- throw new Error('This instance has been destroyed and can no longer be used.');
702
- }
703
-
704
511
  /* ===========================
705
512
  Public: Item management
706
513
  =========================== */
@@ -712,6 +519,7 @@ class TinyAdvancedRaffle {
712
519
  * @throws {TypeError} If `itemId` is not a string.
713
520
  */
714
521
  hasItem(itemId) {
522
+ checkDestroy(this.#isDestroyed);
715
523
  if (typeof itemId !== 'string') throw new TypeError('itemId must be a string');
716
524
  return this.#items.has(itemId);
717
525
  }
@@ -728,7 +536,7 @@ class TinyAdvancedRaffle {
728
536
  * @throws {TypeError} If any parameter has an invalid type.
729
537
  */
730
538
  addItem(id, opts = {}) {
731
- this._checkDestroyed();
539
+ checkDestroy(this.#isDestroyed);
732
540
  if (typeof id !== 'string' || !id.trim()) throw new TypeError('id must be a non-empty string');
733
541
  if (typeof opts !== 'object' || opts === null) throw new TypeError('opts must be an object');
734
542
  let { weight = 1, label = id, meta = {}, groups = [] } = opts;
@@ -758,7 +566,7 @@ class TinyAdvancedRaffle {
758
566
  this.#items.set(id, entry);
759
567
  // Register in groups map
760
568
  for (const g of groups) this._ensureGroup(g).add(id);
761
- this.#emit('itemAdded', entry);
569
+ this.emit('itemAdded', entry);
762
570
  return entry;
763
571
  }
764
572
 
@@ -769,7 +577,7 @@ class TinyAdvancedRaffle {
769
577
  * @throws {TypeError} If id is not a string.
770
578
  */
771
579
  removeItem(id) {
772
- this._checkDestroyed();
580
+ checkDestroy(this.#isDestroyed);
773
581
  if (typeof id !== 'string' || !id.trim()) throw new TypeError('id must be a non-empty string');
774
582
  const it = this.#items.get(id);
775
583
  if (!it) return false;
@@ -778,7 +586,7 @@ class TinyAdvancedRaffle {
778
586
  if (s) s.delete(id);
779
587
  }
780
588
  this.#items.delete(id);
781
- this.#emit('itemRemoved', id);
589
+ this.emit('itemRemoved', id);
782
590
  this.resetFreq(id);
783
591
  this.resetPity(id);
784
592
  return true;
@@ -792,14 +600,14 @@ class TinyAdvancedRaffle {
792
600
  * @throws {TypeError} If weight is invalid.
793
601
  */
794
602
  setBaseWeight(id, weight) {
795
- this._checkDestroyed();
603
+ checkDestroy(this.#isDestroyed);
796
604
  if (typeof id !== 'string' || !id.trim()) throw new TypeError('id must be a non-empty string');
797
605
  if (typeof weight !== 'number' || !Number.isFinite(weight) || weight < 0)
798
606
  throw new TypeError('weight must be a non-negative number');
799
607
  const it = this.#items.get(id);
800
608
  if (!it) throw new Error('Item not found');
801
609
  it.baseWeight = Math.max(0, Number(weight) || 0);
802
- this.#emit('weightChanged', { id, weight: it.baseWeight });
610
+ this.emit('weightChanged', { id, weight: it.baseWeight });
803
611
  }
804
612
 
805
613
  /**
@@ -809,6 +617,7 @@ class TinyAdvancedRaffle {
809
617
  * @throws {TypeError} If id is not a string.
810
618
  */
811
619
  getItem(id) {
620
+ checkDestroy(this.#isDestroyed);
812
621
  if (typeof id !== 'string' || !id.trim()) throw new TypeError('id must be a non-empty string');
813
622
  return this.#items.get(id) ?? null;
814
623
  }
@@ -818,6 +627,7 @@ class TinyAdvancedRaffle {
818
627
  * @returns {ItemData[]} Array of cloned item objects.
819
628
  */
820
629
  listItems() {
630
+ checkDestroy(this.#isDestroyed);
821
631
  return Array.from(this.#items.values()).map((i) => ({ ...i }));
822
632
  }
823
633
 
@@ -825,7 +635,7 @@ class TinyAdvancedRaffle {
825
635
  * Clear all items from the system.
826
636
  */
827
637
  clearList() {
828
- this._checkDestroyed();
638
+ checkDestroy(this.#isDestroyed);
829
639
  this.#items.clear();
830
640
  this.clearFreqs();
831
641
  this.clearPities();
@@ -842,6 +652,7 @@ class TinyAdvancedRaffle {
842
652
  * @throws {TypeError} If `fn` is not a function.
843
653
  */
844
654
  hasGlobalModifier(fn) {
655
+ checkDestroy(this.#isDestroyed);
845
656
  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
846
657
  return this.#globalModifiers.includes(fn);
847
658
  }
@@ -853,7 +664,7 @@ class TinyAdvancedRaffle {
853
664
  * @throws {TypeError} If `fn` is not a function.
854
665
  */
855
666
  addGlobalModifier(fn) {
856
- this._checkDestroyed();
667
+ checkDestroy(this.#isDestroyed);
857
668
  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
858
669
  this.#globalModifiers.push(fn);
859
670
  }
@@ -864,7 +675,7 @@ class TinyAdvancedRaffle {
864
675
  * @throws {TypeError} If `fn` is not a function.
865
676
  */
866
677
  removeGlobalModifier(fn) {
867
- this._checkDestroyed();
678
+ checkDestroy(this.#isDestroyed);
868
679
  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
869
680
  this.#globalModifiers = this.#globalModifiers.filter((x) => x !== fn);
870
681
  }
@@ -876,6 +687,7 @@ class TinyAdvancedRaffle {
876
687
  * @throws {TypeError} If `fn` is not a function.
877
688
  */
878
689
  hasTemporaryModifier(fn) {
690
+ checkDestroy(this.#isDestroyed);
879
691
  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
880
692
  return this.#temporaryModifiers.some((mod) => mod.fn === fn);
881
693
  }
@@ -889,7 +701,7 @@ class TinyAdvancedRaffle {
889
701
  * @throws {TypeError} If `uses` is not a number.
890
702
  */
891
703
  addTemporaryModifier(fn, uses = 1) {
892
- this._checkDestroyed();
704
+ checkDestroy(this.#isDestroyed);
893
705
  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
894
706
  if (typeof uses !== 'number' || Number.isNaN(uses))
895
707
  throw new TypeError('uses must be a number');
@@ -904,7 +716,7 @@ class TinyAdvancedRaffle {
904
716
  * @throws {TypeError} If `fn` is not a function.
905
717
  */
906
718
  removeTemporaryModifier(fn) {
907
- this._checkDestroyed();
719
+ checkDestroy(this.#isDestroyed);
908
720
  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
909
721
  const originalLength = this.#temporaryModifiers.length;
910
722
  this.#temporaryModifiers = this.#temporaryModifiers.filter((mod) => mod.fn !== fn);
@@ -918,6 +730,7 @@ class TinyAdvancedRaffle {
918
730
  * @throws {TypeError} If `ruleFn` is not a function.
919
731
  */
920
732
  hasConditionalRule(ruleFn) {
733
+ checkDestroy(this.#isDestroyed);
921
734
  if (typeof ruleFn !== 'function') throw new TypeError('ruleFn must be a function');
922
735
  return this.#conditionalRules.includes(ruleFn);
923
736
  }
@@ -930,7 +743,7 @@ class TinyAdvancedRaffle {
930
743
  * @throws {TypeError} If `ruleFn` is not a function.
931
744
  */
932
745
  addConditionalRule(ruleFn) {
933
- this._checkDestroyed();
746
+ checkDestroy(this.#isDestroyed);
934
747
  if (typeof ruleFn !== 'function') throw new TypeError('ruleFn must be a function');
935
748
  this.#conditionalRules.push(ruleFn);
936
749
  }
@@ -943,7 +756,7 @@ class TinyAdvancedRaffle {
943
756
  * @throws {TypeError} If `ruleFn` is not a function.
944
757
  */
945
758
  removeConditionalRule(ruleFn) {
946
- this._checkDestroyed();
759
+ checkDestroy(this.#isDestroyed);
947
760
  if (typeof ruleFn !== 'function') throw new TypeError('ruleFn must be a function');
948
761
  const originalLength = this.#conditionalRules.length;
949
762
  this.#conditionalRules = this.#conditionalRules.filter((fn) => fn !== ruleFn);
@@ -961,6 +774,7 @@ class TinyAdvancedRaffle {
961
774
  * @throws {TypeError} If `itemId` is not a string.
962
775
  */
963
776
  hasPity(itemId) {
777
+ checkDestroy(this.#isDestroyed);
964
778
  if (typeof itemId !== 'string') throw new TypeError('itemId must be a string');
965
779
  return this.#pitySystems.has(itemId);
966
780
  }
@@ -977,7 +791,7 @@ class TinyAdvancedRaffle {
977
791
  * @throws {TypeError} If parameters are invalid.
978
792
  */
979
793
  configurePity(itemId, cfg) {
980
- this._checkDestroyed();
794
+ checkDestroy(this.#isDestroyed);
981
795
  if (!this.#items.has(itemId)) throw new Error('Item not found');
982
796
  if (typeof cfg !== 'object' || cfg === null) throw new TypeError('cfg must be an object');
983
797
  const { threshold, increment, cap = Infinity } = cfg;
@@ -1001,7 +815,7 @@ class TinyAdvancedRaffle {
1001
815
  * @throws {TypeError} If itemId is not a string.
1002
816
  */
1003
817
  resetPity(itemId) {
1004
- this._checkDestroyed();
818
+ checkDestroy(this.#isDestroyed);
1005
819
  if (typeof itemId !== 'string' || !itemId.trim())
1006
820
  throw new TypeError('itemId must be a non-empty string');
1007
821
  const p = this.#pitySystems.get(itemId);
@@ -1015,7 +829,7 @@ class TinyAdvancedRaffle {
1015
829
  * Remove all pity configurations.
1016
830
  */
1017
831
  clearPities() {
1018
- this._checkDestroyed();
832
+ checkDestroy(this.#isDestroyed);
1019
833
  this.#pitySystems.clear();
1020
834
  }
1021
835
 
@@ -1030,6 +844,7 @@ class TinyAdvancedRaffle {
1030
844
  * @throws {TypeError} If `itemId` is not a string.
1031
845
  */
1032
846
  hasExclusion(itemId) {
847
+ checkDestroy(this.#isDestroyed);
1033
848
  if (typeof itemId !== 'string') throw new TypeError('itemId must be a string');
1034
849
  return this.#exclusions.has(itemId);
1035
850
  }
@@ -1040,7 +855,7 @@ class TinyAdvancedRaffle {
1040
855
  * @throws {TypeError} If `itemId` is not a string.
1041
856
  */
1042
857
  excludeItem(itemId) {
1043
- this._checkDestroyed();
858
+ checkDestroy(this.#isDestroyed);
1044
859
  if (typeof itemId !== 'string') throw new TypeError('itemId must be a string');
1045
860
  this.#exclusions.add(itemId);
1046
861
  }
@@ -1051,7 +866,7 @@ class TinyAdvancedRaffle {
1051
866
  * @throws {TypeError} If `itemId` is not a string.
1052
867
  */
1053
868
  includeItem(itemId) {
1054
- this._checkDestroyed();
869
+ checkDestroy(this.#isDestroyed);
1055
870
  if (typeof itemId !== 'string') throw new TypeError('itemId must be a string');
1056
871
  this.#exclusions.delete(itemId);
1057
872
  }
@@ -1064,7 +879,7 @@ class TinyAdvancedRaffle {
1064
879
  * @private
1065
880
  */
1066
881
  _ensureGroup(name) {
1067
- this._checkDestroyed();
882
+ checkDestroy(this.#isDestroyed);
1068
883
  if (typeof name !== 'string') throw new TypeError('name must be a string');
1069
884
  let group = this.#groups.get(name);
1070
885
  if (!group) {
@@ -1082,6 +897,7 @@ class TinyAdvancedRaffle {
1082
897
  * @throws {TypeError} If parameters are not strings.
1083
898
  */
1084
899
  hasInGroup(itemId, groupName) {
900
+ checkDestroy(this.#isDestroyed);
1085
901
  if (typeof itemId !== 'string' || typeof groupName !== 'string')
1086
902
  throw new TypeError('itemId and groupName must be strings');
1087
903
  const group = this.#groups.get(groupName);
@@ -1096,7 +912,7 @@ class TinyAdvancedRaffle {
1096
912
  * @throws {TypeError} If parameters are not strings.
1097
913
  */
1098
914
  addToGroup(itemId, groupName) {
1099
- this._checkDestroyed();
915
+ checkDestroy(this.#isDestroyed);
1100
916
  if (typeof itemId !== 'string' || typeof groupName !== 'string')
1101
917
  throw new TypeError('itemId and groupName must be strings');
1102
918
  const it = this.#items.get(itemId);
@@ -1112,7 +928,7 @@ class TinyAdvancedRaffle {
1112
928
  * @throws {TypeError} If parameters are not strings.
1113
929
  */
1114
930
  removeFromGroup(itemId, groupName) {
1115
- this._checkDestroyed();
931
+ checkDestroy(this.#isDestroyed);
1116
932
  if (typeof itemId !== 'string' || typeof groupName !== 'string')
1117
933
  throw new TypeError('itemId and groupName must be strings');
1118
934
  const g = this.#groups.get(groupName);
@@ -1130,7 +946,7 @@ class TinyAdvancedRaffle {
1130
946
  * Effectively resets the internal frequency map to an empty state.
1131
947
  */
1132
948
  clearFreqs() {
1133
- this._checkDestroyed();
949
+ checkDestroy(this.#isDestroyed);
1134
950
  this.#freq.clear();
1135
951
  }
1136
952
 
@@ -1142,7 +958,7 @@ class TinyAdvancedRaffle {
1142
958
  * @throws {TypeError} If `itemId` is not a string.
1143
959
  */
1144
960
  resetFreq(itemId) {
1145
- this._checkDestroyed();
961
+ checkDestroy(this.#isDestroyed);
1146
962
  if (typeof itemId !== 'string') throw new TypeError('itemId must be a string');
1147
963
  this.#freq.delete(itemId);
1148
964
  }
@@ -1157,7 +973,7 @@ class TinyAdvancedRaffle {
1157
973
  * @throws {TypeError} If `context` is provided but is not an object.
1158
974
  */
1159
975
  computeEffectiveWeights(context = {}) {
1160
- this._checkDestroyed();
976
+ checkDestroy(this.#isDestroyed);
1161
977
  if (typeof context !== 'object' || context === null)
1162
978
  throw new TypeError(
1163
979
  `computeEffectiveWeights: parameter 'context' must be a non-null object, got ${typeof context}`,
@@ -1246,9 +1062,9 @@ class TinyAdvancedRaffle {
1246
1062
  * @param {Map<string, number>} weights - Map of item IDs to their weights.
1247
1063
  * @returns {Array<{id: string, weight: number, p: number, cumulative: number}>} Distribution array.
1248
1064
  * @throws {TypeError} If `weights` is not a Map.
1065
+ * @private
1249
1066
  */
1250
1067
  _weightsToDistribution(weights) {
1251
- this._checkDestroyed();
1252
1068
  if (!(weights instanceof Map))
1253
1069
  throw new TypeError(
1254
1070
  `_weightsToDistribution: parameter 'weights' must be a Map, got ${typeof weights}`,
@@ -1302,7 +1118,7 @@ class TinyAdvancedRaffle {
1302
1118
  * @throws {TypeError} If `opts` is not an object.
1303
1119
  */
1304
1120
  drawOne(opts = {}) {
1305
- this._checkDestroyed();
1121
+ checkDestroy(this.#isDestroyed);
1306
1122
  if (typeof opts !== 'object' || opts === null)
1307
1123
  throw new TypeError(
1308
1124
  `drawOne: parameter 'opts' must be a non-null object, got ${typeof opts}`,
@@ -1349,7 +1165,7 @@ class TinyAdvancedRaffle {
1349
1165
  const item = this.#items.get(chosen.id);
1350
1166
  if (!item) return null;
1351
1167
  const result = { id: item.id, label: item.label, meta: { ...item.meta }, prob: chosen.p };
1352
- this.#emit('draw', result);
1168
+ this.emit('draw', result);
1353
1169
 
1354
1170
  // add frequence
1355
1171
  if (result) this.#freq.set(result.id, (this.#freq.get(result.id) || 0) + 1);
@@ -1364,7 +1180,6 @@ class TinyAdvancedRaffle {
1364
1180
  * @private
1365
1181
  */
1366
1182
  _consumeTemporaryModifiers() {
1367
- this._checkDestroyed();
1368
1183
  for (let i = this.#temporaryModifiers.length - 1; i >= 0; --i) {
1369
1184
  const t = this.#temporaryModifiers[i];
1370
1185
  t.uses -= 1;
@@ -1386,7 +1201,7 @@ class TinyAdvancedRaffle {
1386
1201
  * @throws {TypeError} If `opts` is not an object.
1387
1202
  */
1388
1203
  drawMany(count = 1, opts = {}) {
1389
- this._checkDestroyed();
1204
+ checkDestroy(this.#isDestroyed);
1390
1205
  if (!Number.isInteger(count) || count <= 0)
1391
1206
  throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${count}`);
1392
1207
  if (typeof opts !== 'object' || opts === null)
@@ -1469,7 +1284,7 @@ class TinyAdvancedRaffle {
1469
1284
  * @returns {ExportedJson} Exported configuration object.
1470
1285
  */
1471
1286
  exportToJson() {
1472
- this._checkDestroyed();
1287
+ checkDestroy(this.#isDestroyed);
1473
1288
  const data = {
1474
1289
  items: Array.from(this.#items.values()).map((it) => ({
1475
1290
  id: it.id,
@@ -1496,7 +1311,7 @@ class TinyAdvancedRaffle {
1496
1311
  * @throws {TypeError} If `data.seed` is not a number, null, or undefined.
1497
1312
  */
1498
1313
  loadFromJson(data) {
1499
- this._checkDestroyed();
1314
+ checkDestroy(this.#isDestroyed);
1500
1315
  if (typeof data !== 'object' || data === null)
1501
1316
  throw new TypeError('data must be a non-null object');
1502
1317
  if (!Array.isArray(data.items) || !Array.isArray(data.pity) || !Array.isArray(data.exclusions))
@@ -1550,7 +1365,7 @@ class TinyAdvancedRaffle {
1550
1365
  * @returns {TinyAdvancedRaffle} A new cloned instance, fully independent from the original.
1551
1366
  */
1552
1367
  clone() {
1553
- this._checkDestroyed();
1368
+ checkDestroy(this.#isDestroyed);
1554
1369
  const cloneInstance = new TinyAdvancedRaffle();
1555
1370
 
1556
1371
  // Primitive values
@@ -1610,9 +1425,9 @@ class TinyAdvancedRaffle {
1610
1425
  * @param {number} seed - Seed value for PRNG (integer).
1611
1426
  * @returns {RngGenerator} A function that returns a pseudo-random number in [0, 1).
1612
1427
  * @throws {TypeError} If `seed` is not a finite number.
1428
+ * @private
1613
1429
  */
1614
1430
  _makeSeededRng(seed) {
1615
- this._checkDestroyed();
1616
1431
  if (typeof seed !== 'number' || !Number.isFinite(seed))
1617
1432
  throw new TypeError('seed must be a finite number');
1618
1433
  // mulberry32
@@ -1632,7 +1447,6 @@ class TinyAdvancedRaffle {
1632
1447
  */
1633
1448
  destroy() {
1634
1449
  if (this.#isDestroyed) return;
1635
- this.#isDestroyed = true;
1636
1450
 
1637
1451
  // Clear all Maps and Sets
1638
1452
  this.#pitySystems.clear();
@@ -1648,6 +1462,8 @@ class TinyAdvancedRaffle {
1648
1462
 
1649
1463
  // Nullify core references
1650
1464
  this.#seed = null;
1465
+
1466
+ this.#isDestroyed = true;
1651
1467
  }
1652
1468
  }
1653
1469