tiny-essentials 1.21.8 → 1.21.10

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.
@@ -377,17 +377,89 @@ const defaultTemplates = [
377
377
  */
378
378
  class UltraRandomMsgGen {
379
379
  /** @type {string[]} */
380
- static defaultWords = defaultWords;
380
+ static #defaultWords = defaultWords;
381
381
  /** @type {string[]} */
382
- static defaultEmojis = defaultEmojis;
382
+ static #defaultEmojis = defaultEmojis;
383
383
  /** @type {string[]} */
384
- static defaultNouns = defaultNouns;
384
+ static #defaultNouns = defaultNouns;
385
385
  /** @type {string[]} */
386
- static defaultVerbs = defaultVerbs;
386
+ static #defaultVerbs = defaultVerbs;
387
387
  /** @type {string[]} */
388
- static defaultAdjectives = defaultAdjectives;
388
+ static #defaultAdjectives = defaultAdjectives;
389
389
  /** @type {string[]} */
390
- static defaultTemplates = defaultTemplates;
390
+ static #defaultTemplates = defaultTemplates;
391
+
392
+ /**
393
+ * Utility to validate arrays before setting.
394
+ * @param {any} value
395
+ * @param {string} field
396
+ */
397
+ static #validateArray(value, field) {
398
+ if (!Array.isArray(value)) throw new TypeError(`${field} must be an array of strings`);
399
+ if (!value.every((v) => typeof v === 'string'))
400
+ throw new TypeError(`${field} must contain only strings`);
401
+ if (value.length === 0) throw new Error(`${field} cannot be empty`);
402
+ }
403
+
404
+ /** @returns {string[]} */
405
+ static get defaultWords() {
406
+ return [...this.#defaultWords];
407
+ }
408
+ /** @param {string[]} value */
409
+ static set defaultWords(value) {
410
+ this.#validateArray(value, 'defaultWords');
411
+ this.#defaultWords = [...value];
412
+ }
413
+
414
+ /** @returns {string[]} */
415
+ static get defaultEmojis() {
416
+ return [...this.#defaultEmojis];
417
+ }
418
+ /** @param {string[]} value */
419
+ static set defaultEmojis(value) {
420
+ this.#validateArray(value, 'defaultEmojis');
421
+ this.#defaultEmojis = [...value];
422
+ }
423
+
424
+ /** @returns {string[]} */
425
+ static get defaultNouns() {
426
+ return [...this.#defaultNouns];
427
+ }
428
+ /** @param {string[]} value */
429
+ static set defaultNouns(value) {
430
+ this.#validateArray(value, 'defaultNouns');
431
+ this.#defaultNouns = [...value];
432
+ }
433
+
434
+ /** @returns {string[]} */
435
+ static get defaultVerbs() {
436
+ return [...this.#defaultVerbs];
437
+ }
438
+ /** @param {string[]} value */
439
+ static set defaultVerbs(value) {
440
+ this.#validateArray(value, 'defaultVerbs');
441
+ this.#defaultVerbs = [...value];
442
+ }
443
+
444
+ /** @returns {string[]} */
445
+ static get defaultAdjectives() {
446
+ return [...this.#defaultAdjectives];
447
+ }
448
+ /** @param {string[]} value */
449
+ static set defaultAdjectives(value) {
450
+ this.#validateArray(value, 'defaultAdjectives');
451
+ this.#defaultAdjectives = [...value];
452
+ }
453
+
454
+ /** @returns {string[]} */
455
+ static get defaultTemplates() {
456
+ return [...this.#defaultTemplates];
457
+ }
458
+ /** @param {string[]} value */
459
+ static set defaultTemplates(value) {
460
+ this.#validateArray(value, 'defaultTemplates');
461
+ this.#defaultTemplates = [...value];
462
+ }
391
463
 
392
464
  /** @type {MsgGenConfig} */
393
465
  config = {
@@ -576,20 +648,20 @@ class UltraRandomMsgGen {
576
648
  }
577
649
  }
578
650
 
579
- this.config.emojiSet = [...defaultEmojis];
580
- this.config.wordSet = [...defaultWords];
651
+ this.config.emojiSet = [...UltraRandomMsgGen.#defaultEmojis];
652
+ this.config.wordSet = [...UltraRandomMsgGen.#defaultWords];
581
653
 
582
- this.config.grammar.templates = [...defaultTemplates];
583
- this.config.grammar.nouns = [...defaultNouns];
584
- this.config.grammar.verbs = [...defaultVerbs];
585
- this.config.grammar.adjectives = [...defaultAdjectives];
654
+ this.config.grammar.templates = [...UltraRandomMsgGen.#defaultTemplates];
655
+ this.config.grammar.nouns = [...UltraRandomMsgGen.#defaultNouns];
656
+ this.config.grammar.verbs = [...UltraRandomMsgGen.#defaultVerbs];
657
+ this.config.grammar.adjectives = [...UltraRandomMsgGen.#defaultAdjectives];
586
658
  Object.assign(this.config, config);
587
659
  }
588
660
 
589
661
  /**
590
662
  * Merges new configuration values into the current instance.
591
663
  * @param {Object} newConfig - Object with one or more configuration overrides.
592
- * @returns {UltraRandomMsgGen} - The instance for chaining.
664
+ * @returns {this} - The instance for chaining.
593
665
  */
594
666
  configure(newConfig = {}) {
595
667
  Object.assign(this.config, newConfig);
@@ -599,7 +671,7 @@ class UltraRandomMsgGen {
599
671
  /**
600
672
  * Replaces the entire list of grammar templates.
601
673
  * @param {...string[]} templates - One or more arrays or strings containing sentence templates.
602
- * @returns {UltraRandomMsgGen} - The instance for chaining.
674
+ * @returns {this} - The instance for chaining.
603
675
  */
604
676
  setGrammarTemplates(...templates) {
605
677
  this.config.grammar.templates = templates.flat();
@@ -609,7 +681,7 @@ class UltraRandomMsgGen {
609
681
  /**
610
682
  * Adds new grammar templates to the existing list.
611
683
  * @param {...string[]} templates - One or more arrays or strings containing sentence templates.
612
- * @returns {UltraRandomMsgGen} - The instance for chaining.
684
+ * @returns {this} - The instance for chaining.
613
685
  */
614
686
  addGrammarTemplates(...templates) {
615
687
  this.config.grammar.templates.push(...templates.flat());
@@ -619,7 +691,7 @@ class UltraRandomMsgGen {
619
691
  /**
620
692
  * Replaces the list of noun words used in grammar templates.
621
693
  * @param {...string[]} nouns - One or more arrays or strings of nouns.
622
- * @returns {UltraRandomMsgGen} - The instance for chaining.
694
+ * @returns {this} - The instance for chaining.
623
695
  */
624
696
  setGrammarNouns(...nouns) {
625
697
  this.config.grammar.nouns = nouns.flat();
@@ -629,7 +701,7 @@ class UltraRandomMsgGen {
629
701
  /**
630
702
  * Adds noun words to the existing list used in grammar templates.
631
703
  * @param {...string[]} nouns - One or more arrays or strings of nouns.
632
- * @returns {UltraRandomMsgGen} - The instance for chaining.
704
+ * @returns {this} - The instance for chaining.
633
705
  */
634
706
  addGrammarNouns(...nouns) {
635
707
  this.config.grammar.nouns.push(...nouns.flat());
@@ -639,7 +711,7 @@ class UltraRandomMsgGen {
639
711
  /**
640
712
  * Replaces the list of verb words used in grammar templates.
641
713
  * @param {...string[]} verbs - One or more arrays or strings of verbs.
642
- * @returns {UltraRandomMsgGen} - The instance for chaining.
714
+ * @returns {this} - The instance for chaining.
643
715
  */
644
716
  setGrammarVerbs(...verbs) {
645
717
  this.config.grammar.verbs = verbs.flat();
@@ -649,7 +721,7 @@ class UltraRandomMsgGen {
649
721
  /**
650
722
  * Adds verb words to the existing list used in grammar templates.
651
723
  * @param {...string[]} verbs - One or more arrays or strings of verbs.
652
- * @returns {UltraRandomMsgGen} - The instance for chaining.
724
+ * @returns {this} - The instance for chaining.
653
725
  */
654
726
  addGrammarVerbs(...verbs) {
655
727
  this.config.grammar.verbs.push(...verbs.flat());
@@ -659,7 +731,7 @@ class UltraRandomMsgGen {
659
731
  /**
660
732
  * Replaces the list of adjective words used in grammar templates.
661
733
  * @param {...string[]} adjectives - One or more arrays or strings of adjectives.
662
- * @returns {UltraRandomMsgGen} - The instance for chaining.
734
+ * @returns {this} - The instance for chaining.
663
735
  */
664
736
  setGrammarAdjectives(...adjectives) {
665
737
  this.config.grammar.adjectives = adjectives.flat();
@@ -669,7 +741,7 @@ class UltraRandomMsgGen {
669
741
  /**
670
742
  * Adds adjective words to the existing list used in grammar templates.
671
743
  * @param {...string[]} adjectives - One or more arrays or strings of adjectives.
672
- * @returns {UltraRandomMsgGen} - The instance for chaining.
744
+ * @returns {this} - The instance for chaining.
673
745
  */
674
746
  addGrammarAdjectives(...adjectives) {
675
747
  this.config.grammar.adjectives.push(...adjectives.flat());
@@ -679,7 +751,7 @@ class UltraRandomMsgGen {
679
751
  /**
680
752
  * Removes specific grammar templates from the current list.
681
753
  * @param {...string[]} templates - One or more arrays or strings of templates to remove.
682
- * @returns {UltraRandomMsgGen} - The instance for chaining.
754
+ * @returns {this} - The instance for chaining.
683
755
  */
684
756
  removeGrammarTemplates(...templates) {
685
757
  const removeSet = new Set(templates.flat());
@@ -690,7 +762,7 @@ class UltraRandomMsgGen {
690
762
  /**
691
763
  * Removes specific noun words from the grammar noun list.
692
764
  * @param {...string[]} nouns - One or more arrays or strings of nouns to remove.
693
- * @returns {UltraRandomMsgGen} - The instance for chaining.
765
+ * @returns {this} - The instance for chaining.
694
766
  */
695
767
  removeGrammarNouns(...nouns) {
696
768
  const removeSet = new Set(nouns.flat());
@@ -701,7 +773,7 @@ class UltraRandomMsgGen {
701
773
  /**
702
774
  * Removes specific verb words from the grammar verb list.
703
775
  * @param {...string[]} verbs - One or more arrays or strings of verbs to remove.
704
- * @returns {UltraRandomMsgGen} - The instance for chaining.
776
+ * @returns {this} - The instance for chaining.
705
777
  */
706
778
  removeGrammarVerbs(...verbs) {
707
779
  const removeSet = new Set(verbs.flat());
@@ -712,7 +784,7 @@ class UltraRandomMsgGen {
712
784
  /**
713
785
  * Removes specific adjective words from the grammar adjective list.
714
786
  * @param {...string[]} adjectives - One or more arrays or strings of adjectives to remove.
715
- * @returns {UltraRandomMsgGen} - The instance for chaining.
787
+ * @returns {this} - The instance for chaining.
716
788
  */
717
789
  removeGrammarAdjectives(...adjectives) {
718
790
  const removeSet = new Set(adjectives.flat());
@@ -725,7 +797,7 @@ class UltraRandomMsgGen {
725
797
  /**
726
798
  * Replaces the entire word set used in readable/mixed modes.
727
799
  * @param {...string[]} words - One or more arrays or strings of words.
728
- * @returns {UltraRandomMsgGen} - The instance for chaining.
800
+ * @returns {this} - The instance for chaining.
729
801
  */
730
802
  setWords(...words) {
731
803
  this.config.wordSet = words.flat();
@@ -735,7 +807,7 @@ class UltraRandomMsgGen {
735
807
  /**
736
808
  * Adds new words to the word set used in readable/mixed modes.
737
809
  * @param {...string[]} words - One or more arrays or strings of words.
738
- * @returns {UltraRandomMsgGen} - The instance for chaining.
810
+ * @returns {this} - The instance for chaining.
739
811
  */
740
812
  addWords(...words) {
741
813
  this.config.wordSet.push(...words.flat());
@@ -745,7 +817,7 @@ class UltraRandomMsgGen {
745
817
  /**
746
818
  * Removes specific words from the word set.
747
819
  * @param {...string[]} words - Words to be removed.
748
- * @returns {UltraRandomMsgGen} - The instance for chaining.
820
+ * @returns {this} - The instance for chaining.
749
821
  */
750
822
  removeWords(...words) {
751
823
  const removeSet = new Set(words.flat());
@@ -756,7 +828,7 @@ class UltraRandomMsgGen {
756
828
  /**
757
829
  * Replaces the emoji set used in generated output.
758
830
  * @param {...string[]} emojis - One or more arrays or strings of emojis.
759
- * @returns {UltraRandomMsgGen} - The instance for chaining.
831
+ * @returns {this} - The instance for chaining.
760
832
  */
761
833
  setEmojis(...emojis) {
762
834
  this.config.emojiSet = emojis.flat();
@@ -766,7 +838,7 @@ class UltraRandomMsgGen {
766
838
  /**
767
839
  * Adds new emojis to the emoji set.
768
840
  * @param {...string[]} emojis - One or more arrays or strings of emojis.
769
- * @returns {UltraRandomMsgGen} - The instance for chaining.
841
+ * @returns {this} - The instance for chaining.
770
842
  */
771
843
  addEmojis(...emojis) {
772
844
  this.config.emojiSet.push(...emojis.flat());
@@ -776,7 +848,7 @@ class UltraRandomMsgGen {
776
848
  /**
777
849
  * Removes specific emojis from the emoji set.
778
850
  * @param {...string[]} emojis - Emojis to be removed.
779
- * @returns {UltraRandomMsgGen} - The instance for chaining.
851
+ * @returns {this} - The instance for chaining.
780
852
  */
781
853
  removeEmojis(...emojis) {
782
854
  const removeSet = new Set(emojis.flat());
@@ -160,17 +160,47 @@ export type MsgGenConfig = {
160
160
  */
161
161
  declare class UltraRandomMsgGen {
162
162
  /** @type {string[]} */
163
- static defaultWords: string[];
163
+ static "__#12@#defaultWords": string[];
164
164
  /** @type {string[]} */
165
- static defaultEmojis: string[];
165
+ static "__#12@#defaultEmojis": string[];
166
166
  /** @type {string[]} */
167
- static defaultNouns: string[];
167
+ static "__#12@#defaultNouns": string[];
168
168
  /** @type {string[]} */
169
- static defaultVerbs: string[];
169
+ static "__#12@#defaultVerbs": string[];
170
170
  /** @type {string[]} */
171
- static defaultAdjectives: string[];
171
+ static "__#12@#defaultAdjectives": string[];
172
172
  /** @type {string[]} */
173
- static defaultTemplates: string[];
173
+ static "__#12@#defaultTemplates": string[];
174
+ /**
175
+ * Utility to validate arrays before setting.
176
+ * @param {any} value
177
+ * @param {string} field
178
+ */
179
+ static "__#12@#validateArray"(value: any, field: string): void;
180
+ /** @param {string[]} value */
181
+ static set defaultWords(value: string[]);
182
+ /** @returns {string[]} */
183
+ static get defaultWords(): string[];
184
+ /** @param {string[]} value */
185
+ static set defaultEmojis(value: string[]);
186
+ /** @returns {string[]} */
187
+ static get defaultEmojis(): string[];
188
+ /** @param {string[]} value */
189
+ static set defaultNouns(value: string[]);
190
+ /** @returns {string[]} */
191
+ static get defaultNouns(): string[];
192
+ /** @param {string[]} value */
193
+ static set defaultVerbs(value: string[]);
194
+ /** @returns {string[]} */
195
+ static get defaultVerbs(): string[];
196
+ /** @param {string[]} value */
197
+ static set defaultAdjectives(value: string[]);
198
+ /** @returns {string[]} */
199
+ static get defaultAdjectives(): string[];
200
+ /** @param {string[]} value */
201
+ static set defaultTemplates(value: string[]);
202
+ /** @returns {string[]} */
203
+ static get defaultTemplates(): string[];
174
204
  /**
175
205
  * Creates an instance of UltraRandomMsgGen.
176
206
  *
@@ -235,117 +265,117 @@ declare class UltraRandomMsgGen {
235
265
  /**
236
266
  * Merges new configuration values into the current instance.
237
267
  * @param {Object} newConfig - Object with one or more configuration overrides.
238
- * @returns {UltraRandomMsgGen} - The instance for chaining.
268
+ * @returns {this} - The instance for chaining.
239
269
  */
240
- configure(newConfig?: Object): UltraRandomMsgGen;
270
+ configure(newConfig?: Object): this;
241
271
  /**
242
272
  * Replaces the entire list of grammar templates.
243
273
  * @param {...string[]} templates - One or more arrays or strings containing sentence templates.
244
- * @returns {UltraRandomMsgGen} - The instance for chaining.
274
+ * @returns {this} - The instance for chaining.
245
275
  */
246
- setGrammarTemplates(...templates: string[][]): UltraRandomMsgGen;
276
+ setGrammarTemplates(...templates: string[][]): this;
247
277
  /**
248
278
  * Adds new grammar templates to the existing list.
249
279
  * @param {...string[]} templates - One or more arrays or strings containing sentence templates.
250
- * @returns {UltraRandomMsgGen} - The instance for chaining.
280
+ * @returns {this} - The instance for chaining.
251
281
  */
252
- addGrammarTemplates(...templates: string[][]): UltraRandomMsgGen;
282
+ addGrammarTemplates(...templates: string[][]): this;
253
283
  /**
254
284
  * Replaces the list of noun words used in grammar templates.
255
285
  * @param {...string[]} nouns - One or more arrays or strings of nouns.
256
- * @returns {UltraRandomMsgGen} - The instance for chaining.
286
+ * @returns {this} - The instance for chaining.
257
287
  */
258
- setGrammarNouns(...nouns: string[][]): UltraRandomMsgGen;
288
+ setGrammarNouns(...nouns: string[][]): this;
259
289
  /**
260
290
  * Adds noun words to the existing list used in grammar templates.
261
291
  * @param {...string[]} nouns - One or more arrays or strings of nouns.
262
- * @returns {UltraRandomMsgGen} - The instance for chaining.
292
+ * @returns {this} - The instance for chaining.
263
293
  */
264
- addGrammarNouns(...nouns: string[][]): UltraRandomMsgGen;
294
+ addGrammarNouns(...nouns: string[][]): this;
265
295
  /**
266
296
  * Replaces the list of verb words used in grammar templates.
267
297
  * @param {...string[]} verbs - One or more arrays or strings of verbs.
268
- * @returns {UltraRandomMsgGen} - The instance for chaining.
298
+ * @returns {this} - The instance for chaining.
269
299
  */
270
- setGrammarVerbs(...verbs: string[][]): UltraRandomMsgGen;
300
+ setGrammarVerbs(...verbs: string[][]): this;
271
301
  /**
272
302
  * Adds verb words to the existing list used in grammar templates.
273
303
  * @param {...string[]} verbs - One or more arrays or strings of verbs.
274
- * @returns {UltraRandomMsgGen} - The instance for chaining.
304
+ * @returns {this} - The instance for chaining.
275
305
  */
276
- addGrammarVerbs(...verbs: string[][]): UltraRandomMsgGen;
306
+ addGrammarVerbs(...verbs: string[][]): this;
277
307
  /**
278
308
  * Replaces the list of adjective words used in grammar templates.
279
309
  * @param {...string[]} adjectives - One or more arrays or strings of adjectives.
280
- * @returns {UltraRandomMsgGen} - The instance for chaining.
310
+ * @returns {this} - The instance for chaining.
281
311
  */
282
- setGrammarAdjectives(...adjectives: string[][]): UltraRandomMsgGen;
312
+ setGrammarAdjectives(...adjectives: string[][]): this;
283
313
  /**
284
314
  * Adds adjective words to the existing list used in grammar templates.
285
315
  * @param {...string[]} adjectives - One or more arrays or strings of adjectives.
286
- * @returns {UltraRandomMsgGen} - The instance for chaining.
316
+ * @returns {this} - The instance for chaining.
287
317
  */
288
- addGrammarAdjectives(...adjectives: string[][]): UltraRandomMsgGen;
318
+ addGrammarAdjectives(...adjectives: string[][]): this;
289
319
  /**
290
320
  * Removes specific grammar templates from the current list.
291
321
  * @param {...string[]} templates - One or more arrays or strings of templates to remove.
292
- * @returns {UltraRandomMsgGen} - The instance for chaining.
322
+ * @returns {this} - The instance for chaining.
293
323
  */
294
- removeGrammarTemplates(...templates: string[][]): UltraRandomMsgGen;
324
+ removeGrammarTemplates(...templates: string[][]): this;
295
325
  /**
296
326
  * Removes specific noun words from the grammar noun list.
297
327
  * @param {...string[]} nouns - One or more arrays or strings of nouns to remove.
298
- * @returns {UltraRandomMsgGen} - The instance for chaining.
328
+ * @returns {this} - The instance for chaining.
299
329
  */
300
- removeGrammarNouns(...nouns: string[][]): UltraRandomMsgGen;
330
+ removeGrammarNouns(...nouns: string[][]): this;
301
331
  /**
302
332
  * Removes specific verb words from the grammar verb list.
303
333
  * @param {...string[]} verbs - One or more arrays or strings of verbs to remove.
304
- * @returns {UltraRandomMsgGen} - The instance for chaining.
334
+ * @returns {this} - The instance for chaining.
305
335
  */
306
- removeGrammarVerbs(...verbs: string[][]): UltraRandomMsgGen;
336
+ removeGrammarVerbs(...verbs: string[][]): this;
307
337
  /**
308
338
  * Removes specific adjective words from the grammar adjective list.
309
339
  * @param {...string[]} adjectives - One or more arrays or strings of adjectives to remove.
310
- * @returns {UltraRandomMsgGen} - The instance for chaining.
340
+ * @returns {this} - The instance for chaining.
311
341
  */
312
- removeGrammarAdjectives(...adjectives: string[][]): UltraRandomMsgGen;
342
+ removeGrammarAdjectives(...adjectives: string[][]): this;
313
343
  /**
314
344
  * Replaces the entire word set used in readable/mixed modes.
315
345
  * @param {...string[]} words - One or more arrays or strings of words.
316
- * @returns {UltraRandomMsgGen} - The instance for chaining.
346
+ * @returns {this} - The instance for chaining.
317
347
  */
318
- setWords(...words: string[][]): UltraRandomMsgGen;
348
+ setWords(...words: string[][]): this;
319
349
  /**
320
350
  * Adds new words to the word set used in readable/mixed modes.
321
351
  * @param {...string[]} words - One or more arrays or strings of words.
322
- * @returns {UltraRandomMsgGen} - The instance for chaining.
352
+ * @returns {this} - The instance for chaining.
323
353
  */
324
- addWords(...words: string[][]): UltraRandomMsgGen;
354
+ addWords(...words: string[][]): this;
325
355
  /**
326
356
  * Removes specific words from the word set.
327
357
  * @param {...string[]} words - Words to be removed.
328
- * @returns {UltraRandomMsgGen} - The instance for chaining.
358
+ * @returns {this} - The instance for chaining.
329
359
  */
330
- removeWords(...words: string[][]): UltraRandomMsgGen;
360
+ removeWords(...words: string[][]): this;
331
361
  /**
332
362
  * Replaces the emoji set used in generated output.
333
363
  * @param {...string[]} emojis - One or more arrays or strings of emojis.
334
- * @returns {UltraRandomMsgGen} - The instance for chaining.
364
+ * @returns {this} - The instance for chaining.
335
365
  */
336
- setEmojis(...emojis: string[][]): UltraRandomMsgGen;
366
+ setEmojis(...emojis: string[][]): this;
337
367
  /**
338
368
  * Adds new emojis to the emoji set.
339
369
  * @param {...string[]} emojis - One or more arrays or strings of emojis.
340
- * @returns {UltraRandomMsgGen} - The instance for chaining.
370
+ * @returns {this} - The instance for chaining.
341
371
  */
342
- addEmojis(...emojis: string[][]): UltraRandomMsgGen;
372
+ addEmojis(...emojis: string[][]): this;
343
373
  /**
344
374
  * Removes specific emojis from the emoji set.
345
375
  * @param {...string[]} emojis - Emojis to be removed.
346
- * @returns {UltraRandomMsgGen} - The instance for chaining.
376
+ * @returns {this} - The instance for chaining.
347
377
  */
348
- removeEmojis(...emojis: string[][]): UltraRandomMsgGen;
378
+ removeEmojis(...emojis: string[][]): this;
349
379
  /**
350
380
  * Returns a random item from an array.
351
381
  * @private