MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseEnum

Function parseEnum

packages/cli/src/commands/cloudrun.ts:850–860  ·  view source on GitHub ↗
(
  raw: unknown,
  allowed: readonly T[],
  errorPrefix: string,
  defaultValue: T | undefined,
)

Source from the content-addressed store, hash-verified

848}
849// fallow-ignore-next-line complexity
850function parseEnum<T extends string>(
851 raw: unknown,
852 allowed: readonly T[],
853 errorPrefix: string,
854 defaultValue: T | undefined,
855): T | undefined {
856 if (raw === undefined || raw === null || raw === "") return defaultValue;
857 const s = String(raw);
858 if ((allowed as readonly string[]).includes(s)) return s as T;
859 throw new Error(`${errorPrefix} must be ${allowed.join("|")}; got ${s}`);
860}
861const FORMATS = ["mp4", "mov", "png-sequence", "webm"] as const;
862const CODECS = ["h264", "h265"] as const;
863const QUALITIES = ["draft", "standard", "high"] as const;

Callers 3

parseFormatFunction · 0.70
parseCodecFunction · 0.70
parseQualityFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected