@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.
- package/README.md +1335 -0
- package/dist/array/chunk-array.d.ts +12 -0
- package/dist/array/index.d.ts +2 -0
- package/dist/browser/copy-text.d.ts +9 -0
- package/dist/browser/index.d.ts +6 -0
- package/dist/browser/is-android.d.ts +8 -0
- package/dist/browser/is-ios.d.ts +8 -0
- package/dist/browser/is-mobile.d.ts +9 -0
- package/dist/browser/is-pc.d.ts +8 -0
- package/dist/core/__test__/can-be-parsed-as-number.test.d.ts +1 -0
- package/dist/core/be-parsed-as-number.d.ts +8 -0
- package/dist/core/can-be-parsed-as-number.d.ts +8 -0
- package/dist/core/check-array-empty.d.ts +8 -0
- package/dist/core/check-empty-not-zero.d.ts +8 -0
- package/dist/core/check-empty.d.ts +9 -0
- package/dist/core/check-object-empty.d.ts +9 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/is-array.d.ts +8 -0
- package/dist/core/is-null-or-undefined.d.ts +7 -0
- package/dist/core/is-number.d.ts +8 -0
- package/dist/core/is-object.d.ts +8 -0
- package/dist/core/is-string.d.ts +8 -0
- package/dist/core/is-undefined.d.ts +8 -0
- package/dist/file/batch-download-file.d.ts +11 -0
- package/dist/file/extends/enum.d.ts +81 -0
- package/dist/file/extends/regex.d.ts +3 -0
- package/dist/file/get-file-feed-type.d.ts +9 -0
- package/dist/file/get-file-icon.d.ts +8 -0
- package/dist/file/get-file-item-icon.d.ts +9 -0
- package/dist/file/get-file-item-suffix.d.ts +9 -0
- package/dist/file/get-file-name.d.ts +8 -0
- package/dist/file/get-file-suffix-icon.d.ts +9 -0
- package/dist/file/get-file-suffix.d.ts +9 -0
- package/dist/file/get-file-title.d.ts +8 -0
- package/dist/file/index.d.ts +19 -0
- package/dist/file/is-document-file-path.d.ts +8 -0
- package/dist/file/is-file-path.d.ts +8 -0
- package/dist/file/is-image-file-path.d.ts +8 -0
- package/dist/file/is-ppt-file-path.d.ts +8 -0
- package/dist/file/is-video-file-path.d.ts +8 -0
- package/dist/file/single-download-file.d.ts +8 -0
- package/dist/file/types/index.d.ts +18 -0
- package/dist/function/debounce.d.ts +23 -0
- package/dist/function/index.d.ts +3 -0
- package/dist/function/throttle.d.ts +23 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +547 -0
- package/dist/math/__test__/add.test.d.ts +1 -0
- package/dist/math/__test__/divide.test.d.ts +1 -0
- package/dist/math/__test__/get-decimal-places.test.d.ts +1 -0
- package/dist/math/__test__/multiply.test.d.ts +1 -0
- package/dist/math/__test__/subtract.test.d.ts +1 -0
- package/dist/math/add.d.ts +9 -0
- package/dist/math/divide.d.ts +9 -0
- package/dist/math/get-decimal-places.d.ts +8 -0
- package/dist/math/index.d.ts +6 -0
- package/dist/math/multiply.d.ts +9 -0
- package/dist/math/subtract.d.ts +9 -0
- package/dist/object/deep-freeze.d.ts +9 -0
- package/dist/object/index.d.ts +3 -0
- package/dist/object/pick-object.d.ts +9 -0
- package/dist/string/__test__/chunk-string.test.d.ts +1 -0
- package/dist/string/chunk-string.d.ts +10 -0
- package/dist/string/index.d.ts +2 -0
- package/dist/supply/get-uuid.d.ts +9 -0
- package/dist/supply/index.d.ts +2 -0
- package/dist/web-socket/create-web-socket.d.ts +9 -0
- package/dist/web-socket/index.d.ts +3 -0
- package/dist/web-socket/is-web-socket-supported.d.ts +9 -0
- package/dist/wrker/close-worker.d.ts +9 -0
- package/dist/wrker/create-worker.d.ts +11 -0
- package/dist/wrker/index.d.ts +3 -0
- 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,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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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,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,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,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,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,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;
|
package/dist/index.d.ts
ADDED
|
@@ -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';
|