anvil/striker-ui/lib/toNumber.ts

8 lines
215 B
TypeScript
Raw Normal View History

const toNumber: (
value: unknown,
parser?: 'parseFloat' | 'parseInt',
) => number = (value, parser = 'parseInt') =>
typeof value === 'number' ? value : Number[parser](String(value));
export default toNumber;