MCPcopy
hub / github.com/faker-js/faker / enumValue

Method enumValue

src/modules/helpers/index.ts:1097–1106  ·  view source on GitHub ↗
(
    enumObject: T
  )

Source from the content-addressed store, hash-verified

1095 */
1096 // This does not use `const T` because enums shouldn't be created on the spot.
1097 enumValue<T extends Record<string | number, string | number>>(
1098 enumObject: T
1099 ): T[keyof T] {
1100 // ignore numeric keys added by TypeScript
1101 const keys: Array<keyof T> = Object.keys(enumObject).filter((key) =>
1102 Number.isNaN(Number(key))
1103 );
1104 const randomKey = this.arrayElement(keys);
1105 return enumObject[randomKey];
1106 }
1107
1108 /**
1109 * Helper method that converts the given number or range to a number.

Callers 6

helpers.spec.tsFile · 0.80
cssSupportedFunctionMethod · 0.80
cssSupportedSpaceMethod · 0.80
bitcoinAddressMethod · 0.80
sexTypeMethod · 0.80
aircraftTypeMethod · 0.80

Calls 1

arrayElementMethod · 0.95

Tested by

no test coverage detected