swc/crates/swc_bundler/tests/.cache/deno/34258bfe315c2e7dbaff38f7316cbfe31d370014.ts
2021-11-09 20:42:49 +09:00

18 lines
463 B
TypeScript

// Loaded from https://deno.land/x/cliffy@v0.18.0/flags/types/number.ts
import type { ITypeHandler, ITypeInfo } from "../types.ts";
/** Number type handler. Excepts any numeric value. */
export const number: ITypeHandler<number> = (
{ label, name, value, type }: ITypeInfo,
): number => {
if (isNaN(Number(value))) {
throw new Error(
`${label} "${name}" must be of type "${type}", but got "${value}".`,
);
}
return parseFloat(value);
};