@pawover/kit 0.0.0-alpha.3 → 0.0.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/enums.d.ts +25 -0
  2. package/dist/enums.d.ts.map +1 -0
  3. package/dist/enums.js +25 -0
  4. package/dist/enums.js.map +1 -0
  5. package/dist/hooks-alova.d.ts +23 -0
  6. package/dist/hooks-alova.d.ts.map +1 -0
  7. package/dist/hooks-alova.js +39 -0
  8. package/dist/hooks-alova.js.map +1 -0
  9. package/dist/hooks-react.d.ts +89 -0
  10. package/dist/hooks-react.d.ts.map +1 -0
  11. package/dist/hooks-react.js +334 -0
  12. package/dist/hooks-react.js.map +1 -0
  13. package/dist/index.d.ts +2388 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +1361 -2
  16. package/dist/index.js.map +1 -0
  17. package/dist/patches-fetchEventSource.d.ts +806 -0
  18. package/dist/patches-fetchEventSource.d.ts.map +1 -0
  19. package/dist/patches-fetchEventSource.js +313 -0
  20. package/dist/patches-fetchEventSource.js.map +1 -0
  21. package/dist/vite.d.ts +13 -0
  22. package/dist/vite.d.ts.map +1 -0
  23. package/dist/vite.js +22 -0
  24. package/dist/vite.js.map +1 -0
  25. package/dist/zod.d.ts +105 -0
  26. package/dist/zod.d.ts.map +1 -0
  27. package/dist/zod.js +138 -0
  28. package/dist/zod.js.map +1 -0
  29. package/metadata.json +157 -0
  30. package/package.json +57 -35
  31. package/dist/enums/index.js +0 -20
  32. package/dist/hooks/react/index.js +0 -5
  33. package/dist/hooks/react/useCreation.js +0 -11
  34. package/dist/hooks/react/useLatest.js +0 -6
  35. package/dist/hooks/react/useMount.js +0 -29
  36. package/dist/hooks/react/useResponsive.js +0 -59
  37. package/dist/hooks/react/useUnmount.js +0 -17
  38. package/dist/types/enums/index.d.ts +0 -20
  39. package/dist/types/hooks/react/index.d.ts +0 -5
  40. package/dist/types/hooks/react/useCreation.d.ts +0 -2
  41. package/dist/types/hooks/react/useLatest.d.ts +0 -1
  42. package/dist/types/hooks/react/useMount.d.ts +0 -11
  43. package/dist/types/hooks/react/useResponsive.d.ts +0 -16
  44. package/dist/types/hooks/react/useUnmount.d.ts +0 -6
  45. package/dist/types/index.d.ts +0 -2
  46. package/dist/types/utils/array.d.ts +0 -76
  47. package/dist/types/utils/index.d.ts +0 -6
  48. package/dist/types/utils/object.d.ts +0 -53
  49. package/dist/types/utils/string.d.ts +0 -13
  50. package/dist/types/utils/to.d.ts +0 -5
  51. package/dist/types/utils/tree/index.d.ts +0 -6
  52. package/dist/types/utils/tree/rowsToTree.d.ts +0 -10
  53. package/dist/types/utils/tree/treeFilter.d.ts +0 -6
  54. package/dist/types/utils/tree/treeFind.d.ts +0 -8
  55. package/dist/types/utils/tree/treeForEach.d.ts +0 -5
  56. package/dist/types/utils/tree/treeMap.d.ts +0 -6
  57. package/dist/types/utils/tree/treeToRows.d.ts +0 -9
  58. package/dist/types/utils/tree/types.d.ts +0 -24
  59. package/dist/types/utils/typeof.d.ts +0 -29
  60. package/dist/utils/array.js +0 -196
  61. package/dist/utils/index.js +0 -6
  62. package/dist/utils/object.js +0 -138
  63. package/dist/utils/string.js +0 -70
  64. package/dist/utils/to.js +0 -16
  65. package/dist/utils/tree/index.js +0 -6
  66. package/dist/utils/tree/rowsToTree.js +0 -35
  67. package/dist/utils/tree/treeFilter.js +0 -92
  68. package/dist/utils/tree/treeFind.js +0 -82
  69. package/dist/utils/tree/treeForEach.js +0 -60
  70. package/dist/utils/tree/treeMap.js +0 -79
  71. package/dist/utils/tree/treeToRows.js +0 -13
  72. package/dist/utils/tree/types.js +0 -10
  73. package/dist/utils/typeof.js +0 -114
@@ -1,70 +0,0 @@
1
- import { isString } from "./typeof";
2
- /**
3
- * 转义特殊字符
4
- *
5
- * @link https://github.com/sindresorhus/escape-string-regexp
6
- * @param value 字符串
7
- */
8
- export function escapeStringRegexp(value) {
9
- return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
10
- }
11
- /**
12
- * 首字母大小写
13
- */
14
- export function stringInitialCase(value, type) {
15
- if (!isString(value) || value.length === 0) {
16
- return value;
17
- }
18
- const m1 = /\S+/g;
19
- const m2 = /[^a-zA-Z\u00C0-\u017F]/;
20
- return value.replace(m1, (word) => {
21
- // 单词含非字母字符(如.,'-等)→ 原样保留
22
- if (m2.test(word)) {
23
- return word;
24
- }
25
- // 纯字母且全大写 → 保留
26
- if (word === word.toLocaleUpperCase()) {
27
- return word;
28
- }
29
- // 纯字母且非全大写 → 首字母小写,其余保留
30
- if (type === "lower" && word[0]) {
31
- return word[0].toLocaleLowerCase() + word.slice(1);
32
- }
33
- // 纯字母且非全大写 → 首字母大写写,其余保留
34
- if (type === "upper" && word[0]) {
35
- return word[0].toLocaleUpperCase() + word.slice(1);
36
- }
37
- return word;
38
- });
39
- }
40
- export function stringToJson(data, safeValue) {
41
- if (isString(data) && data) {
42
- try {
43
- const value = JSON.parse(data);
44
- return value;
45
- }
46
- catch (error) {
47
- return safeValue;
48
- }
49
- }
50
- else {
51
- return safeValue;
52
- }
53
- }
54
- export function stringToValues(data, valueType = "number") {
55
- if (isString(data) && data) {
56
- try {
57
- const values = data.split(",");
58
- if (valueType === "number") {
59
- return values.map((d) => Number(d));
60
- }
61
- return values;
62
- }
63
- catch (error) {
64
- return [];
65
- }
66
- }
67
- else {
68
- return [];
69
- }
70
- }
package/dist/utils/to.js DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * @param promise
3
- * @param errorExt - 可以传递给err对象的其他信息
4
- */
5
- export function to(promise, errorExt) {
6
- return promise
7
- .then((data) => [null, data])
8
- .catch((err) => {
9
- if (errorExt) {
10
- const parsedError = { ...err, ...errorExt };
11
- return [parsedError, undefined];
12
- }
13
- const defaultError = err ? err : new Error("defaultError");
14
- return [defaultError, undefined];
15
- });
16
- }
@@ -1,6 +0,0 @@
1
- export { treeFilter } from "./treeFilter";
2
- export { treeFind } from "./treeFind";
3
- export { treeForEach } from "./treeForEach";
4
- export { treeMap } from "./treeMap";
5
- export { rowsToTree } from "./rowsToTree";
6
- export { treeToRows } from "./treeToRows";
@@ -1,35 +0,0 @@
1
- import { isNull, isUndefined } from "../typeof";
2
- /**
3
- * 行结构 转 树结构
4
- */
5
- export function rowsToTree(rows, options) {
6
- const { parentIdKey = "parentId", rowKey = "id", childrenKey = "children" } = options || {};
7
- const result = [];
8
- const map = new Map();
9
- for (const row of rows) {
10
- const id = row[rowKey];
11
- if (!map.get(id)) {
12
- map.set(id, row);
13
- }
14
- }
15
- for (const row of rows) {
16
- const parentId = row[parentIdKey];
17
- const parent = map.get(parentId);
18
- if (!parent || !parentId) {
19
- result.push(row);
20
- continue;
21
- }
22
- const siblings = parent[childrenKey];
23
- if (isNull(siblings) || isUndefined(siblings)) {
24
- parent[childrenKey] = [row];
25
- }
26
- else if (Array.isArray(siblings)) {
27
- siblings.push(row);
28
- }
29
- else {
30
- const message = `The key "${childrenKey.toString()}" in parent item is not an array.`;
31
- throw new Error(message);
32
- }
33
- }
34
- return result;
35
- }
@@ -1,92 +0,0 @@
1
- import { arrayLast } from "../array";
2
- import { isArray } from "../typeof";
3
- import { getFinalChildrenKey } from "./types";
4
- // 前置遍历
5
- function preImpl(row, callback, options) {
6
- const result = callback(row, options);
7
- if (!result) {
8
- return undefined;
9
- }
10
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
11
- const children = row[finalChildrenKey];
12
- let newChildren;
13
- if (isArray(children)) {
14
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
15
- newChildren = children.map((c) => preImpl(c, callback, nextLevelOptions)).filter((c) => !!c);
16
- }
17
- return { ...row, [finalChildrenKey]: newChildren };
18
- }
19
- // 子节点优先遍历
20
- function postImpl(row, callback, options) {
21
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
22
- const children = row[finalChildrenKey];
23
- let newChildren;
24
- if (isArray(children)) {
25
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
26
- newChildren = children.map((c) => preImpl(c, callback, nextLevelOptions)).filter((c) => !!c);
27
- }
28
- const result = callback(row, options);
29
- if (!result) {
30
- return undefined;
31
- }
32
- return { ...row, [finalChildrenKey]: newChildren };
33
- }
34
- // 广度优先遍历
35
- function breadthImpl(row, callback, options) {
36
- const queue = [{ queueRow: row, queueOptions: options }];
37
- const resultCache = new WeakMap();
38
- const newNodeCache = new WeakMap();
39
- const childrenKeyCache = new WeakMap();
40
- let result;
41
- const runQueue = () => {
42
- if (queue.length === 0) {
43
- return result;
44
- }
45
- const { queueRow, queueOptions } = queue.shift();
46
- const finalChildrenKey = getFinalChildrenKey(queueRow, queueOptions, queueOptions);
47
- const children = queueRow[finalChildrenKey];
48
- if (isArray(children)) {
49
- const nextLevelOptions = { ...queueOptions, parents: [...queueOptions.parents, queueRow], depth: queueOptions.depth + 1 };
50
- const subQueueItems = children.map((queueRow) => ({ queueRow, queueOptions: nextLevelOptions }));
51
- queue.push(...subQueueItems);
52
- }
53
- const parent = arrayLast(queueOptions.parents);
54
- const isTopNode = queueOptions.depth === 0;
55
- const parentResult = parent && resultCache.get(parent);
56
- if (!isTopNode && !parentResult) {
57
- return runQueue();
58
- }
59
- const callbackResult = callback(queueRow, queueOptions);
60
- if (isTopNode && !callbackResult) {
61
- return undefined;
62
- }
63
- const newNode = { ...queueRow, [finalChildrenKey]: undefined };
64
- if (isTopNode) {
65
- result = newNode;
66
- }
67
- resultCache.set(queueRow, callbackResult);
68
- newNodeCache.set(queueRow, newNode);
69
- childrenKeyCache.set(queueRow, finalChildrenKey);
70
- if (callbackResult && parent) {
71
- const parentNewNode = newNodeCache.get(parent);
72
- const parentChildrenKey = childrenKeyCache.get(parent);
73
- if (parentNewNode && parentChildrenKey) {
74
- if (!parentNewNode[parentChildrenKey]) {
75
- parentNewNode[parentChildrenKey] = [];
76
- }
77
- parentNewNode[parentChildrenKey].push(newNode);
78
- }
79
- }
80
- return runQueue();
81
- };
82
- return runQueue();
83
- }
84
- const strategies = { pre: preImpl, post: postImpl, breadth: breadthImpl };
85
- export function treeFilter(tree, callback, options = {}) {
86
- const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
87
- const traversalMethod = strategies[strategy];
88
- const innerOptions = { childrenKey: childrenKey, depth: 0, parents: [], getChildrenKey };
89
- return isArray(tree)
90
- ? tree.map((row) => traversalMethod(row, callback, innerOptions)).filter((t) => !!t)
91
- : traversalMethod(tree, callback, innerOptions) || [];
92
- }
@@ -1,82 +0,0 @@
1
- import { isArray } from "../typeof";
2
- import { getFinalChildrenKey } from "./types";
3
- const strategies = { pre: preImpl, post: postImpl, breadth: breadthImpl };
4
- // 前置深度优先遍历
5
- function preImpl(row, callback, options) {
6
- const callbackResult = callback(row, options);
7
- if (callbackResult) {
8
- return row;
9
- }
10
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
11
- const children = row[finalChildrenKey];
12
- if (isArray(children)) {
13
- for (const child of children) {
14
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
15
- const result = preImpl(child, callback, nextLevelOptions);
16
- if (result) {
17
- return result;
18
- }
19
- }
20
- }
21
- return undefined;
22
- }
23
- // 后置深度优先遍历
24
- function postImpl(row, callback, options) {
25
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
26
- const children = row[finalChildrenKey];
27
- if (isArray(children)) {
28
- for (const child of children) {
29
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
30
- const result = postImpl(child, callback, nextLevelOptions);
31
- if (result) {
32
- return result;
33
- }
34
- }
35
- }
36
- const callbackResult = callback(row, options);
37
- if (callbackResult) {
38
- return row;
39
- }
40
- return undefined;
41
- }
42
- // 广度优先遍历
43
- function breadthImpl(row, callback, options) {
44
- const queue = [{ queueRow: row, queueOptions: options }];
45
- const runQueue = () => {
46
- if (queue.length === 0) {
47
- return undefined;
48
- }
49
- const { queueRow, queueOptions } = queue.shift();
50
- const finalChildrenKey = getFinalChildrenKey(queueRow, queueOptions, queueOptions);
51
- const children = queueRow[finalChildrenKey];
52
- if (isArray(children)) {
53
- const nextLevelOptions = { ...queueOptions, parents: [...queueOptions.parents, queueRow], depth: queueOptions.depth + 1 };
54
- const subQueueItems = children.map((queueRow) => ({ queueRow, queueOptions: nextLevelOptions }));
55
- queue.push(...subQueueItems);
56
- }
57
- const callbackResult = callback(queueRow, queueOptions);
58
- if (callbackResult) {
59
- return queueRow;
60
- }
61
- return runQueue();
62
- };
63
- return runQueue();
64
- }
65
- /**
66
- * 查找树节点,找到第一个返回非空值的节点
67
- */
68
- export function treeFind(tree, callback, options = {}) {
69
- const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
70
- const traversalMethod = strategies[strategy];
71
- const innerOptions = { childrenKey: childrenKey, depth: 0, parents: [], getChildrenKey };
72
- if (isArray(tree)) {
73
- for (const row of tree) {
74
- const result = traversalMethod(row, callback, innerOptions);
75
- if (result) {
76
- return result;
77
- }
78
- }
79
- return undefined;
80
- }
81
- return traversalMethod(tree, callback, innerOptions);
82
- }
@@ -1,60 +0,0 @@
1
- import { isArray } from "../typeof";
2
- import { getFinalChildrenKey } from "./types";
3
- const strategies = { pre: preImpl, post: postImpl, breadth: breadthImpl };
4
- // 前置遍历
5
- function preImpl(row, callback, options) {
6
- callback(row, options);
7
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
8
- const children = row[finalChildrenKey];
9
- if (isArray(children)) {
10
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
11
- for (const child of children) {
12
- preImpl(child, callback, nextLevelOptions);
13
- }
14
- }
15
- }
16
- // 后置遍历
17
- function postImpl(row, callback, options) {
18
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
19
- const children = row[finalChildrenKey];
20
- if (isArray(children)) {
21
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
22
- for (const child of children) {
23
- postImpl(child, callback, nextLevelOptions);
24
- }
25
- }
26
- callback(row, options);
27
- }
28
- // 广度优先遍历
29
- function breadthImpl(row, callback, options) {
30
- const queue = [{ queueRow: row, queueOptions: options }];
31
- const runQueue = () => {
32
- if (queue.length === 0) {
33
- return;
34
- }
35
- const { queueRow, queueOptions } = queue.shift();
36
- const finalChildrenKey = getFinalChildrenKey(queueRow, queueOptions, queueOptions);
37
- const children = queueRow[finalChildrenKey];
38
- if (isArray(children)) {
39
- const nextLevelOptions = { ...queueOptions, parents: [...queueOptions.parents, queueRow], depth: queueOptions.depth + 1 };
40
- const subQueueItems = children.map((queueRow) => ({ queueRow, queueOptions: nextLevelOptions }));
41
- queue.push(...subQueueItems);
42
- }
43
- callback(queueRow, queueOptions);
44
- runQueue();
45
- };
46
- runQueue();
47
- }
48
- export function treeForEach(tree, callback, options = {}) {
49
- const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
50
- const traversalMethod = strategies[strategy];
51
- const innerOptions = { childrenKey: childrenKey, depth: 0, parents: [], getChildrenKey };
52
- if (isArray(tree)) {
53
- for (const row of tree) {
54
- traversalMethod(row, callback, innerOptions);
55
- }
56
- }
57
- else {
58
- traversalMethod(tree, callback, innerOptions);
59
- }
60
- }
@@ -1,79 +0,0 @@
1
- import { arrayLast } from "../array";
2
- import { isArray } from "../typeof";
3
- import { getFinalChildrenKey } from "./types";
4
- const strategies = { pre: preImpl, post: postImpl, breadth: breadthImpl };
5
- // 前置遍历
6
- function preImpl(row, callback, options) {
7
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
8
- const result = callback(row, options);
9
- const children = row[finalChildrenKey];
10
- let newChildren;
11
- if (isArray(children)) {
12
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
13
- newChildren = children.map((c) => preImpl(c, callback, nextLevelOptions));
14
- }
15
- return { ...result, [finalChildrenKey]: newChildren };
16
- }
17
- // 子节点优先遍历
18
- function postImpl(row, callback, options) {
19
- const finalChildrenKey = getFinalChildrenKey(row, options, options);
20
- const children = row[finalChildrenKey];
21
- let newChildren;
22
- if (isArray(children)) {
23
- const nextLevelOptions = { ...options, parents: [...options.parents, row], depth: options.depth + 1 };
24
- newChildren = children.map((c) => postImpl(c, callback, nextLevelOptions));
25
- }
26
- const result = callback(row, options);
27
- return { ...result, [finalChildrenKey]: newChildren };
28
- }
29
- // 广度优先遍历
30
- function breadthImpl(row, callback, options) {
31
- const queue = [{ queueRow: row, queueOptions: options }];
32
- const cache = new WeakMap();
33
- const childrenKeyCache = new WeakMap();
34
- let result;
35
- const runQueue = () => {
36
- if (queue.length === 0) {
37
- return result;
38
- }
39
- const { queueRow, queueOptions } = queue.shift();
40
- const finalChildrenKey = getFinalChildrenKey(queueRow, queueOptions, queueOptions);
41
- const children = queueRow[finalChildrenKey];
42
- if (isArray(children)) {
43
- const nextLevelOptions = { ...queueOptions, parents: [...queueOptions.parents, queueRow], depth: queueOptions.depth + 1 };
44
- const subQueueItems = children.map((queueRow) => ({ queueRow, queueOptions: nextLevelOptions }));
45
- queue.push(...subQueueItems);
46
- }
47
- const res = callback(queueRow, queueOptions);
48
- cache.set(queueRow, res);
49
- childrenKeyCache.set(queueRow, finalChildrenKey);
50
- // breadth 模式的子节点一定晚于父节点执行,所以可以在cache中找到父节点的生成物
51
- const parent = arrayLast(queueOptions.parents);
52
- if (parent) {
53
- const newParent = cache.get(parent);
54
- const parentChildrenKey = childrenKeyCache.get(parent);
55
- if (newParent && parentChildrenKey) {
56
- if (newParent[parentChildrenKey]) {
57
- newParent[parentChildrenKey].push(res);
58
- }
59
- else {
60
- newParent[parentChildrenKey] = [res];
61
- }
62
- }
63
- }
64
- // 这棵树的顶点
65
- if (queueOptions.depth === 0) {
66
- result = res;
67
- }
68
- return runQueue();
69
- };
70
- return runQueue();
71
- }
72
- export function treeMap(tree, callback, options = {}) {
73
- const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
74
- const traversalMethod = strategies[strategy];
75
- const innerOptions = { childrenKey: childrenKey, depth: 0, parents: [], getChildrenKey };
76
- return isArray(tree)
77
- ? tree.map((row) => traversalMethod(row, callback, innerOptions))
78
- : traversalMethod(tree, callback, innerOptions);
79
- }
@@ -1,13 +0,0 @@
1
- import { treeForEach } from "./treeForEach";
2
- /**
3
- * 树结构 转 行结构
4
- */
5
- export function treeToRows(tree, options = {}) {
6
- const { childrenKey = "children" } = options;
7
- const result = [];
8
- if (!tree) {
9
- return result;
10
- }
11
- treeForEach(tree, (t) => result.push({ ...t, [childrenKey]: undefined }), options);
12
- return result;
13
- }
@@ -1,10 +0,0 @@
1
- import { isFunction } from "../typeof";
2
- export function getFinalChildrenKey(tree, meta, options) {
3
- if (isFunction(options.getChildrenKey)) {
4
- const dynamicChildrenKey = options.getChildrenKey(tree, meta);
5
- if (dynamicChildrenKey && dynamicChildrenKey !== null) {
6
- return dynamicChildrenKey;
7
- }
8
- }
9
- return options.childrenKey;
10
- }
@@ -1,114 +0,0 @@
1
- const prototypes = {
2
- string: "[object String]",
3
- number: "[object Number]",
4
- boolean: "[object Boolean]",
5
- object: "[object Object]",
6
- array: "[object Array]",
7
- bigInt: "[object BigInt]",
8
- symbol: "[object Symbol]",
9
- function: "[object Function]",
10
- generatorFunction: "[object GeneratorFunction]",
11
- asyncFunction: "[object AsyncFunction]",
12
- promise: "[object Promise]",
13
- null: "[object Null]",
14
- undefined: "[object Undefined]",
15
- date: "[object Date]",
16
- regExp: "[object RegExp]",
17
- error: "[object Error]",
18
- file: "[object File]",
19
- map: "[object Map]",
20
- weakMap: "[object WeakMap]",
21
- set: "[object Set]",
22
- weakSet: "[object WeakSet]",
23
- window: "[object Window]",
24
- webSocket: "[object WebSocket]",
25
- URLSearchParams: "[object URLSearchParams]",
26
- };
27
- function resolvePrototypeString(value) {
28
- return Object.prototype.toString.call(value);
29
- }
30
- export function isString(value) {
31
- return resolvePrototypeString(value) === prototypes.string;
32
- }
33
- export function isNumber(value) {
34
- return resolvePrototypeString(value) === prototypes.number;
35
- }
36
- export function isBoolean(value) {
37
- return resolvePrototypeString(value) === prototypes.boolean;
38
- }
39
- export function isObject(value) {
40
- return resolvePrototypeString(value) === prototypes.object;
41
- }
42
- export function isArray(value) {
43
- return resolvePrototypeString(value) === prototypes.array;
44
- }
45
- export function isBigInt(value) {
46
- return resolvePrototypeString(value) === prototypes.bigInt;
47
- }
48
- export function isSymbol(value) {
49
- return resolvePrototypeString(value) === prototypes.symbol;
50
- }
51
- export function isFunction(value) {
52
- const prototypeList = [prototypes.function, prototypes.generatorFunction, prototypes.asyncFunction];
53
- return prototypeList.includes(resolvePrototypeString(value));
54
- }
55
- export function isGeneratorFunction(value) {
56
- return resolvePrototypeString(value) === prototypes.generatorFunction;
57
- }
58
- export function isAsyncFunction(value) {
59
- return resolvePrototypeString(value) === prototypes.asyncFunction;
60
- }
61
- export function isPromise(value) {
62
- return resolvePrototypeString(value) === prototypes.promise;
63
- }
64
- export function isPromiseLike(value) {
65
- return isPromise(value) || (isObject(value) && isFunction(value["then"]));
66
- }
67
- export function isNull(value) {
68
- return resolvePrototypeString(value) === prototypes.null;
69
- }
70
- export function isUndefined(value) {
71
- return resolvePrototypeString(value) === prototypes.undefined;
72
- }
73
- export function isDate(value) {
74
- return resolvePrototypeString(value) === prototypes.date;
75
- }
76
- export function isRegExp(value) {
77
- return resolvePrototypeString(value) === prototypes.regExp;
78
- }
79
- export function isError(value) {
80
- return resolvePrototypeString(value) === prototypes.error;
81
- }
82
- export function isFile(value) {
83
- return resolvePrototypeString(value) === prototypes.file;
84
- }
85
- export function isMap(value) {
86
- return resolvePrototypeString(value) === prototypes.map;
87
- }
88
- export function isWeakMap(value) {
89
- return resolvePrototypeString(value) === prototypes.weakMap;
90
- }
91
- export function isSet(value) {
92
- return resolvePrototypeString(value) === prototypes.set;
93
- }
94
- export function isWeakSet(value) {
95
- return resolvePrototypeString(value) === prototypes.weakSet;
96
- }
97
- export function isWindow(value) {
98
- return resolvePrototypeString(value) === prototypes.window;
99
- }
100
- export function isWebSocket(value) {
101
- return resolvePrototypeString(value) === prototypes.webSocket;
102
- }
103
- export function isURLSearchParams(value) {
104
- return resolvePrototypeString(value) === prototypes.URLSearchParams;
105
- }
106
- export function isClass(value) {
107
- return resolvePrototypeString(value).startsWith("class ");
108
- }
109
- export function isInteger(value) {
110
- return Number.isInteger(value);
111
- }
112
- export function isIterable(value) {
113
- return isObject(value) && Symbol.iterator in value;
114
- }