14 lines
286 B
TypeScript
14 lines
286 B
TypeScript
/**
|
|
* @description: 判断值是否为某个类型
|
|
*/
|
|
export function is(val: unknown, type: string) {
|
|
return toString.call(val) === `[object ${type}]`
|
|
}
|
|
|
|
/**
|
|
* @description: 是否为数值
|
|
*/
|
|
export function isNumber(val: unknown): val is number {
|
|
return is(val, "Number")
|
|
}
|