@minto-ai/tools 1.0.1

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/README.md +1335 -0
  2. package/dist/array/chunk-array.d.ts +12 -0
  3. package/dist/array/index.d.ts +2 -0
  4. package/dist/browser/copy-text.d.ts +9 -0
  5. package/dist/browser/index.d.ts +6 -0
  6. package/dist/browser/is-android.d.ts +8 -0
  7. package/dist/browser/is-ios.d.ts +8 -0
  8. package/dist/browser/is-mobile.d.ts +9 -0
  9. package/dist/browser/is-pc.d.ts +8 -0
  10. package/dist/core/__test__/can-be-parsed-as-number.test.d.ts +1 -0
  11. package/dist/core/be-parsed-as-number.d.ts +8 -0
  12. package/dist/core/can-be-parsed-as-number.d.ts +8 -0
  13. package/dist/core/check-array-empty.d.ts +8 -0
  14. package/dist/core/check-empty-not-zero.d.ts +8 -0
  15. package/dist/core/check-empty.d.ts +9 -0
  16. package/dist/core/check-object-empty.d.ts +9 -0
  17. package/dist/core/index.d.ts +13 -0
  18. package/dist/core/is-array.d.ts +8 -0
  19. package/dist/core/is-null-or-undefined.d.ts +7 -0
  20. package/dist/core/is-number.d.ts +8 -0
  21. package/dist/core/is-object.d.ts +8 -0
  22. package/dist/core/is-string.d.ts +8 -0
  23. package/dist/core/is-undefined.d.ts +8 -0
  24. package/dist/file/batch-download-file.d.ts +11 -0
  25. package/dist/file/extends/enum.d.ts +81 -0
  26. package/dist/file/extends/regex.d.ts +3 -0
  27. package/dist/file/get-file-feed-type.d.ts +9 -0
  28. package/dist/file/get-file-icon.d.ts +8 -0
  29. package/dist/file/get-file-item-icon.d.ts +9 -0
  30. package/dist/file/get-file-item-suffix.d.ts +9 -0
  31. package/dist/file/get-file-name.d.ts +8 -0
  32. package/dist/file/get-file-suffix-icon.d.ts +9 -0
  33. package/dist/file/get-file-suffix.d.ts +9 -0
  34. package/dist/file/get-file-title.d.ts +8 -0
  35. package/dist/file/index.d.ts +19 -0
  36. package/dist/file/is-document-file-path.d.ts +8 -0
  37. package/dist/file/is-file-path.d.ts +8 -0
  38. package/dist/file/is-image-file-path.d.ts +8 -0
  39. package/dist/file/is-ppt-file-path.d.ts +8 -0
  40. package/dist/file/is-video-file-path.d.ts +8 -0
  41. package/dist/file/single-download-file.d.ts +8 -0
  42. package/dist/file/types/index.d.ts +18 -0
  43. package/dist/function/debounce.d.ts +23 -0
  44. package/dist/function/index.d.ts +3 -0
  45. package/dist/function/throttle.d.ts +23 -0
  46. package/dist/index.d.ts +11 -0
  47. package/dist/index.js +547 -0
  48. package/dist/math/__test__/add.test.d.ts +1 -0
  49. package/dist/math/__test__/divide.test.d.ts +1 -0
  50. package/dist/math/__test__/get-decimal-places.test.d.ts +1 -0
  51. package/dist/math/__test__/multiply.test.d.ts +1 -0
  52. package/dist/math/__test__/subtract.test.d.ts +1 -0
  53. package/dist/math/add.d.ts +9 -0
  54. package/dist/math/divide.d.ts +9 -0
  55. package/dist/math/get-decimal-places.d.ts +8 -0
  56. package/dist/math/index.d.ts +6 -0
  57. package/dist/math/multiply.d.ts +9 -0
  58. package/dist/math/subtract.d.ts +9 -0
  59. package/dist/object/deep-freeze.d.ts +9 -0
  60. package/dist/object/index.d.ts +3 -0
  61. package/dist/object/pick-object.d.ts +9 -0
  62. package/dist/string/__test__/chunk-string.test.d.ts +1 -0
  63. package/dist/string/chunk-string.d.ts +10 -0
  64. package/dist/string/index.d.ts +2 -0
  65. package/dist/supply/get-uuid.d.ts +9 -0
  66. package/dist/supply/index.d.ts +2 -0
  67. package/dist/web-socket/create-web-socket.d.ts +9 -0
  68. package/dist/web-socket/index.d.ts +3 -0
  69. package/dist/web-socket/is-web-socket-supported.d.ts +9 -0
  70. package/dist/wrker/close-worker.d.ts +9 -0
  71. package/dist/wrker/create-worker.d.ts +11 -0
  72. package/dist/wrker/index.d.ts +3 -0
  73. package/package.json +32 -0
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 将一个数组分割成多个指定大小的块。
3
+ * 这个函数接受一个数组和一个指定的块大小,然后返回一个二维数组。
4
+ * 每个子数组包含原数组中的一部分元素,大小由 `chunkSize` 参数决定。
5
+ * 如果数组的长度不是 `chunkSize` 的整数倍,最后一个块可能包含的元素少于 `chunkSize`。
6
+ *
7
+ * @param array 要分割的源数组。
8
+ * @param chunkSize 每个块的大小。必须为正整数。默认值为 1。
9
+ * @returns 返回一个二维数组,每个子数组包含原数组的一部分元素。
10
+ */
11
+ declare function chunkArray<T>(array: T[], chunkSize?: number): T[][];
12
+ export default chunkArray;
@@ -0,0 +1,2 @@
1
+ import { default as chunkArray } from './chunk-array';
2
+ export { chunkArray };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 复制文本到剪贴板的函数。
3
+ * 如果复制成功,返回一个包含被复制文本的 Promise;如果失败,返回一个包含错误信息的 Promise。
4
+ *
5
+ * @param text 需要复制的文本内容。
6
+ * @returns 返回一个 Promise 对象。成功时返回被复制的文本,失败时返回错误信息。
7
+ */
8
+ declare function copyText(text: string): Promise<string>;
9
+ export default copyText;
@@ -0,0 +1,6 @@
1
+ import { default as copyText } from './copy-text';
2
+ import { default as isAndroid } from './is-android';
3
+ import { default as isIos } from './is-ios';
4
+ import { default as isMobile } from './is-mobile';
5
+ import { default as isPc } from './is-pc';
6
+ export { copyText, isIos, isMobile, isPc, isAndroid };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前设备是否为 Android 设备
3
+ * 通过检测用户代理字符串中是否包含 "android" 关键字来判断。
4
+ *
5
+ * @returns 如果是 Android 设备,返回 true;否则返回 false。
6
+ */
7
+ declare function isAndroid(): boolean;
8
+ export default isAndroid;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前设备是否为iOS设备
3
+ * 主要检测的设备类型包括 iPhone、iPad 和 iPod。
4
+ *
5
+ * @returns 如果是iOS设备,返回true;否则返回false。
6
+ */
7
+ declare function isIos(): boolean;
8
+ export default isIos;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 判断当前设备是否为移动设备(手机或平板)。
3
+ * 通过检测设备是否为 Android 或 iOS 设备来判断是否为移动设备。
4
+ * 如果设备是 Android 或 iOS 设备,则认为是移动设备。
5
+ *
6
+ * @returns 如果是移动设备,返回 true;否则返回 false。
7
+ */
8
+ declare function isMobile(): boolean;
9
+ export default isMobile;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前设备是否为桌面设备(PC)。
3
+ * 如果当前设备不是移动设备(手机或平板),则认为是桌面设备。
4
+ *
5
+ * @returns 如果是桌面设备,返回 true;否则返回 false。
6
+ */
7
+ declare function isPc(): boolean;
8
+ export default isPc;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 将输入值转换为数字类型。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 转换后的数字值,如果无法解析则返回 `NaN`。
6
+ */
7
+ declare function beParsedAsNumber(value: never): number;
8
+ export default beParsedAsNumber;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查一个值是否可以被解析为有效的数字。
3
+ *
4
+ * @param value 需要检查的值
5
+ * @returns 如果值可以被解析为数字,则返回 true;否则返回 false
6
+ */
7
+ declare function canBeParsedAsNumber(value: unknown): boolean;
8
+ export default canBeParsedAsNumber;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查数组是否为空
3
+ *
4
+ * @param value 要检查的值。
5
+ * @returns 如果 value 是一个数组并且长度为0返回 true,否则返回false
6
+ */
7
+ declare function checkArrayEmpty(value: unknown): value is Array<unknown>;
8
+ export default checkArrayEmpty;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查给定的值是否为空,但不包括数字 0。空值包括:空字符串、空数组、空对象、null 或 undefined。
3
+ *
4
+ * @param value 要检查的值。
5
+ * @returns 如果值是空的,且不是数字 0,则返回 true,否则返回 false。
6
+ */
7
+ declare function checkEmptyNotZero(value: unknown): value is null | undefined | '' | [] | Record<string, never>;
8
+ export default checkEmptyNotZero;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 检查给定的值是否为空。
3
+ * 空值包括:空字符串、空数组、空对象、null 或 undefined。
4
+ *
5
+ * @param value 要检查的值。
6
+ * @returns 如果值是空的,则返回 true,否则返回 false。
7
+ */
8
+ declare function checkEmpty(value: unknown): value is null | undefined | '' | [] | Record<string, never> | 0;
9
+ export default checkEmpty;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 检查对象是否为空。
3
+ * 一个空对象是指没有任何自身属性的对象。
4
+ *
5
+ * @param value 要检查的值。
6
+ * @returns 如果值是一个空对象,则返回 true,否则返回 false。
7
+ */
8
+ declare function checkObjectEmpty(value: unknown): value is Record<string, never>;
9
+ export default checkObjectEmpty;
@@ -0,0 +1,13 @@
1
+ import { default as beParsedAsNumber } from './be-parsed-as-number';
2
+ import { default as canBeParsedAsNumber } from './can-be-parsed-as-number';
3
+ import { default as checkArrayEmpty } from './check-array-empty';
4
+ import { default as checkEmpty } from './check-empty';
5
+ import { default as checkEmptyNotZero } from './check-empty-not-zero';
6
+ import { default as checkObjectEmpty } from './check-object-empty';
7
+ import { default as isArray } from './is-array';
8
+ import { default as isNullOrUndefined } from './is-null-or-undefined';
9
+ import { default as isNumber } from './is-number';
10
+ import { default as isObject } from './is-object';
11
+ import { default as isString } from './is-string';
12
+ import { default as isUndefined } from './is-undefined';
13
+ export { checkArrayEmpty, checkEmpty, checkEmptyNotZero, checkObjectEmpty, isArray, isNumber, isObject, isString, canBeParsedAsNumber, isUndefined, isNullOrUndefined, beParsedAsNumber };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断给定的值是否是一个数组。
3
+ *
4
+ * @param value 要检查的值。
5
+ * @returns 如果 value 是一个数组,则返回 true,否则返回 false。
6
+ */
7
+ declare function isArray(value: unknown): value is Array<unknown>;
8
+ export default isArray;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 检查一个值是否为 null 或 undefined。
3
+ * @param value - 要检查的值。
4
+ * @returns 如果值为 null 或 undefined,则返回 true;否则返回 false。
5
+ */
6
+ declare function isNullOrUndefined(value: unknown): value is null | undefined;
7
+ export default isNullOrUndefined;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断给定的值是否是一个数字。
3
+ *
4
+ * @param value 要检查的值。
5
+ * @returns 如果 value 是一个数字,则返回 true,否则返回 false。
6
+ */
7
+ declare function isNumber(value: unknown): value is number;
8
+ export default isNumber;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断给定的值是否是一个对象。但对象的值包含 null 的情况,返回 false。
3
+ *
4
+ * @param value 要检查的值。
5
+ * @returns 如果 value 是一个普通对象,则返回 true,否则返回 false。
6
+ */
7
+ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>;
8
+ export default isObject;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断给定的值是否是一个字符串。
3
+ *
4
+ * @param value 要检查的值。
5
+ * @returns 如果 value 是一个字符串,则返回 true,否则返回 false。
6
+ */
7
+ declare function isString(value: unknown): value is string;
8
+ export default isString;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查一个值是否为 undefined。
3
+ *
4
+ * @param value 需要检查的值。
5
+ * @returns 如果值为 undefined,则返回 true;否则返回 false。
6
+ */
7
+ declare function isUndefined(value: unknown): value is undefined;
8
+ export default isUndefined;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 批量下载文件并打包为 ZIP
3
+ *
4
+ * @param fileList 文件列表,包含文件路径和文件名
5
+ * @param zipName 打包后的 ZIP 文件名
6
+ */
7
+ declare function batchDownloadFile(fileList: Array<{
8
+ filePath: string;
9
+ fileName?: string;
10
+ }>, zipName: string): Promise<void>;
11
+ export default batchDownloadFile;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 文件后缀类型枚举
3
+ */
4
+ declare const FileSuffixEnum: {
5
+ readonly DOC: "doc";
6
+ readonly DOCX: "docx";
7
+ readonly PDF: "pdf";
8
+ readonly PPT: "ppt";
9
+ readonly PPTX: "pptx";
10
+ readonly XLS: "xls";
11
+ readonly XLSX: "xlsx";
12
+ readonly JPG: "jpg";
13
+ readonly PNG: "png";
14
+ readonly JPEG: "jpeg";
15
+ readonly WEBP: "webp";
16
+ readonly GIF: "gif";
17
+ readonly MP4: "mp4";
18
+ readonly AVI: "avi";
19
+ readonly FLV: "flv";
20
+ readonly MKV: "mkv";
21
+ readonly MP3: "mp3";
22
+ readonly WAV: "wav";
23
+ readonly TXT: "txt";
24
+ readonly HTML: "html";
25
+ readonly NULL: "";
26
+ };
27
+ /**
28
+ * 图片后缀类型枚举
29
+ */
30
+ declare const ImageFileSuffixEnum: {
31
+ readonly JPG: "jpg";
32
+ readonly PNG: "png";
33
+ readonly GIF: "gif";
34
+ readonly JPEG: "jpeg";
35
+ readonly WEBP: "webp";
36
+ };
37
+ /**
38
+ * 视频文件后缀类型枚举
39
+ */
40
+ declare const VideoFileSuffixEnum: {
41
+ readonly MP4: "mp4";
42
+ readonly AVI: "avi";
43
+ readonly FLV: "flv";
44
+ readonly MKV: "mkv";
45
+ };
46
+ /**
47
+ * PPT文件后缀类型枚举
48
+ */
49
+ declare const PptFileSuffixEnum: {
50
+ readonly PPT: "ppt";
51
+ readonly PPTX: "pptx";
52
+ };
53
+ /**
54
+ * 文档文件后缀类型枚举
55
+ */
56
+ declare const DocumentFileSuffixEnum: {
57
+ readonly DOC: "doc";
58
+ readonly DOCX: "docx";
59
+ readonly PDF: "pdf";
60
+ readonly TXT: "txt";
61
+ readonly XLS: "xls";
62
+ readonly XLSX: "xlsx";
63
+ };
64
+ /**
65
+ * feedType类型枚举
66
+ */
67
+ declare const FileItemFeedTypeEnum: {
68
+ readonly ALL: "";
69
+ readonly DOCUMENT: 0;
70
+ readonly TEXT: 1;
71
+ readonly IMG: 2;
72
+ readonly VIDEO: 3;
73
+ readonly PPT: 4;
74
+ readonly QA: 5;
75
+ readonly AUDIO: 6;
76
+ readonly MUSIC: 7;
77
+ readonly AUTOHTML: 8;
78
+ readonly TWEET: 9;
79
+ readonly COMIC_STRIP: 10;
80
+ };
81
+ export { FileSuffixEnum, FileItemFeedTypeEnum, ImageFileSuffixEnum, VideoFileSuffixEnum, PptFileSuffixEnum, DocumentFileSuffixEnum };
@@ -0,0 +1,3 @@
1
+ declare const fileSuffixRegex: RegExp;
2
+ declare const fileNameRegex: RegExp;
3
+ export { fileSuffixRegex, fileNameRegex };
@@ -0,0 +1,9 @@
1
+ import { FileItemFeedType } from './types';
2
+ /**
3
+ * 根据文件路径获取文件类型
4
+ *
5
+ * @param filePath 文件路径
6
+ * @returns 文件类型(FileItemFeedTypeEnum)或 undefined(如果无法识别)
7
+ */
8
+ declare function getFileFeedType(filePath: string): FileItemFeedType | undefined;
9
+ export default getFileFeedType;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 根据文件路径获取对应的图标
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 图标路径
6
+ */
7
+ declare function getFileIcon(filePath: string): string;
8
+ export default getFileIcon;
@@ -0,0 +1,9 @@
1
+ import { IFileItem } from './types';
2
+ /**
3
+ * 根据文件的后缀文件类型获取文件类型图标
4
+ *
5
+ * @param fileItem 文件实例
6
+ * @returns 文件图标
7
+ */
8
+ declare function getFileItemIcon(fileItem: IFileItem): string;
9
+ export default getFileItemIcon;
@@ -0,0 +1,9 @@
1
+ import { FileSuffix, IFileItem } from './types';
2
+ /**
3
+ * 获取文件类型后缀,内部包含各种逻辑,可直接调用和修改
4
+ *
5
+ * @param fileItem 文件实例
6
+ * @returns 文件类型后缀
7
+ */
8
+ declare function getFileItemSuffix(fileItem: IFileItem): FileSuffix;
9
+ export default getFileItemSuffix;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 获取完整的文件名(包含后缀)
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 完整的文件名
6
+ */
7
+ declare function getFileName(filePath: string): string;
8
+ export default getFileName;
@@ -0,0 +1,9 @@
1
+ import { FileSuffix } from './types';
2
+ /**
3
+ * 根据文件后缀获取对应的图标
4
+ *
5
+ * @param fileSuffix 文件后缀(需为 FileSuffixEnum 中的有效值)
6
+ * @returns 对应的图标路径,若未匹配则返回默认图标
7
+ */
8
+ declare function getFileSuffixIcon(fileSuffix: FileSuffix): string;
9
+ export default getFileSuffixIcon;
@@ -0,0 +1,9 @@
1
+ import { FileSuffix } from './types';
2
+ /**
3
+ * 获取文件后缀
4
+ *
5
+ * @param filePath 文件路径或文件名
6
+ * @returns 文件后缀
7
+ */
8
+ declare function getFileSuffix(filePath: string): FileSuffix;
9
+ export default getFileSuffix;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 获取文件名(不包含后缀)
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 文件名(不包含后缀)
6
+ */
7
+ declare function getFileTitle(filePath: string): string;
8
+ export default getFileTitle;
@@ -0,0 +1,19 @@
1
+ import { default as batchDownloadFile } from './batch-download-file';
2
+ import { FileSuffixEnum, FileItemFeedTypeEnum, ImageFileSuffixEnum } from './extends/enum';
3
+ import { default as getFileFeedType } from './get-file-feed-type';
4
+ import { default as getFileIcon } from './get-file-icon';
5
+ import { default as getFileSuffixIcon } from './get-file-suffix-icon';
6
+ import { default as getFileItemIcon } from './get-file-item-icon';
7
+ import { default as getFileItemSuffix } from './get-file-item-suffix';
8
+ import { default as getFileName } from './get-file-name';
9
+ import { default as getFileSuffix } from './get-file-suffix';
10
+ import { default as getFileTitle } from './get-file-title';
11
+ import { default as isDocumentFilePath } from './is-document-file-path';
12
+ import { default as isFilePath } from './is-file-path';
13
+ import { default as isImageFilePath } from './is-image-file-path';
14
+ import { default as isPptFilePath } from './is-ppt-file-path';
15
+ import { default as isVideoFilePath } from './is-video-file-path';
16
+ import { default as singleDownloadFile } from './single-download-file';
17
+ import { IFileItem, FileSuffix, FileItemFeedType, ImageFileSuffix, VideoFileSuffix, PptFileSuffix, DocumentFileSuffix } from './types';
18
+ export type { IFileItem, FileSuffix, FileItemFeedType, ImageFileSuffix, VideoFileSuffix, PptFileSuffix, DocumentFileSuffix };
19
+ export { getFileName, getFileTitle, getFileSuffix, isFilePath, getFileIcon, getFileItemIcon, getFileSuffixIcon, getFileItemSuffix, singleDownloadFile, batchDownloadFile, FileSuffixEnum, FileItemFeedTypeEnum, ImageFileSuffixEnum, getFileFeedType, isImageFilePath, isVideoFilePath, isDocumentFilePath, isPptFilePath };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的文档文件路径(包含doc、docx、pdf、txt、xls、xlsx)
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 是否是有效的文档文件路径
6
+ */
7
+ declare function isDocumentFilePath(filePath: string): boolean;
8
+ export default isDocumentFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的文件路径
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 是否是有效的文件路径
6
+ */
7
+ declare function isFilePath(filePath: string): boolean;
8
+ export default isFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的图片文件路径(包含jpg、jpeg、png、webp)
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 是否是有效的图片文件路径
6
+ */
7
+ declare function isImageFilePath(filePath: string): boolean;
8
+ export default isImageFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的ppt文件路径(包含ppt、pptx)
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 是否是有效的ppt文件路径
6
+ */
7
+ declare function isPptFilePath(filePath: string): boolean;
8
+ export default isPptFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的视频文件路径(包含mp4、avi、flv、mkv)
3
+ *
4
+ * @param filePath 文件路径
5
+ * @returns 是否是有效的视频文件路径
6
+ */
7
+ declare function isVideoFilePath(filePath: string): boolean;
8
+ export default isVideoFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 下载单个文件
3
+ *
4
+ * @param filePath 文件路径(必须)
5
+ * @param fileName 下载时保存的文件名(可选)
6
+ */
7
+ declare function singleDownloadFile(filePath: string, fileName?: string): Promise<void>;
8
+ export default singleDownloadFile;
@@ -0,0 +1,18 @@
1
+ import { FileSuffixEnum, FileItemFeedTypeEnum, ImageFileSuffixEnum, VideoFileSuffixEnum, PptFileSuffixEnum, DocumentFileSuffixEnum } from '../extends/enum';
2
+ type FileSuffix = (typeof FileSuffixEnum)[keyof typeof FileSuffixEnum];
3
+ type ImageFileSuffix = (typeof ImageFileSuffixEnum)[keyof typeof ImageFileSuffixEnum];
4
+ type VideoFileSuffix = (typeof VideoFileSuffixEnum)[keyof typeof VideoFileSuffixEnum];
5
+ type PptFileSuffix = (typeof PptFileSuffixEnum)[keyof typeof PptFileSuffixEnum];
6
+ type DocumentFileSuffix = (typeof DocumentFileSuffixEnum)[keyof typeof DocumentFileSuffixEnum];
7
+ type FileItemFeedType = (typeof FileItemFeedTypeEnum)[keyof typeof FileItemFeedTypeEnum];
8
+ /**
9
+ * 明塗内部文件对象
10
+ */
11
+ interface IFileItem {
12
+ title: string;
13
+ viewUrl?: string;
14
+ previewUrl?: string;
15
+ createTime?: string;
16
+ feedType?: FileItemFeedType;
17
+ }
18
+ export type { IFileItem, FileSuffix, FileItemFeedType, ImageFileSuffix, VideoFileSuffix, PptFileSuffix, DocumentFileSuffix };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 防抖函数的类型定义
3
+ * @template T - 原始函数的类型
4
+ */
5
+ type DebouncedFunction<T extends (...args: any[]) => any> = {
6
+ /**
7
+ * 防抖后的函数,参数类型与原函数一致
8
+ */
9
+ (...args: Parameters<T>): void;
10
+ /**
11
+ * 取消防抖函数的未执行部分
12
+ */
13
+ cancel: () => void;
14
+ };
15
+ /**
16
+ * 创建一个防抖函数。
17
+ * 防抖函数的作用是限制一个函数在短时间内频繁触发的次数,直到指定的延迟时间结束后才执行。
18
+ * @param {T} callback - 需要防抖的函数
19
+ * @param {number} delay - 防抖的延迟时间(毫秒)
20
+ * @returns {DebouncedFunction<T>} 防抖后的函数,包含原函数的参数类型和取消方法
21
+ */
22
+ declare function debounce<T extends (...args: any[]) => any>(callback: T, delay: number): DebouncedFunction<T>;
23
+ export default debounce;
@@ -0,0 +1,3 @@
1
+ import { default as debounce } from './debounce';
2
+ import { default as throttle } from './throttle';
3
+ export { throttle, debounce };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 节流函数的类型定义
3
+ * @template T - 原始函数的类型
4
+ */
5
+ type ThrottledFunction<T extends (...args: any[]) => any> = {
6
+ /**
7
+ * 节流后的函数,参数类型与原函数一致
8
+ */
9
+ (...args: Parameters<T>): void;
10
+ /**
11
+ * 取消节流函数的未执行部分
12
+ */
13
+ cancel: () => void;
14
+ };
15
+ /**
16
+ * 创建一个节流函数。
17
+ * 节流函数的作用是限制一个函数在一定时间内最多执行一次,避免高频触发导致的性能问题。
18
+ * @param {T} callback - 需要节流的函数
19
+ * @param {number} delay - 节流的时间间隔(毫秒)
20
+ * @returns {ThrottledFunction<T>} 节流后的函数,包含原函数的参数类型和取消方法
21
+ */
22
+ declare function throttle<T extends (...args: any[]) => any>(callback: T, delay: number): ThrottledFunction<T>;
23
+ export default throttle;
@@ -0,0 +1,11 @@
1
+ export * from './array';
2
+ export * from './browser';
3
+ export * from './core';
4
+ export * from './object';
5
+ export * from './supply';
6
+ export * from './web-socket';
7
+ export * from './wrker';
8
+ export * from './file';
9
+ export * from './function';
10
+ export * from './math';
11
+ export * from './string';