@tspro/ts-utils-lib 1.18.0 → 1.19.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.19.1] - 2025-10-27
4
+ ## Fixed
5
+ - Forgot to export `DefaultArray`, `SetBase`, `Set1` and `DeepSet`.
6
+
7
+ ## [1.19.0] - 2025-10-27
8
+ ### Added
9
+ - SignedIndexArray.toArray(), IndexArray.toArray(), IndexArray.length;
10
+ - Set1 and DeepSet.
11
+ - DefaultArray.
12
+ - Stack functions.
13
+
3
14
  ## [1.18.0] - 2025-10-24
4
15
  ### Changed
5
16
  - Deprecated `DivRect` properties `centerX` and `centerY`, replaced with `anchorX` and `anchorY`.
package/dist/index.d.mts CHANGED
@@ -143,15 +143,60 @@ declare namespace index$7 {
143
143
  export { type index$7_ErrorConstructor as ErrorConstructor, index$7_array_elem as array_elem, index$7_array_id as array_id, index$7_assert as assert, index$7_assertEnum as assertEnum, index$7_eq as eq, index$7_even as even, index$7_fail as fail, index$7_finite as finite, index$7_in_group as in_group, index$7_int as int, index$7_int_between as int_between, index$7_int_between_exclusive as int_between_exclusive, index$7_int_eq as int_eq, index$7_int_gt as int_gt, index$7_int_gte as int_gte, index$7_int_lt as int_lt, index$7_int_lte as int_lte, index$7_interrupt as interrupt, isArray$1 as isArray, isArrayIndex$1 as isArrayIndex, isArrayOrUndefined$1 as isArrayOrUndefined, isBoolean$1 as isBoolean, isBooleanOrUndefined$1 as isBooleanOrUndefined, isDeepEqual$1 as isDeepEqual, isEmptyArray$1 as isEmptyArray, isEmptyArrayOrUndefined$1 as isEmptyArrayOrUndefined, isEmptyString$1 as isEmptyString, isEmptyStringOrUndefined$1 as isEmptyStringOrUndefined, isEnumValue$1 as isEnumValue, isEnumValueOrUndefined$1 as isEnumValueOrUndefined, isEqual$1 as isEqual, isEvenNumber$1 as isEvenNumber, isFalse$1 as isFalse, isFalseOrUndefined$1 as isFalseOrUndefined, isFinite$1 as isFinite, isFunction$1 as isFunction, isFunctionOrUndefined$1 as isFunctionOrUndefined, isIncluded$1 as isIncluded, isInfinity$1 as isInfinity, isInteger$1 as isInteger, isIntegerBetween$1 as isIntegerBetween, isIntegerBetweenExclusive$1 as isIntegerBetweenExclusive, isIntegerEq$1 as isIntegerEq, isIntegerGt$1 as isIntegerGt, isIntegerGte$1 as isIntegerGte, isIntegerLt$1 as isIntegerLt, isIntegerLte$1 as isIntegerLte, isIntegerOrUndefined$1 as isIntegerOrUndefined, isNaNValue$1 as isNaNValue, isNegInfinity$1 as isNegInfinity, isNonEmptyArray$1 as isNonEmptyArray, isNonEmptyArrayOrUndefined$1 as isNonEmptyArrayOrUndefined, isNonEmptyString$1 as isNonEmptyString, isNonEmptyStringOrUndefined$1 as isNonEmptyStringOrUndefined, isNull$1 as isNull, isNullish$1 as isNullish, isNumber$1 as isNumber, isNumberBetween$1 as isNumberBetween, isNumberBetweenExclusive$1 as isNumberBetweenExclusive, isNumberOrUndefined$1 as isNumberOrUndefined, isObject$1 as isObject, isObjectOrUndefined$1 as isObjectOrUndefined, isOddNumber$1 as isOddNumber, isPosInfinity$1 as isPosInfinity, isString$1 as isString, isStringOrUndefined$1 as isStringOrUndefined, isThrowing$1 as isThrowing, isTrue$1 as isTrue, isTrueOrUndefined$1 as isTrueOrUndefined, isTypedObject$1 as isTypedObject, isUndefined$1 as isUndefined, index$7_odd as odd, index$7_require as require, index$7_requireDefined as requireDefined, index$7_setErrorClass as setErrorClass };
144
144
  }
145
145
 
146
+ /**
147
+ * Set expiration time for cookies.
148
+ * @param days - Number of days until cookies expire.
149
+ */
146
150
  declare function setExpireDays(days: number): void;
151
+ /**
152
+ * Is consent pending (cookies not yet accepted)?
153
+ * @returns
154
+ */
147
155
  declare function isConsentPending(): boolean;
156
+ /**
157
+ * Consent cookies.
158
+ */
148
159
  declare function accept(): void;
160
+ /**
161
+ * Decline cookies. This will reject all cookies than a single flags that cookies have been declined.
162
+ */
149
163
  declare function decline(): void;
164
+ /**
165
+ * Save a cookie.
166
+ * @param name - Cookie name.
167
+ * @param value - Cookie value, can be string, number or boolean.
168
+ * @returns - Returns given value.
169
+ */
150
170
  declare function save<T extends string | number | boolean>(name: string, value: T): T;
171
+ /**
172
+ * Read a string cookie.
173
+ * @param name - Cookie name.
174
+ * @param defaultValue - Default value returned when cookie with given name was not found.
175
+ * @returns - String cookie value.
176
+ */
151
177
  declare function read(name: string, defaultValue: string): string;
178
+ /**
179
+ * Read an integer cookie.
180
+ * @param name - Cookie name.
181
+ * @param defaultValue - Default value returned when cookie with given name was not found.
182
+ * @returns - Integer cookie valus.
183
+ */
152
184
  declare function readInt(name: string, defaultValue: number): number;
185
+ /**
186
+ * Read a boolean cookie.
187
+ * @param name - Cookie name.
188
+ * @param defaultValue - Default value returned when cookie with given name was not found.
189
+ * @returns - Boolean cookie value.
190
+ */
153
191
  declare function readBool(name: string, defaultValue: boolean): boolean;
192
+ /**
193
+ * Erase cookie.
194
+ * @param name - Name of cookie to be erased.
195
+ */
154
196
  declare function erase(name: string): void;
197
+ /**
198
+ * Erase all cookies.
199
+ */
155
200
  declare function eraseAll(): void;
156
201
 
157
202
  declare const cookies_accept: typeof accept;
@@ -168,15 +213,39 @@ declare namespace cookies {
168
213
  export { cookies_accept as accept, cookies_decline as decline, cookies_erase as erase, cookies_eraseAll as eraseAll, cookies_isConsentPending as isConsentPending, cookies_read as read, cookies_readBool as readBool, cookies_readInt as readInt, cookies_save as save, cookies_setExpireDays as setExpireDays };
169
214
  }
170
215
 
216
+ /** Devices dots per inch. */
171
217
  declare const DPI: number;
218
+ /** Devices pixels per millimeter. */
172
219
  declare const PxPerMm: number;
220
+ /** Browsers scroll bar width. */
173
221
  declare const ScrollbarWidth: number;
222
+ /** Browsers system font size. */
174
223
  declare const FontSize: number;
224
+ /** Is touch device? */
175
225
  declare const IsTouchDevice: boolean;
226
+ /** Is mobile device? */
176
227
  declare const IsMobileDevice: boolean;
228
+ /** Host address. */
177
229
  declare const HostAddress: string;
230
+ /**
231
+ * Convert pixels to millimeters on a device.
232
+ * @param px - Pixels.
233
+ * @returns - Millimeters.
234
+ */
178
235
  declare function pxToMm(px: number): number;
236
+ /**
237
+ * Convert millimeters to pixels on a device.
238
+ * @param mm - Millimeters.
239
+ * @returns - Pixels.
240
+ */
179
241
  declare function mmToPx(mm: number): number;
242
+ /**
243
+ * Convert input to pixels on a device. Input value is in html style form containing number
244
+ * followed by unit (e.g. "10px"). Supported units are "mm", "cm", "in", "inch", "em" and "px".
245
+ *
246
+ * @param input - Input value.
247
+ * @returns - Pixels.
248
+ */
180
249
  declare function toPx(input: string | number): number;
181
250
 
182
251
  declare const device_DPI: typeof DPI;
@@ -310,8 +379,9 @@ declare namespace Guard {
310
379
 
311
380
  declare function toArray<T>(a: T | T[]): Array<T>;
312
381
  declare function duplicate<T>(a: T[] | undefined): T[] | undefined;
313
- declare function removeDuplicates<T>(a: T[]): T[];
314
- declare function removeDuplicatesCmp<T>(arr: ReadonlyArray<T>, cmp: (t1: T, t2: T) => boolean): T[];
382
+ declare function removeDuplicates<T>(arr: T[], compareFn?: (a: T, b: T) => boolean): T[];
383
+ /** @deprecated - Use {@link removeDuplicates} with compareFn instead. */
384
+ declare function removeDuplicatesCmp<T>(arr: ReadonlyArray<T>, compareFn: (t1: T, t2: T) => boolean): T[];
315
385
  declare function fillArray<T>(fillValue: T, fillCount: number): T[];
316
386
  declare function mapSequenceArray<T>(len: number, fn: (i: number) => T): T[];
317
387
  declare function getSequenceArray(len: number): number[];
@@ -545,18 +615,33 @@ declare namespace index {
545
615
  export { index$6 as Arr, index$5 as Dom, index$8 as Enum, index_Is as Is, index$4 as Map, index$3 as Math, index$2 as Obj, index$1 as Str };
546
616
  }
547
617
 
618
+ /**
619
+ * This is a stack data structure.
620
+ */
548
621
  declare class Stack<T> {
549
- private readonly list;
550
- push(e: T): T;
622
+ private readonly data;
623
+ private assertId;
624
+ get length(): number;
625
+ push(el: T): T;
551
626
  pop(): T;
627
+ popOrUndef(): T | undefined;
628
+ popOr(defaultValueOrCreator: T | (() => T)): T;
552
629
  top(): T;
630
+ topOrUndef(): T | undefined;
631
+ topOr(defaultValueOrCreator: T | (() => T)): T;
632
+ peek(depth?: number): T;
633
+ peekOrUndef(depth?: number): T | undefined;
634
+ peekOr(depth: number | undefined, defaultValueOrCreator: T | (() => T)): T;
635
+ values(): IterableIterator<T>;
636
+ [Symbol.iterator](): IterableIterator<T>;
553
637
  toArray(): T[];
554
- get length(): number;
638
+ isEmpty(): boolean;
555
639
  clear(): void;
640
+ toString(): string;
556
641
  }
557
642
 
558
643
  /**
559
- * Vector class.
644
+ * `Vec` is a generic vector class with two or more coordinates.
560
645
  *
561
646
  * ```ts
562
647
  * // Example usage:
@@ -606,7 +691,7 @@ declare class Vec {
606
691
  }
607
692
 
608
693
  /**
609
- * DivRect class, left, top, right, bottom rectangle divided into four sections by anchorX, anchorY.
694
+ * DivRect class is a rectangle (left, top, right, bottom) with an anchor point (anchorX, anchorY).
610
695
  */
611
696
  declare class DivRect {
612
697
  left: number;
@@ -830,7 +915,7 @@ declare class DivRect {
830
915
  }
831
916
 
832
917
  /**
833
- * LRUCache class: Least Recently Used cache with a fixed capacity
918
+ * LRUCache is an implementation of least recently used cache with a fixed capacity.
834
919
  */
835
920
  declare class LRUCache<K extends string, V> {
836
921
  private cache;
@@ -867,7 +952,8 @@ interface KVComponent<K extends any[], VALUE> {
867
952
  }
868
953
 
869
954
  /**
870
- * An array-like structure for non-negative indexes.
955
+ * `IndexArray` is a sparse array with non-negative indexes. It stores values
956
+ * to indexes, and each index also has flag telling it has a value.
871
957
  */
872
958
  declare class IndexArray<VALUE> implements KVComponent<[number], VALUE> {
873
959
  private static validateIndex;
@@ -879,6 +965,8 @@ declare class IndexArray<VALUE> implements KVComponent<[number], VALUE> {
879
965
  constructor(entries: Iterable<[number, VALUE]>);
880
966
  private get posLen();
881
967
  get size(): number;
968
+ get length(): number;
969
+ private trimRight;
882
970
  isEmpty(): boolean;
883
971
  has(id: number): boolean;
884
972
  set(id: number, value: VALUE): void;
@@ -898,7 +986,7 @@ declare class IndexArray<VALUE> implements KVComponent<[number], VALUE> {
898
986
  kvKeys(): IterableIterator<[number]>;
899
987
  kvValues(): IterableIterator<VALUE>;
900
988
  kvEntries(): IterableIterator<[[number], VALUE]>;
901
- [Symbol.iterator](): Generator<[number, VALUE], void, any>;
989
+ [Symbol.iterator](): IterableIterator<[number, VALUE]>;
902
990
  clone(): IndexArray<VALUE>;
903
991
  merge(other: IndexArray<VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, id: number) => VALUE): this;
904
992
  some(fn: (value: VALUE, id: number) => boolean): boolean;
@@ -911,11 +999,13 @@ declare class IndexArray<VALUE> implements KVComponent<[number], VALUE> {
911
999
  map<R = VALUE>(fn: (value: VALUE, key1: number) => R): IndexArray<R>;
912
1000
  equals(other: IndexArray<VALUE>): boolean;
913
1001
  equals(other: IndexArray<VALUE>, eq: (a: VALUE, b: VALUE) => boolean): boolean;
1002
+ toArray(): VALUE[];
914
1003
  toString(): string;
915
1004
  }
916
1005
 
917
1006
  /**
918
- * An array-like structure for signed indexes, including negatives.
1007
+ * `IndexArray` is a sparse array with positive and negative indexes. It stores
1008
+ * values to indexes, and each index also has flag telling it has a value.
919
1009
  */
920
1010
  declare class SignedIndexArray<VALUE> implements KVComponent<[number], VALUE> {
921
1011
  private static toNegIndex;
@@ -950,7 +1040,7 @@ declare class SignedIndexArray<VALUE> implements KVComponent<[number], VALUE> {
950
1040
  kvKeys(): IterableIterator<[number]>;
951
1041
  kvValues(): IterableIterator<VALUE>;
952
1042
  kvEntries(): IterableIterator<[[number], VALUE]>;
953
- [Symbol.iterator](): Generator<[number, VALUE], void, any>;
1043
+ [Symbol.iterator](): IterableIterator<[number, VALUE]>;
954
1044
  clone(): SignedIndexArray<VALUE>;
955
1045
  merge(other: SignedIndexArray<VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, id: number) => VALUE): this;
956
1046
  some(fn: (value: VALUE, id: number) => boolean): boolean;
@@ -963,9 +1053,66 @@ declare class SignedIndexArray<VALUE> implements KVComponent<[number], VALUE> {
963
1053
  map<R = VALUE>(fn: (value: VALUE, key1: number) => R): SignedIndexArray<R>;
964
1054
  equals(other: SignedIndexArray<VALUE>): boolean;
965
1055
  equals(other: SignedIndexArray<VALUE>, eq: (a: VALUE, b: VALUE) => boolean): boolean;
1056
+ toArray(): VALUE[];
966
1057
  toString(): string;
967
1058
  }
968
1059
 
1060
+ /**
1061
+ * `DefaultArray` is an array list where every index is guaranteed to have a value.
1062
+ * There are no undefineds unless that is part of the value type.
1063
+ * When you create `DefaultArray` you give a default value. For example if you
1064
+ * delete an index then that index is set to the default value.
1065
+ */
1066
+ declare class DefaultArray<VALUE> implements KVComponent<[number], VALUE> {
1067
+ readonly defaultValue: VALUE;
1068
+ private data;
1069
+ constructor(values: Iterable<VALUE>, defaultValue: VALUE);
1070
+ constructor(length: number, defaultValue: VALUE);
1071
+ get size(): number;
1072
+ get length(): number;
1073
+ private assertId;
1074
+ isEmpty(): boolean;
1075
+ isDefault(id: number): boolean;
1076
+ isSet(id: number): boolean;
1077
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
1078
+ has(id: number): boolean;
1079
+ set(id: number, value: VALUE): VALUE;
1080
+ get(id: number): VALUE;
1081
+ getOrDefault(id: number, defaultValue: VALUE): VALUE;
1082
+ getOrCreate(id: number, value: VALUE): VALUE;
1083
+ getOrCreate(id: number, creator: () => VALUE): VALUE;
1084
+ delete(id: number): boolean;
1085
+ clear(empty?: boolean): void;
1086
+ forEach(callbackfn: (value: VALUE, id: number, arr: DefaultArray<VALUE>) => void, thisArg?: any): void;
1087
+ indices(): IterableIterator<number>;
1088
+ values(): IterableIterator<VALUE>;
1089
+ entries(): IterableIterator<[number, VALUE]>;
1090
+ indicesArray(): number[];
1091
+ valuesArray(): VALUE[];
1092
+ entriesArray(): [number, VALUE][];
1093
+ kvKeys(): IterableIterator<[number]>;
1094
+ kvValues(): IterableIterator<VALUE>;
1095
+ kvEntries(): IterableIterator<[[number], VALUE]>;
1096
+ [Symbol.iterator](): IterableIterator<[number, VALUE]>;
1097
+ clone(): this;
1098
+ merge(other: DefaultArray<VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, id: number) => VALUE): this;
1099
+ some(fn: (value: VALUE, id: number) => boolean): boolean;
1100
+ every(fn: (value: VALUE, key1: number) => boolean): boolean;
1101
+ filter<S extends VALUE>(predicate: (value: VALUE, id: number, array: DefaultArray<VALUE>) => value is S): DefaultArray<S>;
1102
+ filter(predicate: (value: VALUE, id: number, array: DefaultArray<VALUE>) => unknown): DefaultArray<VALUE>;
1103
+ reduce(fn: (acc: VALUE, value: VALUE, id: number) => VALUE): VALUE;
1104
+ reduce<R>(fn: (acc: R, value: VALUE, id: number) => R, init: R): R;
1105
+ mapToArray<R>(fn: (value: VALUE, key1: number) => R): R[];
1106
+ map<R = VALUE>(fn: (value: VALUE, key1: number) => R, defaultValue: R): DefaultArray<R>;
1107
+ equals(other: DefaultArray<VALUE>): boolean;
1108
+ equals(other: DefaultArray<VALUE>, eq: (a: VALUE, b: VALUE) => boolean): boolean;
1109
+ toArray(): VALUE[];
1110
+ toString(): string;
1111
+ }
1112
+
1113
+ /**
1114
+ * A Map implementation mapping a single key to a value.
1115
+ */
969
1116
  declare class Map1<KEY1, VALUE> implements KVComponent<[KEY1], VALUE> {
970
1117
  private map1;
971
1118
  constructor();
@@ -991,7 +1138,7 @@ declare class Map1<KEY1, VALUE> implements KVComponent<[KEY1], VALUE> {
991
1138
  kvKeys(): IterableIterator<[KEY1]>;
992
1139
  kvValues(): IterableIterator<VALUE>;
993
1140
  kvEntries(): IterableIterator<[[KEY1], VALUE]>;
994
- [Symbol.iterator](): Generator<[KEY1, VALUE], void, any>;
1141
+ [Symbol.iterator](): IterableIterator<[KEY1, VALUE]>;
995
1142
  clone(): Map1<KEY1, VALUE>;
996
1143
  merge(other: Map1<KEY1, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1) => VALUE): this;
997
1144
  some(fn: (value: VALUE, key1: KEY1) => boolean): boolean;
@@ -1006,6 +1153,9 @@ declare class Map1<KEY1, VALUE> implements KVComponent<[KEY1], VALUE> {
1006
1153
  toString(): string;
1007
1154
  }
1008
1155
 
1156
+ /**
1157
+ * A Map implementation mapping a double key to a value.
1158
+ */
1009
1159
  declare class Map2<KEY1, KEY2, VALUE> implements KVComponent<[KEY1, KEY2], VALUE> {
1010
1160
  private map1;
1011
1161
  constructor();
@@ -1032,7 +1182,7 @@ declare class Map2<KEY1, KEY2, VALUE> implements KVComponent<[KEY1, KEY2], VALUE
1032
1182
  kvKeys(): IterableIterator<[KEY1, KEY2]>;
1033
1183
  kvValues(): IterableIterator<VALUE>;
1034
1184
  kvEntries(): IterableIterator<[[KEY1, KEY2], VALUE]>;
1035
- [Symbol.iterator](): Generator<[KEY1, KEY2, VALUE], void, any>;
1185
+ [Symbol.iterator](): IterableIterator<[KEY1, KEY2, VALUE]>;
1036
1186
  clone(): Map2<KEY1, KEY2, VALUE>;
1037
1187
  merge(other: Map2<KEY1, KEY2, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1, key2: KEY2) => VALUE): this;
1038
1188
  some(fn: (value: VALUE, key1: KEY1, key2: KEY2) => boolean): boolean;
@@ -1047,6 +1197,9 @@ declare class Map2<KEY1, KEY2, VALUE> implements KVComponent<[KEY1, KEY2], VALUE
1047
1197
  toString(): string;
1048
1198
  }
1049
1199
 
1200
+ /**
1201
+ * A Map implementation mapping a triple key to a value.
1202
+ */
1050
1203
  declare class Map3<KEY1, KEY2, KEY3, VALUE> implements KVComponent<[KEY1, KEY2, KEY3], VALUE> {
1051
1204
  private map1;
1052
1205
  constructor();
@@ -1074,7 +1227,7 @@ declare class Map3<KEY1, KEY2, KEY3, VALUE> implements KVComponent<[KEY1, KEY2,
1074
1227
  kvKeys(): IterableIterator<[KEY1, KEY2, KEY3]>;
1075
1228
  kvValues(): IterableIterator<VALUE>;
1076
1229
  kvEntries(): IterableIterator<[[KEY1, KEY2, KEY3], VALUE]>;
1077
- [Symbol.iterator](): Generator<[KEY1, KEY2, KEY3, VALUE], void, any>;
1230
+ [Symbol.iterator](): IterableIterator<[KEY1, KEY2, KEY3, VALUE]>;
1078
1231
  clone(): Map3<KEY1, KEY2, KEY3, VALUE>;
1079
1232
  merge(other: Map3<KEY1, KEY2, KEY3, VALUE>, conflictResolver?: (oldValue: VALUE, newValue: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => VALUE): this;
1080
1233
  some(fn: (value: VALUE, key1: KEY1, key2: KEY2, key3: KEY3) => boolean): boolean;
@@ -1089,6 +1242,82 @@ declare class Map3<KEY1, KEY2, KEY3, VALUE> implements KVComponent<[KEY1, KEY2,
1089
1242
  toString(): string;
1090
1243
  }
1091
1244
 
1245
+ /**
1246
+ * An abstract base class implementation of a Set data structure.
1247
+ */
1248
+ declare abstract class SetBase<VALUE, CLS extends SetBase<VALUE, CLS> = any> implements KVComponent<[VALUE], VALUE> {
1249
+ protected data: Set<VALUE>;
1250
+ constructor(entries?: Iterable<VALUE>);
1251
+ protected abstract valueEquals(a: VALUE, b: VALUE): boolean;
1252
+ protected abstract createEmpty<R = VALUE>(): SetBase<R, any>;
1253
+ protected abstract getName(): string;
1254
+ has(value: VALUE): boolean;
1255
+ add(value: VALUE): VALUE;
1256
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
1257
+ set(key: VALUE, value: VALUE): void;
1258
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
1259
+ get(key: VALUE): VALUE | undefined;
1260
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
1261
+ getOrDefault(key: VALUE, defaultValue: VALUE): VALUE;
1262
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
1263
+ getOrCreate(key: VALUE, value: VALUE): VALUE;
1264
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
1265
+ getOrCreate(key: VALUE, creator: () => VALUE): VALUE;
1266
+ delete(value: VALUE): boolean;
1267
+ clear(): void;
1268
+ get size(): number;
1269
+ isEmpty(): boolean;
1270
+ forEach(callbackfn: (value: VALUE, set1: SetBase<VALUE>) => void, thisArg?: any): void;
1271
+ keys(): IterableIterator<VALUE>;
1272
+ values(): IterableIterator<VALUE>;
1273
+ entries(): IterableIterator<[VALUE, VALUE]>;
1274
+ kvKeys(): IterableIterator<[VALUE]>;
1275
+ kvValues(): IterableIterator<VALUE>;
1276
+ kvEntries(): IterableIterator<[[VALUE], VALUE]>;
1277
+ [Symbol.iterator](): IterableIterator<VALUE>;
1278
+ clone(): SetBase<VALUE>;
1279
+ merge(other: SetBase<VALUE>): this;
1280
+ some(fn: (value: VALUE) => boolean): boolean;
1281
+ every(fn: (value: VALUE) => boolean): boolean;
1282
+ filter<R extends VALUE>(predicate: (value: VALUE, set1: SetBase<VALUE, any>) => value is R): SetBase<R, any>;
1283
+ filter(predicate: (value: VALUE, set1: SetBase<VALUE>) => unknown): SetBase<VALUE, any>;
1284
+ reduce(fn: (acc: VALUE, value: VALUE) => VALUE): VALUE;
1285
+ reduce<R = VALUE>(fn: (acc: R, value: VALUE) => R, init: R): R;
1286
+ mapValues<R = VALUE>(fn: (value: VALUE) => R): SetBase<R, any>;
1287
+ mapToArray<R = VALUE>(fn: (value: VALUE) => R): R[];
1288
+ map<R = VALUE>(fn: (value: VALUE) => R): SetBase<R, any>;
1289
+ toSet(): Set<VALUE>;
1290
+ toArray(): VALUE[];
1291
+ toString(): string;
1292
+ }
1293
+ /**
1294
+ * A simple Set data structure. Comparison of values is done
1295
+ * using === operator (e.g. "a" === "a", but [1, 2] !== [1, 2]).
1296
+ */
1297
+ declare class Set1<VALUE> extends SetBase<VALUE, Set1<VALUE>> {
1298
+ constructor();
1299
+ constructor(set: SetBase<VALUE>);
1300
+ constructor(entries: Iterable<VALUE>);
1301
+ protected createEmpty<R = VALUE>(): Set1<R>;
1302
+ protected valueEquals(a: VALUE, b: VALUE): boolean;
1303
+ protected getName(): string;
1304
+ }
1305
+ /**
1306
+ * A simple Set data structure, where comparison of values is done
1307
+ * using deep equality (e.g. "a" === "a" and also [1, 2] === [1, 2]).
1308
+ */
1309
+ declare class DeepSet<VALUE> extends SetBase<VALUE, DeepSet<VALUE>> {
1310
+ constructor();
1311
+ constructor(set: SetBase<VALUE>);
1312
+ constructor(entries: Iterable<VALUE>);
1313
+ protected createEmpty<R = VALUE>(): DeepSet<R>;
1314
+ protected valueEquals(a: VALUE, b: VALUE): boolean;
1315
+ protected getName(): string;
1316
+ }
1317
+
1318
+ /**
1319
+ * Wrapper class of a key-value container that contain array values.
1320
+ */
1092
1321
  declare class MultiContainer<K extends any[], V> {
1093
1322
  private readonly base;
1094
1323
  constructor(base: KVComponent<K, V[]>);
@@ -1105,10 +1334,14 @@ declare class MultiContainer<K extends any[], V> {
1105
1334
  toString(): string;
1106
1335
  }
1107
1336
  /**
1337
+ * Create a multi-container.
1338
+ *
1108
1339
  * ```ts
1109
1340
  * // Usage:
1110
1341
  * const multi = asMulti(new Map2<string, string, number[]>());
1111
- * multi.add("A", "B", 5);
1342
+ * multi.add("a", "b", 5);
1343
+ * multi.add("a", "b", 10);
1344
+ * multi.add("a", "c", 15);
1112
1345
  * ```
1113
1346
  * @param base
1114
1347
  * @returns
@@ -1163,4 +1396,4 @@ declare class SmallIntCache<VALUE> {
1163
1396
  clear(): void;
1164
1397
  }
1165
1398
 
1166
- export { index$7 as Assert, cookies as Cookies, device as Device, DivRect, Guard, IndexArray, type KVComponent, LRUCache, Map1, Map2, Map3, MultiContainer, SignedIndexArray, SmallIntCache, Stack, index as Utils, Vec, Vec2, asMulti };
1399
+ export { index$7 as Assert, cookies as Cookies, DeepSet, DefaultArray, device as Device, DivRect, Guard, IndexArray, type KVComponent, LRUCache, Map1, Map2, Map3, MultiContainer, Set1, SetBase, SignedIndexArray, SmallIntCache, Stack, index as Utils, Vec, Vec2, asMulti };