Skip to content

Commit dd11dcb

Browse files
committed
perf: add instanceof checks
1 parent 8d2c0f3 commit dd11dcb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/parser/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export function isBigUInt64Array(value: unknown): value is BigUint64Array {
3535
);
3636
}
3737

38-
export function isRegExp(d: unknown): d is RegExp {
39-
return Object.prototype.toString.call(d) === '[object RegExp]';
38+
export function isRegExp(regexp: unknown): regexp is RegExp {
39+
return regexp instanceof RegExp || Object.prototype.toString.call(regexp) === '[object RegExp]';
4040
}
4141

4242
export function isMap(value: unknown): value is Map<unknown, unknown> {
@@ -48,8 +48,8 @@ export function isMap(value: unknown): value is Map<unknown, unknown> {
4848
);
4949
}
5050

51-
export function isDate(d: unknown): d is Date {
52-
return Object.prototype.toString.call(d) === '[object Date]';
51+
export function isDate(date: unknown): date is Date {
52+
return date instanceof Date || Object.prototype.toString.call(date) === '[object Date]';
5353
}
5454

5555
export type InspectFn = (x: unknown, options?: unknown) => string;

0 commit comments

Comments
 (0)