[improvement] optimize isNaN (#3988)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { isNaN } from './number';
|
||||
|
||||
export function isDate(date: Date): boolean {
|
||||
return (
|
||||
Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime())
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
/* eslint-disable no-self-compare */
|
||||
|
||||
export function isNumber(value: string): boolean {
|
||||
return /^\d+(\.\d+)?$/.test(value);
|
||||
}
|
||||
|
||||
export function isNaN(value: any): boolean {
|
||||
if (Number.isNaN) {
|
||||
return Number.isNaN(value);
|
||||
}
|
||||
|
||||
return value !== value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user