@themachinarium/google-merchant-feed
Version:
A simple library to generate Google Merchant XML Feed
25 lines (20 loc) • 507 B
text/typescript
export const PAUSE = {
ads: "ads",
all: "all",
} as const;
export namespace Pause {
export type Model = keyof typeof PAUSE;
export function formatter(pause: Pause.Model): string {
const isValidPause = (value: string): value is Pause.Model => {
return value in PAUSE;
};
if (!isValidPause(pause)) {
throw new Error(
`Invalid pause: "${pause}". Valid values are: ${Object.keys(PAUSE).join(
", ",
)}`,
);
}
return PAUSE[pause];
}
}