@microsoft/kiota-abstractions
Version:
Core abstractions for kiota generated libraries in TypeScript and JavaScript
21 lines • 939 B
JavaScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
const reverseRecord = (input) => {
const entries = Object.entries(input).map(([key, value]) => [value, key]);
return Object.fromEntries(entries);
};
/**
* Factory to create an UntypedString from a string.
* @param stringValue The string value to lookup the enum value from.
* @param originalType The type definition of the enum.
* @returns The enum value.
*/
export const getEnumValueFromStringValue = (stringValue, originalType) => {
const reversed = reverseRecord(originalType);
return originalType[reversed[stringValue]];
};
//# sourceMappingURL=enumUtils.js.map