swc/bundler/tests/.cache/deno/3e9ec29bf7ffe6df5bbd10261cc1a3eeb15a74b1.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

32 lines
713 B
TypeScript

// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isNumeric.ts
// @ts-ignore allowing typedoc to build
import { assertString } from '../helpers/assertString.ts';
// @ts-ignore allowing typedoc to build
import { decimal } from '../helpers/alpha.ts';
/**
* @ignore
*/
const numericNoSymbols = /^[0-9]+$/;
type NumericOptions = {
noSymbols?: boolean;
locale?: any;
};
export const isNumeric = (str: string, options?: NumericOptions) => {
assertString(str);
if (options && options.noSymbols) {
return numericNoSymbols.test(str);
}
return new RegExp(
`^[+-]?([0-9]*[${
(options || {}).locale ? (decimal as any)[options?.locale] : '.'
}])?[0-9]+$`
).test(str);
};