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

Function parseEnum

packages/cli/src/commands/lambda.ts:446–456  ·  view source on GitHub ↗

* Parse a string-union flag against a closed set of allowed values. * Returns `defaultValue` (which may be `undefined`) when the input is * empty; throws with a flag-specific message when the value is set * but unrecognised.

(
  raw: unknown,
  allowed: readonly T[],
  errorPrefix: string,
  defaultValue: T | undefined,
)

Source from the content-addressed store, hash-verified

444 * but unrecognised.
445 */
446function parseEnum<T extends string>(
447 raw: unknown,
448 allowed: readonly T[],
449 errorPrefix: string,
450 defaultValue: T | undefined,
451): T | undefined {
452 if (raw === undefined || raw === null || raw === "") return defaultValue;
453 const s = String(raw);
454 if ((allowed as readonly string[]).includes(s)) return s as T;
455 throw new Error(`${errorPrefix} must be ${allowed.join("|")}; got ${s}`);
456}
457
458const FORMATS = [
459 "mp4",

Callers 4

parseFormatFunction · 0.70
parseCodecFunction · 0.70
parseQualityFunction · 0.70
parseChromeSourceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected