-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathis.ts
More file actions
67 lines (52 loc) · 1.48 KB
/
Copy pathis.ts
File metadata and controls
67 lines (52 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type { AnyAsyncFunction } from "./function";
export const isSymobl = (v: unknown): v is symbol => {
return typeof v === "symbol";
};
export const isString = (v: unknown): v is string => {
return typeof v === "string";
};
export const isNumber = (v: unknown): v is number => {
return typeof v === "number";
};
export const isBoolean = (v: unknown): v is boolean => {
return typeof v === "boolean";
};
export const isArray = (v: unknown): v is Array<any> => {
return Array.isArray(v);
};
export const isFunction = (v: unknown): v is Function => {
return typeof v === "function";
};
export const isObject = (v: unknown): v is object => {
return typeof v === "object" && v !== null;
};
const { constructor } = Object.getPrototypeOf(
async function () {},
);
export const isAsyncFunciton = (
v: unknown,
): v is AnyAsyncFunction => {
return typeof v === "function" && v instanceof constructor;
};
export const isSet = (v: unknown): v is Set<any> => {
return v instanceof Set;
};
export const isWeakSet = (
v: unknown,
): v is WeakSet<any> => {
return v instanceof WeakSet;
};
export const isMap = (v: unknown): v is Map<any, any> => {
return v instanceof Map;
};
export const isWeakMap = (
v: unknown,
): v is WeakMap<any, any> => {
return v instanceof WeakMap;
};
export const isPromise = (v: unknown): v is Promise<any> => {
return v instanceof Promise;
};
export const isUndefined = (v: undefined): v is undefined => {
return typeof v === "undefined";
};