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

14 lines
455 B
TypeScript

// Loaded from https://deno.land/x/cliffy@v0.12.1/packages/flags/lib/types/number.ts
import { IFlagArgument, IFlagOptions, ITypeHandler } from '../types.ts';
export const number: ITypeHandler<number> = ( option: IFlagOptions, arg: IFlagArgument, value: string ): number => {
if ( isNaN( value as any ) ) {
throw new Error( `Option --${ option.name } must be of type number but got: ${ value }` );
}
return parseFloat( value );
};