-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathformatExtension.ts
More file actions
25 lines (22 loc) · 968 Bytes
/
formatExtension.ts
File metadata and controls
25 lines (22 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* Map a distributed `format` to the file extension the assembled output
* should carry on disk + in S3. Shared by `src/handler.ts` (chunk +
* assemble output paths) and `src/sdk/renderToLambda.ts` (final
* output key construction) so the two sides agree on what an mp4
* looks like vs a png-sequence.
*/
export type DistributedFormat = "mp4" | "mov" | "png-sequence" | "webm";
// Closed-enum lookup table. TS enforces exhaustiveness via the
// `Record<DistributedFormat, string>` annotation — adding a format to
// `DistributedFormat` without adding the matching key here fails to
// typecheck, which is the same exhaustiveness guarantee a switch +
// `_exhaustive: never` arm provides but at lower complexity.
const FORMAT_EXTENSIONS: Record<DistributedFormat, string> = {
mp4: ".mp4",
mov: ".mov",
webm: ".webm",
"png-sequence": "",
};
export function formatExtension(format: DistributedFormat): string {
return FORMAT_EXTENSIONS[format];
}