@trackunit/shared-utils 0.0.71 → 0.0.73
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/README.md +0 -4
- package/index.cjs.js +1 -1
- package/index.esm.js +1 -1
- package/package.json +1 -1
- package/src/enumUtils.d.ts +1 -1
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -411,7 +411,7 @@ const enumOrUndefinedFromValue = (_enum, val) => {
|
|
|
411
411
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
412
412
|
*/
|
|
413
413
|
const enumFromValueTypesafe = (val, _enum) => {
|
|
414
|
-
const enumName =
|
|
414
|
+
const enumName = objectKeys(_enum).find(k => _enum[k] === val);
|
|
415
415
|
if (!enumName) {
|
|
416
416
|
throw Error(`Unknown enum value: ${String(val)} expect one of: ${JSON.stringify(objectValues(_enum))}`);
|
|
417
417
|
}
|
package/index.esm.js
CHANGED
|
@@ -409,7 +409,7 @@ const enumOrUndefinedFromValue = (_enum, val) => {
|
|
|
409
409
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
410
410
|
*/
|
|
411
411
|
const enumFromValueTypesafe = (val, _enum) => {
|
|
412
|
-
const enumName =
|
|
412
|
+
const enumName = objectKeys(_enum).find(k => _enum[k] === val);
|
|
413
413
|
if (!enumName) {
|
|
414
414
|
throw Error(`Unknown enum value: ${String(val)} expect one of: ${JSON.stringify(objectValues(_enum))}`);
|
|
415
415
|
}
|
package/package.json
CHANGED
package/src/enumUtils.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @returns {Record<string, string>} The enum value.
|
|
7
7
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
8
8
|
*/
|
|
9
|
-
export declare const enumFromValue: <T extends Record<string, string>>(val: string, _enum: T) => T[keyof T];
|
|
9
|
+
export declare const enumFromValue: <T extends Record<string, string | number>>(val: string | number, _enum: T) => T[keyof T];
|
|
10
10
|
/**
|
|
11
11
|
* Returns the enum value from a string value or undefined if the string value is undefined or null.
|
|
12
12
|
*
|