@indietabletop/appkit 7.0.0-rc.2 → 7.0.0-rc.3
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/lib/EnumMapper.ts +11 -3
- package/lib/index.ts +1 -0
- package/package.json +1 -1
package/lib/EnumMapper.ts
CHANGED
|
@@ -8,9 +8,10 @@ export class EnumMapper<K extends string | number, V> {
|
|
|
8
8
|
private fallback: V;
|
|
9
9
|
|
|
10
10
|
constructor(values: InputValues<K, V>, fallback: V) {
|
|
11
|
-
const entries =
|
|
12
|
-
? values
|
|
13
|
-
|
|
11
|
+
const entries =
|
|
12
|
+
Array.isArray(values) ? values : (
|
|
13
|
+
(Object.entries(values) as Array<[K, V]>)
|
|
14
|
+
);
|
|
14
15
|
this.map = new Map(entries);
|
|
15
16
|
this.fallback = fallback;
|
|
16
17
|
}
|
|
@@ -44,6 +45,13 @@ export class EnumMapper<K extends string | number, V> {
|
|
|
44
45
|
return Array.from(this.map.keys());
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Checks whether key is known by the mapper.
|
|
50
|
+
*/
|
|
51
|
+
has(value: string | number): value is K {
|
|
52
|
+
return this.map.has(value as K);
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
static from<K extends string>(values: InputValues<K, string>) {
|
|
48
56
|
return new EnumMapper(values, "Unknown");
|
|
49
57
|
}
|
package/lib/index.ts
CHANGED
|
@@ -56,6 +56,7 @@ export * from "./class-names.ts";
|
|
|
56
56
|
export * from "./client.ts";
|
|
57
57
|
export * from "./copyrightRange.ts";
|
|
58
58
|
export * from "./createSafeStorage.ts";
|
|
59
|
+
export * from "./createStrictContext.ts";
|
|
59
60
|
export * from "./failureMessages.ts";
|
|
60
61
|
export * from "./fathom.ts";
|
|
61
62
|
export * from "./groupBy.ts";
|