@trackunit/shared-utils 0.0.50 → 0.0.51
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/index.cjs.js +4 -4
- package/index.esm.js +4 -4
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -378,9 +378,9 @@ function doNothing() {
|
|
|
378
378
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
379
379
|
*/
|
|
380
380
|
const enumFromValue = (val, _enum) => {
|
|
381
|
-
const enumName =
|
|
381
|
+
const enumName = objectKeys(_enum).find(k => _enum[k] === val);
|
|
382
382
|
if (!enumName) {
|
|
383
|
-
throw Error(`Unknown enum value: ${val} expect one of: ${JSON.stringify(
|
|
383
|
+
throw Error(`Unknown enum value: ${val} expect one of: ${JSON.stringify(objectValues(_enum))}`);
|
|
384
384
|
}
|
|
385
385
|
return _enum[enumName];
|
|
386
386
|
};
|
|
@@ -408,9 +408,9 @@ const enumOrUndefinedFromValue = (_enum, val) => {
|
|
|
408
408
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
409
409
|
*/
|
|
410
410
|
const enumFromValueTypesafe = (val, _enum) => {
|
|
411
|
-
const enumName =
|
|
411
|
+
const enumName = (objectKeys(_enum)).find(k => _enum[k] === val);
|
|
412
412
|
if (!enumName) {
|
|
413
|
-
throw Error(`Unknown enum value: ${String(val)} expect one of: ${JSON.stringify(
|
|
413
|
+
throw Error(`Unknown enum value: ${String(val)} expect one of: ${JSON.stringify(objectValues(_enum))}`);
|
|
414
414
|
}
|
|
415
415
|
return _enum[enumName];
|
|
416
416
|
};
|
package/index.esm.js
CHANGED
|
@@ -374,9 +374,9 @@ function doNothing() {
|
|
|
374
374
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
375
375
|
*/
|
|
376
376
|
const enumFromValue = (val, _enum) => {
|
|
377
|
-
const enumName =
|
|
377
|
+
const enumName = objectKeys(_enum).find(k => _enum[k] === val);
|
|
378
378
|
if (!enumName) {
|
|
379
|
-
throw Error(`Unknown enum value: ${val} expect one of: ${JSON.stringify(
|
|
379
|
+
throw Error(`Unknown enum value: ${val} expect one of: ${JSON.stringify(objectValues(_enum))}`);
|
|
380
380
|
}
|
|
381
381
|
return _enum[enumName];
|
|
382
382
|
};
|
|
@@ -404,9 +404,9 @@ const enumOrUndefinedFromValue = (_enum, val) => {
|
|
|
404
404
|
* @example enumFromValue("MACHINE", AssetType) // AssetType.MACHINE
|
|
405
405
|
*/
|
|
406
406
|
const enumFromValueTypesafe = (val, _enum) => {
|
|
407
|
-
const enumName =
|
|
407
|
+
const enumName = (objectKeys(_enum)).find(k => _enum[k] === val);
|
|
408
408
|
if (!enumName) {
|
|
409
|
-
throw Error(`Unknown enum value: ${String(val)} expect one of: ${JSON.stringify(
|
|
409
|
+
throw Error(`Unknown enum value: ${String(val)} expect one of: ${JSON.stringify(objectValues(_enum))}`);
|
|
410
410
|
}
|
|
411
411
|
return _enum[enumName];
|
|
412
412
|
};
|