UNPKG

@zstings/utils

Version:

javascript、typescript 工具函数库 文档地址 [utils 文档](https://zstings.github.io/utils/)

21 lines (20 loc) 381 B
/** * 转换为数字 * @param value 任意值 * @return 返回数字 * @throws 无法转换为数字 * @category 数字Number * @example * ```ts * toNumber('1') // 1 * ``` * @example * ```ts * toNumber('1.2') // 1.2 * ``` * @example * ```ts * toNumber('a123') // error => a123无法转换为数字 * ``` */ export default function toNumber<T>(value: T): number;