@byloth/core 2.0.0 → 2.0.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.
@@ -45,10 +45,15 @@ export default class ReducedIterator<K extends PropertyKey, T>
45
45
  /**
46
46
  * Initializes a new instance of the {@link ReducedIterator} class.
47
47
  *
48
+ * ---
49
+ *
50
+ * @example
48
51
  * ```ts
49
52
  * const results = new ReducedIterator<string, number>([["A", 1], ["B", 2], ["C", 4]]);
50
53
  * ```
51
54
  *
55
+ * ---
56
+ *
52
57
  * @param iterable A reduced iterable object.
53
58
  */
54
59
  public constructor(iterable: Iterable<[K, T]>);
@@ -56,6 +61,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
56
61
  /**
57
62
  * Initializes a new instance of the {@link ReducedIterator} class.
58
63
  *
64
+ * ---
65
+ *
66
+ * @example
59
67
  * ```ts
60
68
  * const results = new ReducedIterator<string, number>({
61
69
  * _index: 0,
@@ -69,6 +77,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
69
77
  * });
70
78
  * ```
71
79
  *
80
+ * ---
81
+ *
72
82
  * @param iterator An reduced iterator object.
73
83
  */
74
84
  public constructor(iterator: Iterator<[K, T]>);
@@ -76,6 +86,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
76
86
  /**
77
87
  * Initializes a new instance of the {@link ReducedIterator} class.
78
88
  *
89
+ * ---
90
+ *
91
+ * @example
79
92
  * ```ts
80
93
  * import { range, Random } from "@byloth/core";
81
94
  *
@@ -88,6 +101,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
88
101
  * });
89
102
  * ```
90
103
  *
104
+ * ---
105
+ *
91
106
  * @param generatorFn A generator function that produces the reduced elements.
92
107
  */
93
108
  public constructor(generatorFn: GeneratorFunction<[K, T]>);
@@ -95,10 +110,15 @@ export default class ReducedIterator<K extends PropertyKey, T>
95
110
  /**
96
111
  * Initializes a new instance of the {@link ReducedIterator} class.
97
112
  *
113
+ * ---
114
+ *
115
+ * @example
98
116
  * ```ts
99
117
  * const results = new ReducedIterator(reducedValues);
100
118
  * ```
101
119
  *
120
+ * ---
121
+ *
102
122
  * @param argument An iterable, iterator or generator function that produces the reduced elements.
103
123
  */
104
124
  public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>);
@@ -120,6 +140,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
120
140
  *
121
141
  * If the iterator is infinite and every element satisfies the condition, the method will never return.
122
142
  *
143
+ * ---
144
+ *
145
+ * @example
123
146
  * ```ts
124
147
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
125
148
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -129,6 +152,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
129
152
  * console.log(results); // true
130
153
  * ```
131
154
  *
155
+ * ---
156
+ *
132
157
  * @param predicate The condition to check for each element of the iterator.
133
158
  *
134
159
  * @returns `true` if all elements satisfy the condition, `false` otherwise.
@@ -156,6 +181,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
156
181
  *
157
182
  * If the iterator is infinite and no element satisfies the condition, the method will never return.
158
183
  *
184
+ * ---
185
+ *
186
+ * @example
159
187
  * ```ts
160
188
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
161
189
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -165,6 +193,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
165
193
  * console.log(results); // true
166
194
  * ```
167
195
  *
196
+ * ---
197
+ *
168
198
  * @param predicate The condition to check for each element of the iterator.
169
199
  *
170
200
  * @returns `true` if any element satisfies the condition, `false` otherwise.
@@ -192,6 +222,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
192
222
  * This means that the original iterator won't be consumed until the
193
223
  * new one is and that consuming one of them will consume the other as well.
194
224
  *
225
+ * ---
226
+ *
227
+ * @example
195
228
  * ```ts
196
229
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
197
230
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -201,6 +234,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
201
234
  * console.log(results.toObject()); // { odd: 4, even: 16 }
202
235
  * ```
203
236
  *
237
+ * ---
238
+ *
204
239
  * @param predicate The condition to check for each element of the iterator.
205
240
  *
206
241
  * @returns A new {@link ReducedIterator} containing only the elements that satisfy the condition.
@@ -220,6 +255,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
220
255
  * This means that the original iterator won't be consumed until the
221
256
  * new one is and that consuming one of them will consume the other as well.
222
257
  *
258
+ * ---
259
+ *
260
+ * @example
223
261
  * ```ts
224
262
  * const results = new SmartIterator<number | string>([-3, -1, "0", "2", 3, 5, "6", "8"])
225
263
  * .groupBy((value) => Number(value) % 2 === 0 ? "even" : "odd")
@@ -229,6 +267,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
229
267
  * console.log(results.toObject()); // { odd: 4 }
230
268
  * ```
231
269
  *
270
+ * ---
271
+ *
232
272
  * @template S
233
273
  * The type of the elements that satisfy the condition.
234
274
  * This allows the type-system to infer the correct type of the iterator.
@@ -266,6 +306,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
266
306
  * This means that the original iterator won't be consumed until the
267
307
  * new one is and that consuming one of them will consume the other as well.
268
308
  *
309
+ * ---
310
+ *
311
+ * @example
269
312
  * ```ts
270
313
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
271
314
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -275,6 +318,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
275
318
  * console.log(results.toObject()); // { odd: 8, even: 32 }
276
319
  * ```
277
320
  *
321
+ * ---
322
+ *
278
323
  * @template V The type of the elements after the transformation.
279
324
  *
280
325
  * @param iteratee The transformation function to apply to each element of the iterator.
@@ -308,6 +353,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
308
353
  * - If an empty iterator is provided, a {@link ValueException} will be thrown.
309
354
  * - If the iterator is infinite, the method will never return.
310
355
  *
356
+ * ---
357
+ *
358
+ * @example
311
359
  * ```ts
312
360
  * const result = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
313
361
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -317,6 +365,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
317
365
  * console.log(result); // 20
318
366
  * ```
319
367
  *
368
+ * ---
369
+ *
320
370
  * @param reducer The reducer function to apply to the elements of the iterator.
321
371
  *
322
372
  * @returns The final value after reducing all the elements of the iterator.
@@ -335,6 +385,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
335
385
  *
336
386
  * If the iterator is infinite, the method will never return.
337
387
  *
388
+ * ---
389
+ *
390
+ * @example
338
391
  * ```ts
339
392
  * const result = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
340
393
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -344,6 +397,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
344
397
  * console.log(result); // { value: 20 }
345
398
  * ```
346
399
  *
400
+ * ---
401
+ *
347
402
  * @template A The type of the accumulator value which will also be the type of the final result of the reduction.
348
403
  *
349
404
  * @param reducer The reducer function to apply to the elements of the iterator.
@@ -388,6 +443,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
388
443
  * This means that the original iterator won't be consumed until the
389
444
  * new one is and that consuming one of them will consume the other as well.
390
445
  *
446
+ * ---
447
+ *
448
+ * @example
391
449
  * ```ts
392
450
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
393
451
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -397,6 +455,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
397
455
  * console.log(results.toObject()); // { odd: [-3, -1, 3, 5], even: [0, 2, 6, 8] }
398
456
  * ```
399
457
  *
458
+ * ---
459
+ *
400
460
  * @template V The type of the elements after the transformation.
401
461
  *
402
462
  * @param iteratee The transformation function to apply to each element of the iterator.
@@ -437,6 +497,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
437
497
  * Only the dropped elements will be consumed in the process.
438
498
  * The rest of the iterator will be consumed once the new iterator is.
439
499
  *
500
+ * ---
501
+ *
502
+ * @example
440
503
  * ```ts
441
504
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
442
505
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -478,6 +541,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
478
541
  * Only the taken elements will be consumed from the original reduced iterator.
479
542
  * The rest of the original reduced iterator will be available for further consumption.
480
543
  *
544
+ * ---
545
+ *
546
+ * @example
481
547
  * ```ts
482
548
  * const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
483
549
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -489,11 +555,13 @@ export default class ReducedIterator<K extends PropertyKey, T>
489
555
  * console.log(reduced.toObject()); // { even: [0, 2, 6, 8] }
490
556
  * ```
491
557
  *
492
- * @param count The number of elements to take.
558
+ * ---
559
+ *
560
+ * @param limit The number of elements to take.
493
561
  *
494
562
  * @returns A new {@link ReducedIterator} containing the taken elements.
495
563
  */
496
- public take(count: number): ReducedIterator<K, T>
564
+ public take(limit: number): ReducedIterator<K, T>
497
565
  {
498
566
  const elements = this._elements.enumerate();
499
567
 
@@ -501,7 +569,7 @@ export default class ReducedIterator<K extends PropertyKey, T>
501
569
  {
502
570
  for (const [index, [key, element]] of elements)
503
571
  {
504
- if (index >= count) { break; }
572
+ if (index >= limit) { break; }
505
573
  yield [key, element];
506
574
  }
507
575
  });
@@ -521,6 +589,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
521
589
  * - If no element satisfies the condition, `undefined` will be returned once the entire iterator is consumed.
522
590
  * - If the iterator is infinite and no element satisfies the condition, the method will never return.
523
591
  *
592
+ * ---
593
+ *
594
+ * @example
524
595
  * ```ts
525
596
  * const results = new SmartIterator<number>([-3, -3, -1, 0, 1, 2, 5, 6, 8])
526
597
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -549,6 +620,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
549
620
  * - If no element satisfies the condition, `undefined` will be returned once the entire iterator is consumed.
550
621
  * - If the iterator is infinite and no element satisfies the condition, the method will never return.
551
622
  *
623
+ * ---
624
+ *
625
+ * @example
552
626
  * ```ts
553
627
  * const results = new SmartIterator<number | string>(["-3", -3, "-1", 0, 1, 2, "5", 6, 8])
554
628
  * .groupBy((value) => Number(value) % 2 === 0 ? "even" : "odd")
@@ -589,6 +663,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
589
663
  * This means that the original iterator won't be consumed until the
590
664
  * new one is and that consuming one of them will consume the other as well.
591
665
  *
666
+ * ---
667
+ *
668
+ * @example
592
669
  * ```ts
593
670
  * const results = new ReducedIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
594
671
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -598,6 +675,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
598
675
  * console.log(results.toObject()); // [[0, 4], [1, 16]]
599
676
  * ```
600
677
  *
678
+ * ---
679
+ *
601
680
  * @returns A new {@link ReducedIterator} object containing the enumerated elements.
602
681
  */
603
682
  public enumerate(): ReducedIterator<K, [number, T]>
@@ -616,6 +695,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
616
695
  * This means that the original iterator won't be consumed until the
617
696
  * new one is and that consuming one of them will consume the other as well.
618
697
  *
698
+ * ---
699
+ *
700
+ * @example
619
701
  * ```ts
620
702
  * const results = new ReducedIterator<number>([-3, -1, 0, 2, 3, 6, -3, -1, 1, 5, 6, 8, 7, 2])
621
703
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -650,6 +732,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
650
732
  *
651
733
  * If the iterator is infinite, the method will never return.
652
734
  *
735
+ * ---
736
+ *
737
+ * @example
653
738
  * ```ts
654
739
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
655
740
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -659,6 +744,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
659
744
  * console.log(results); // 2
660
745
  * ```
661
746
  *
747
+ * ---
748
+ *
662
749
  * @returns The number of elements in the iterator.
663
750
  */
664
751
  public count(): number
@@ -677,6 +764,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
677
764
  * This method will consume the entire iterator in the process.
678
765
  * If the iterator is infinite, the method will never return.
679
766
  *
767
+ * ---
768
+ *
769
+ * @example
680
770
  * ```ts
681
771
  * const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
682
772
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -688,6 +778,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
688
778
  * });
689
779
  * ```
690
780
  *
781
+ * ---
782
+ *
691
783
  * @param iteratee The function to apply to each element of the reduced iterator.
692
784
  */
693
785
  public forEach(iteratee: KeyedIteratee<K, T>): void
@@ -709,6 +801,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
709
801
  * This means that the original iterator won't be consumed until the
710
802
  * new one is and that consuming one of them will consume the other as well.
711
803
  *
804
+ * ---
805
+ *
806
+ * @example
712
807
  * ```ts
713
808
  * const results = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, -6, -8])
714
809
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -718,6 +813,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
718
813
  * console.log(results.toObject()); // { positive: 4, negative: -12 }
719
814
  * ```
720
815
  *
816
+ * ---
817
+ *
721
818
  * @template J The type of the new keys used to group the elements.
722
819
  *
723
820
  * @param iteratee The function to determine the new key of each element of the iterator.
@@ -748,6 +845,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
748
845
  * This means that the original iterator won't be consumed until the
749
846
  * new one is and that consuming one of them will consume the other as well.
750
847
  *
848
+ * ---
849
+ *
850
+ * @example
751
851
  * ```ts
752
852
  * const keys = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
753
853
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -757,6 +857,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
757
857
  * console.log(keys.toArray()); // ["odd", "even"]
758
858
  * ```
759
859
  *
860
+ * ---
861
+ *
760
862
  * @returns A new {@link SmartIterator} containing all the keys of the iterator.
761
863
  */
762
864
  public keys(): SmartIterator<K>
@@ -784,6 +886,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
784
886
  * This means that the original iterator won't be consumed until the
785
887
  * new one is and that consuming one of them will consume the other as well.
786
888
  *
889
+ * ---
890
+ *
891
+ * @example
787
892
  * ```ts
788
893
  * const entries = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
789
894
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -793,6 +898,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
793
898
  * console.log(entries.toArray()); // [["odd", 4], ["even", 16]]
794
899
  * ```
795
900
  *
901
+ * ---
902
+ *
796
903
  * @returns A new {@link SmartIterator} containing all the entries of the iterator.
797
904
  */
798
905
  public entries(): SmartIterator<[K, T]>
@@ -811,6 +918,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
811
918
  * This means that the original iterator won't be consumed until the
812
919
  * new one is and that consuming one of them will consume the other as well.
813
920
  *
921
+ * ---
922
+ *
923
+ * @example
814
924
  * ```ts
815
925
  * const values = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
816
926
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -820,6 +930,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
820
930
  * console.log(values.toArray()); // [4, 16]
821
931
  * ```
822
932
  *
933
+ * ---
934
+ *
823
935
  * @returns A new {@link SmartIterator} containing all the values of the iterator.
824
936
  */
825
937
  public values(): SmartIterator<T>
@@ -841,6 +953,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
841
953
  *
842
954
  * If the iterator is infinite, the method will never return.
843
955
  *
956
+ * ---
957
+ *
958
+ * @example
844
959
  * ```ts
845
960
  * const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
846
961
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -849,6 +964,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
849
964
  * console.log(reduced.toArray()); // [4, 16]
850
965
  * ```
851
966
  *
967
+ * ---
968
+ *
852
969
  * @returns The {@link Array} containing all elements of the iterator.
853
970
  */
854
971
  public toArray(): T[]
@@ -862,6 +979,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
862
979
  *
863
980
  * If the iterator is infinite, the method will never return.
864
981
  *
982
+ * ---
983
+ *
984
+ * @example
865
985
  * ```ts
866
986
  * const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
867
987
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -870,6 +990,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
870
990
  * console.log(reduced.toMap()); // Map(2) { "odd" => 4, "even" => 16 }
871
991
  * ```
872
992
  *
993
+ * ---
994
+ *
873
995
  * @returns The {@link Map} containing all elements of the iterator.
874
996
  */
875
997
  public toMap(): Map<K, T>
@@ -883,6 +1005,9 @@ export default class ReducedIterator<K extends PropertyKey, T>
883
1005
  *
884
1006
  * If the iterator is infinite, the method will never return.
885
1007
  *
1008
+ * ---
1009
+ *
1010
+ * @example
886
1011
  * ```ts
887
1012
  * const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
888
1013
  * .groupBy((value) => value % 2 === 0 ? "even" : "odd")
@@ -891,6 +1016,8 @@ export default class ReducedIterator<K extends PropertyKey, T>
891
1016
  * console.log(reduced.toObject()); // { odd: 4, even: 16 }
892
1017
  * ```
893
1018
  *
1019
+ * ---
1020
+ *
894
1021
  * @returns The {@link Object} containing all elements of the iterator.
895
1022
  */
896
1023
  public toObject(): Record<K, T>
@@ -49,6 +49,9 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
49
49
  /**
50
50
  * Initializes a new instance of the {@link Publisher} class.
51
51
  *
52
+ * ---
53
+ *
54
+ * @example
52
55
  * ```ts
53
56
  * const publisher = new Publisher();
54
57
  * ```
@@ -61,6 +64,9 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
61
64
  /**
62
65
  * Unsubscribes all the subscribers from all the events.
63
66
  *
67
+ * ---
68
+ *
69
+ * @example
64
70
  * ```ts
65
71
  * publisher.subscribe("player:spawn", (evt) => { [...] });
66
72
  * publisher.subscribe("player:move", (coords) => { [...] });
@@ -83,6 +89,9 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
83
89
  /**
84
90
  * Publishes an event to all the subscribers.
85
91
  *
92
+ * ---
93
+ *
94
+ * @example
86
95
  * ```ts
87
96
  * publisher.subscribe("player:move", (coords) => { [...] });
88
97
  * publisher.subscribe("player:move", ({ x, y }) => { [...] });
@@ -91,6 +100,8 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
91
100
  * publisher.publish("player:move", { x: 10, y: 20 });
92
101
  * ```
93
102
  *
103
+ * ---
104
+ *
94
105
  * @template K The key of the map containing the callback signature to publish.
95
106
  *
96
107
  * @param event The name of the event to publish.
@@ -110,6 +121,9 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
110
121
  /**
111
122
  * Subscribes a new subscriber to an event.
112
123
  *
124
+ * ---
125
+ *
126
+ * @example
113
127
  * ```ts
114
128
  * let unsubscribe: () => void;
115
129
  * publisher.subscribe("player:death", unsubscribe);
@@ -119,6 +133,8 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
119
133
  * });
120
134
  * ```
121
135
  *
136
+ * ---
137
+ *
122
138
  * @template K The key of the map containing the callback signature to subscribe.
123
139
  *
124
140
  * @param event The name of the event to subscribe to.
@@ -149,6 +165,9 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
149
165
  /**
150
166
  * Unsubscribes a subscriber from an event.
151
167
  *
168
+ * ---
169
+ *
170
+ * @example
152
171
  * ```ts
153
172
  * const onPlayerMove = ({ x, y }: Point) => { [...] };
154
173
  *
@@ -156,6 +175,8 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
156
175
  * publisher.subscribe("player:death", () => publisher.unsubscribe("player:move", onPlayerMove));
157
176
  * ```
158
177
  *
178
+ * ---
179
+ *
159
180
  * @template K The key of the map containing the callback signature to unsubscribe.
160
181
  *
161
182
  * @param event The name of the event to unsubscribe from.