tiny-essentials 1.18.0 โ†’ 1.19.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 (93) hide show
  1. package/README.md +17 -3
  2. package/dist/legacy/get/countObj.cjs +2 -2
  3. package/dist/legacy/get/countObj.d.mts +1 -1
  4. package/dist/legacy/get/countObj.mjs +1 -1
  5. package/dist/legacy/index.cjs +2 -1
  6. package/dist/node_modules/firebase-functions/lib/common/trace.cjs +0 -1
  7. package/dist/node_modules/firebase-functions/lib/logger/index.cjs +1 -0
  8. package/dist/v1/ColorSafeStringify.min.js +1 -1
  9. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  10. package/dist/v1/TinyBasicsEs.js +402 -390
  11. package/dist/v1/TinyBasicsEs.min.js +1 -1
  12. package/dist/v1/TinyClipboard.min.js +1 -1
  13. package/dist/v1/TinyColorConverter.js +617 -0
  14. package/dist/v1/TinyColorConverter.min.js +1 -0
  15. package/dist/v1/TinyDomReadyManager.min.js +1 -1
  16. package/dist/v1/TinyDragger.js +6 -2433
  17. package/dist/v1/TinyDragger.min.js +1 -2
  18. package/dist/v1/TinyEssentials.js +3546 -1388
  19. package/dist/v1/TinyEssentials.min.js +1 -1
  20. package/dist/v1/TinyEvents.js +402 -0
  21. package/dist/v1/TinyEvents.min.js +1 -0
  22. package/dist/v1/TinyHtml.min.js +1 -1
  23. package/dist/v1/TinyLocalStorage.js +1292 -0
  24. package/dist/v1/TinyLocalStorage.min.js +1 -0
  25. package/dist/v1/TinyNotifications.min.js +1 -1
  26. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  27. package/dist/v1/TinyPromiseQueue.min.js +1 -1
  28. package/dist/v1/TinyRateLimiter.js +2 -1
  29. package/dist/v1/TinyRateLimiter.min.js +1 -1
  30. package/dist/v1/TinySmartScroller.js +570 -52
  31. package/dist/v1/TinySmartScroller.min.js +1 -1
  32. package/dist/v1/TinyTextRangeEditor.min.js +1 -1
  33. package/dist/v1/TinyTimeout.js +233 -0
  34. package/dist/v1/TinyTimeout.min.js +1 -0
  35. package/dist/v1/TinyToastNotify.min.js +1 -1
  36. package/dist/v1/TinyUploadClicker.js +2087 -1129
  37. package/dist/v1/TinyUploadClicker.min.js +1 -1
  38. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  39. package/dist/v1/basics/html.cjs +16 -9
  40. package/dist/v1/basics/html.d.mts +12 -4
  41. package/dist/v1/basics/html.mjs +14 -7
  42. package/dist/v1/basics/index.cjs +3 -2
  43. package/dist/v1/basics/index.d.mts +2 -2
  44. package/dist/v1/basics/index.mjs +2 -1
  45. package/dist/v1/basics/objChecker.cjs +46 -0
  46. package/dist/v1/basics/objChecker.d.mts +29 -0
  47. package/dist/v1/basics/objChecker.mjs +45 -0
  48. package/dist/v1/basics/objFilter.cjs +4 -45
  49. package/dist/v1/basics/objFilter.d.mts +3 -28
  50. package/dist/v1/basics/objFilter.mjs +2 -45
  51. package/dist/v1/build/TinyColorConverter.cjs +7 -0
  52. package/dist/v1/build/TinyColorConverter.d.mts +3 -0
  53. package/dist/v1/build/TinyColorConverter.mjs +2 -0
  54. package/dist/v1/build/TinyEvents.cjs +7 -0
  55. package/dist/v1/build/TinyEvents.d.mts +3 -0
  56. package/dist/v1/build/TinyEvents.mjs +2 -0
  57. package/dist/v1/build/TinyLocalStorage.cjs +7 -0
  58. package/dist/v1/build/TinyLocalStorage.d.mts +3 -0
  59. package/dist/v1/build/TinyLocalStorage.mjs +2 -0
  60. package/dist/v1/build/TinyTimeout.cjs +7 -0
  61. package/dist/v1/build/TinyTimeout.d.mts +3 -0
  62. package/dist/v1/build/TinyTimeout.mjs +2 -0
  63. package/dist/v1/index.cjs +11 -2
  64. package/dist/v1/index.d.mts +7 -3
  65. package/dist/v1/index.mjs +7 -2
  66. package/dist/v1/libs/TinyColorConverter.cjs +578 -0
  67. package/dist/v1/libs/TinyColorConverter.d.mts +396 -0
  68. package/dist/v1/libs/TinyColorConverter.mjs +520 -0
  69. package/dist/v1/libs/TinyDragger.cjs +3 -3
  70. package/dist/v1/libs/TinyDragger.mjs +1 -1
  71. package/dist/v1/libs/TinyEvents.cjs +363 -0
  72. package/dist/v1/libs/TinyEvents.d.mts +160 -0
  73. package/dist/v1/libs/TinyEvents.mjs +328 -0
  74. package/dist/v1/libs/TinyLocalStorage.cjs +847 -0
  75. package/dist/v1/libs/TinyLocalStorage.d.mts +407 -0
  76. package/dist/v1/libs/TinyLocalStorage.mjs +740 -0
  77. package/dist/v1/libs/TinySmartScroller.cjs +207 -52
  78. package/dist/v1/libs/TinySmartScroller.d.mts +164 -16
  79. package/dist/v1/libs/TinySmartScroller.mjs +181 -52
  80. package/dist/v1/libs/TinyTimeout.cjs +194 -0
  81. package/dist/v1/libs/TinyTimeout.d.mts +89 -0
  82. package/dist/v1/libs/TinyTimeout.mjs +179 -0
  83. package/dist/v1/libs/TinyUploadClicker.cjs +6 -4
  84. package/docs/v1/README.md +5 -0
  85. package/docs/v1/basics/objChecker.md +47 -0
  86. package/docs/v1/basics/objFilter.md +0 -40
  87. package/docs/v1/libs/TinyColorConverter.md +220 -0
  88. package/docs/v1/libs/TinyEvents.md +199 -0
  89. package/docs/v1/libs/TinyLocalStorage.md +350 -0
  90. package/docs/v1/libs/TinyRateLimiter.md +0 -3
  91. package/docs/v1/libs/TinyTimeout.md +190 -0
  92. package/package.json +28 -5
  93. package/dist/v1/TinyDragger.min.js.LICENSE.txt +0 -8
@@ -0,0 +1,199 @@
1
+ # ๐Ÿ“ฆ TinyEvents
2
+
3
+ A **lightweight event emitter** class similar to Node.js's `EventEmitter`, written in modern JavaScript with no dependencies. Perfect for publish/subscribe patterns in modular apps.
4
+
5
+ ---
6
+
7
+ ## ๐Ÿง  What is TinyEvents?
8
+
9
+ `TinyEvents` enables your components or modules to **subscribe to**, **emit**, and **manage custom events**.
10
+
11
+ It supports:
12
+
13
+ * ๐Ÿ” Persistent listeners (`on`, `appendListener`, `prependListener`)
14
+ * ๐Ÿ”‚ One-time listeners (`once`, `appendListenerOnce`, `prependListenerOnce`)
15
+ * ๐Ÿ“ค Emitting events (`emit`)
16
+ * ๐Ÿ” Inspecting listeners (`listenerCount`, `listeners`, `onceListeners`, `allListeners`, `eventNames`)
17
+ * ๐Ÿงน Removing listeners (`off`, `offAll`, `offAllTypes`)
18
+ * ๐Ÿšฆ Controlling listener count (`setMaxListeners`, `getMaxListeners`)
19
+
20
+ ---
21
+
22
+ ## ๐Ÿ”ง API Reference
23
+
24
+ ### `on(event: string, handler: function): void`
25
+
26
+ Adds a listener for the specified event.
27
+
28
+ ```js
29
+ emitter.on('hello', (name) => console.log(`Hi, ${name}`));
30
+ ```
31
+
32
+ ---
33
+
34
+ ### `once(event: string, handler: function): function`
35
+
36
+ Adds a one-time listener that is automatically removed after it runs once.
37
+
38
+ ```js
39
+ emitter.once('data', console.log);
40
+ ```
41
+
42
+ ---
43
+
44
+ ### `appendListener(event: string, handler: function): void`
45
+
46
+ Alias for `on()`.
47
+
48
+ ---
49
+
50
+ ### `appendListenerOnce(event: string, handler: function): function`
51
+
52
+ Alias for `once()`.
53
+
54
+ ---
55
+
56
+ ### `prependListener(event: string, handler: function): void`
57
+
58
+ Adds a listener to the **start** of the listener array (called before others).
59
+
60
+ ---
61
+
62
+ ### `prependListenerOnce(event: string, handler: function): function`
63
+
64
+ Adds a one-time listener to the **start** of the listener array.
65
+
66
+ ---
67
+
68
+ ### `emit(event: string, ...payload: any[]): boolean`
69
+
70
+ Calls all listeners for an event, passing any number of arguments.
71
+
72
+ Returns `true` if any listeners were called, otherwise `false`.
73
+
74
+ ```js
75
+ emitter.emit('greet', 'Yasmin', 21);
76
+ ```
77
+
78
+ ---
79
+
80
+ ### `off(event: string, handler: function): void`
81
+
82
+ Removes a specific listener from an event.
83
+
84
+ ---
85
+
86
+ ### `offAll(event: string): void`
87
+
88
+ Removes **all listeners** for a specific event.
89
+
90
+ ---
91
+
92
+ ### `offAllTypes(): void`
93
+
94
+ Clears **all listeners** from **all events**.
95
+
96
+ ---
97
+
98
+ ### `listenerCount(event: string): number`
99
+
100
+ Returns how many listeners are currently registered for the event.
101
+
102
+ ---
103
+
104
+ ### `listeners(event: string): function[]`
105
+
106
+ Returns an array of **non-once** listener functions for an event.
107
+
108
+ ---
109
+
110
+ ### `onceListeners(event: string): function[]`
111
+
112
+ Returns an array of **once-only** listener functions for an event.
113
+
114
+ ---
115
+
116
+ ### `allListeners(event: string): function[]`
117
+
118
+ Returns all listeners, including wrapped `once()` functions.
119
+
120
+ ---
121
+
122
+ ### `eventNames(): string[]`
123
+
124
+ Returns an array of event names that currently have listeners.
125
+
126
+ ---
127
+
128
+ ### `setMaxListeners(n: number): void`
129
+
130
+ Sets the maximum allowed listeners per event. Shows a warning if exceeded.
131
+
132
+ ---
133
+
134
+ ### `getMaxListeners(): number`
135
+
136
+ Returns the current max listener limit (default: 10).
137
+
138
+ ---
139
+
140
+ ### `setThrowOnMaxListeners(shouldThrow: boolean): void`
141
+
142
+ Enables or disables the behavior of throwing an error when the number of listeners exceeds the maximum limit.
143
+
144
+ * If `true`, the class will **throw an error** instead of just logging a warning.
145
+ * If `false`, it will default to console warning (default behavior).
146
+
147
+ #### Parameters:
148
+
149
+ * `shouldThrow` *(boolean)* โ€“ Whether to throw an error when the listener limit is exceeded.
150
+
151
+ ---
152
+
153
+ ### `getThrowOnMaxListeners(): boolean`
154
+
155
+ Returns whether the emitter is currently set to throw an error when the maximum number of listeners is exceeded.
156
+
157
+ #### Returns:
158
+
159
+ * *(boolean)* โ€“ `true` if error throwing is enabled, otherwise `false`.
160
+
161
+ ---
162
+
163
+ ## ๐Ÿงช Example
164
+
165
+ ```js
166
+ import TinyEvents from './TinyEvents.js';
167
+
168
+ const emitter = new TinyEvents();
169
+
170
+ function greet(name) {
171
+ console.log(`๐Ÿ‘‹ Hello, ${name}`);
172
+ }
173
+
174
+ emitter.on('greet', greet);
175
+ emitter.emit('greet', 'Yasmin'); // "๐Ÿ‘‹ Hello, Yasmin"
176
+ emitter.off('greet', greet);
177
+ ```
178
+
179
+ ---
180
+
181
+ ## ๐Ÿ›ก๏ธ Type Definitions
182
+
183
+ ```ts
184
+ /**
185
+ * A generic event listener callback function.
186
+ * @callback handler
187
+ * @param {...any} payload - Arguments passed when event is emitted.
188
+ * @returns {void}
189
+ */
190
+ ```
191
+
192
+ ---
193
+
194
+ ## โœ… Why Use It?
195
+
196
+ * No dependencies
197
+ * Fully typed (with JSDoc)
198
+ * Inspired by Node.js EventEmitter
199
+ * Works in browser or Node
@@ -0,0 +1,350 @@
1
+ # ๐Ÿ“ฆ TinyLocalStorage
2
+
3
+ Tiny wrapper for `localStorage` with full support for complex structures like `Map`, `Set`, `Date`, `RegExp`, `BigInt`, and even custom types. Offers a type-safe interface and a powerful event system via `TinyEvents`.
4
+
5
+ ---
6
+
7
+ ## ๐Ÿš€ Quick Start
8
+
9
+ ```js
10
+ const storage = new TinyLocalStorage();
11
+
12
+ storage.setString('name', 'Yasmin');
13
+ storage.setNumber('age', 25);
14
+ storage.setBool('likesCats', true);
15
+ storage.setJson('myMap', new Map([['a', 1], ['b', 2]]));
16
+ storage.setDate('today', new Date());
17
+
18
+ console.log(storage.getString('name')); // "Yasmin"
19
+ console.log(storage.getJson('myMap')); // Map { 'a' => 1, 'b' => 2 }
20
+ console.log(storage.getDate('today') instanceof Date); // true
21
+ ```
22
+
23
+ ---
24
+
25
+ ## ๐Ÿง  Features
26
+
27
+ * โœ… Store & restore `Map`, `Set`, `Date`, `RegExp`, `BigInt`, `Symbol`, `null`, `undefined`.
28
+ * โœ… Custom type encoding and decoding system.
29
+ * โœ… Type-safe methods for string, number and boolean.
30
+ * โœ… Built-in event system (`TinyEvents`) with optional native `storage` listener.
31
+ * โœ… Optional fallback when decoding fails.
32
+
33
+ ---
34
+
35
+ ## ๐Ÿ“ฆ Storage Methods
36
+
37
+ ### `setJson(key, data)`
38
+
39
+ Stores any supported JSON-like structure, including `Map`, `Set`, `Date`, `RegExp`, `BigInt`, etc.
40
+
41
+ ```ts
42
+ setJson(name: string, data: LocalStorageJsonValue): void
43
+ ```
44
+
45
+ ### `getJson(key, fallback?)`
46
+
47
+ Retrieves and decodes the previously stored structure. Optional fallback allows recovery on decode failure.
48
+
49
+ ```ts
50
+ getJson(
51
+ name: string,
52
+ defaultData?: 'array' | 'obj' | 'map' | 'set' | 'null'
53
+ ): LocalStorageJsonValue | null
54
+ ```
55
+
56
+ ---
57
+
58
+ ### `setItem(key, rawString)`
59
+
60
+ Stores a raw `string` value as-is.
61
+
62
+ ```ts
63
+ setItem(name: string, data: string): void
64
+ ```
65
+
66
+ ### `getItem(key)`
67
+
68
+ Retrieves a raw `string` value.
69
+
70
+ ```ts
71
+ getItem(name: string): string | null
72
+ ```
73
+
74
+ ---
75
+
76
+ ### `setString(key, string)`
77
+
78
+ Stores a `string` value.
79
+
80
+ ```ts
81
+ setString(name: string, data: string): void
82
+ ```
83
+
84
+ ### `getString(key)`
85
+
86
+ Retrieves a `string` value.
87
+
88
+ ```ts
89
+ getString(name: string): string | null
90
+ ```
91
+
92
+ ---
93
+
94
+ ### `setNumber(key, number)`
95
+
96
+ Stores a `number` value.
97
+
98
+ ```ts
99
+ setNumber(name: string, data: number): void
100
+ ```
101
+
102
+ ### `getNumber(key)`
103
+
104
+ Retrieves a `number` value.
105
+
106
+ ```ts
107
+ getNumber(name: string): number | null
108
+ ```
109
+
110
+ ---
111
+
112
+ ### `setBool(key, boolean)`
113
+
114
+ Stores a `boolean` value.
115
+
116
+ ```ts
117
+ setBool(name: string, data: boolean): void
118
+ ```
119
+
120
+ ### `getBool(key)`
121
+
122
+ Retrieves a `boolean` value.
123
+
124
+ ```ts
125
+ getBool(name: string): boolean | null
126
+ ```
127
+
128
+ ---
129
+
130
+ ### `setDate(key, date)`
131
+
132
+ Stores a `Date` object.
133
+
134
+ ```ts
135
+ setDate(name: string, data: Date): void
136
+ ```
137
+
138
+ ### `getDate(key)`
139
+
140
+ Retrieves a `Date` object.
141
+
142
+ ```ts
143
+ getDate(name: string): Date | null
144
+ ```
145
+
146
+ ---
147
+
148
+ ### `setRegExp(key, pattern)`
149
+
150
+ Stores a `RegExp` object.
151
+
152
+ ```ts
153
+ setRegExp(name: string, data: RegExp): void
154
+ ```
155
+
156
+ ### `getRegExp(key)`
157
+
158
+ Retrieves a `RegExp` object.
159
+
160
+ ```ts
161
+ getRegExp(name: string): RegExp | null
162
+ ```
163
+
164
+ ---
165
+
166
+ ### `setBigInt(key, value)`
167
+
168
+ Stores a `BigInt` value.
169
+
170
+ ```ts
171
+ setBigInt(name: string, data: bigint): void
172
+ ```
173
+
174
+ ### `getBigInt(key)`
175
+
176
+ Retrieves a `BigInt` value.
177
+
178
+ ```ts
179
+ getBigInt(name: string): bigint | null
180
+ ```
181
+
182
+ ---
183
+
184
+ ### `setSymbol(key, value)`
185
+
186
+ Stores a `Symbol`. Only global symbols (`Symbol.for`) will preserve identity.
187
+
188
+ ```ts
189
+ setSymbol(name: string, data: symbol): void
190
+ ```
191
+
192
+ ### `getSymbol(key)`
193
+
194
+ Retrieves a `Symbol` value.
195
+
196
+ ```ts
197
+ getSymbol(name: string): symbol | null
198
+ ```
199
+
200
+ ---
201
+
202
+ ### `getValue(key)`
203
+
204
+ Retrieves any previously stored value, regardless of type.
205
+
206
+ ```ts
207
+ getValue(name: string): any | null
208
+ ```
209
+
210
+ ---
211
+
212
+ ## โŒ Deletion Methods
213
+
214
+ ### `removeItem(key)`
215
+
216
+ Removes a specific key from `localStorage`.
217
+
218
+ ```ts
219
+ removeItem(name: string): void
220
+ ```
221
+
222
+ ### `clearLocalStorage()`
223
+
224
+ Clears all keys in the active storage.
225
+
226
+ ---
227
+
228
+ ## ๐ŸŒ Storage Configuration
229
+
230
+ ### `setLocalStorage(storage)`
231
+
232
+ Switch between `localStorage` and `sessionStorage`.
233
+
234
+ ```ts
235
+ setLocalStorage(storage: Storage): void
236
+ ```
237
+
238
+ ### `localStorageExists()`
239
+
240
+ Returns `true` if the browser supports the configured storage backend.
241
+
242
+ ---
243
+
244
+ ## ๐Ÿงฉ Custom Type Registration
245
+
246
+ ### `registerJsonType(type, encodeFn, decodeFn)`
247
+
248
+ Registers support for custom types with encoder/decoder logic.
249
+
250
+ ```ts
251
+ registerJsonType(
252
+ type: any,
253
+ encodeFn: (value: any, encodeSpecialJson: EncodeFn) => any,
254
+ decodeFn: {
255
+ check: (value: any) => boolean,
256
+ decode: (value: any, decodeSpecialJson: DecodeFn) => any
257
+ }
258
+ ): void
259
+ ```
260
+
261
+ ---
262
+
263
+ ### `deleteJsonType(type)`
264
+
265
+ Unregisters a previously registered custom type.
266
+
267
+ ```ts
268
+ deleteJsonType(type: any): void
269
+ ```
270
+
271
+ Removes the encoder and decoder associated with the given type. Useful for cleanup or reconfiguration.
272
+
273
+ ---
274
+
275
+ ## ๐Ÿ”ฅ Events (via TinyEvents)
276
+
277
+ ### Built-in Events
278
+
279
+ | Event Name | Triggered When... |
280
+ | -------------- | ------------------------------------------- |
281
+ | `'setJson'` | `.setJson()` is called |
282
+ | `'setItem'` | `.setItem()` is called |
283
+ | `'setString'` | `.setString()` is called |
284
+ | `'setNumber'` | `.setNumber()` is called |
285
+ | `'setBool'` | `.setBool()` is called |
286
+ | `'setSymbol'` | `.setSymbol()` is called |
287
+ | `'setBigInt'` | `.setBigInt()` is called |
288
+ | `'setRegExp'` | `.setRegExp()` is called |
289
+ | `'setDate'` | `.setDate()` is called |
290
+ | `'removeItem'` | `.removeItem()` is called |
291
+ | `'storage'` | Browser's native `storage` event (optional) |
292
+
293
+ All events receive `{ key, value }` or `{ key }` depending on context.
294
+
295
+ ---
296
+
297
+ ## ๐Ÿงน Destroying
298
+
299
+ ### `destroy()`
300
+
301
+ Cleans up listeners and internal event systems.
302
+
303
+ ```ts
304
+ destroy(): void
305
+ ```
306
+
307
+ ---
308
+
309
+ ## ๐Ÿงช Type Definition
310
+
311
+ ```ts
312
+ type LocalStorageJsonValue =
313
+ | Record<string | number | symbol, any>
314
+ | any[]
315
+ | Map<string | number | symbol, any>
316
+ | Set<any>;
317
+ ```
318
+
319
+ ---
320
+
321
+ ## ๐Ÿ” Internal Helpers
322
+
323
+ ### `encodeSpecialJson(value)`
324
+
325
+ Recursively encodes supported complex types into serializable JSON-like structures.
326
+
327
+ ### `decodeSpecialJson(value)`
328
+
329
+ Decodes those JSON-like structures back into `Map`, `Set`, `Date`, etc.
330
+
331
+ ---
332
+
333
+ ## ๐Ÿงช Example: Map, Set, Date, RegExp
334
+
335
+ ```js
336
+ const map = new Map([['x', 123]]);
337
+ const set = new Set(['apple', 'banana']);
338
+ const date = new Date();
339
+ const regex = /hello/i;
340
+
341
+ storage.setJson('dataMap', map);
342
+ storage.setJson('dataSet', set);
343
+ storage.setDate('today', date);
344
+ storage.setRegExp('pattern', regex);
345
+
346
+ console.log(storage.getJson('dataMap') instanceof Map); // true
347
+ console.log(storage.getJson('dataSet') instanceof Set); // true
348
+ console.log(storage.getDate('today') instanceof Date); // true
349
+ console.log(storage.getRegExp('pattern') instanceof RegExp); // true
350
+ ```
@@ -303,6 +303,3 @@ if (limiter.isRateLimited("user42")) {
303
303
  | Group-based rate limiting | โœ… |
304
304
  | Activity metrics per group | โœ… |
305
305
 
306
- ---
307
-
308
- Made with ๐Ÿ’œ to protect your app from spammers and abusers โ€” in a cute and efficient way! ๐Ÿ˜„