@aomex/internal-tools 0.0.27
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 geekact
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { default as chalk } from 'chalk';
|
|
2
|
+
export { default as bytes } from 'bytes';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 返回数组,如果传入非数组,则会包装成只有一个元素的数组
|
|
6
|
+
* @param data 非数组或者数组
|
|
7
|
+
* @param unique 是否需要去重。默认:`false`
|
|
8
|
+
*/
|
|
9
|
+
declare function toArray<T>(data: T | readonly T[], unique?: boolean): T[];
|
|
10
|
+
declare function toArray<T>(data: T | T[], unique?: boolean): T[];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 等待指定的时间后再往下执行
|
|
14
|
+
*/
|
|
15
|
+
declare const sleep: (durationMS: number) => Promise<void>;
|
|
16
|
+
|
|
17
|
+
type NonReadonly<T extends object> = {
|
|
18
|
+
-readonly [K in keyof T]: T[K];
|
|
19
|
+
};
|
|
20
|
+
type Union2Intersection<T> = (T extends any ? (arg: T) => void : never) extends (arg: infer P) => void ? P : never;
|
|
21
|
+
|
|
22
|
+
export { NonReadonly, Union2Intersection, sleep, toArray };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/to-array.ts
|
|
2
|
+
function toArray(data, unique = false) {
|
|
3
|
+
return Array.isArray(data) ? unique ? [...new Set(data)] : data : [data];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/sleep.ts
|
|
7
|
+
var sleep = (durationMS) => durationMS <= 0 ? Promise.resolve(void 0) : new Promise((resolve) => {
|
|
8
|
+
setTimeout(resolve, durationMS);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// src/index.ts
|
|
12
|
+
import { default as default2 } from "chalk";
|
|
13
|
+
import { default as default3 } from "bytes";
|
|
14
|
+
export {
|
|
15
|
+
default3 as bytes,
|
|
16
|
+
default2 as chalk,
|
|
17
|
+
sleep,
|
|
18
|
+
toArray
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/to-array.ts","../src/sleep.ts","../src/index.ts"],"sourcesContent":["/**\n * 返回数组,如果传入非数组,则会包装成只有一个元素的数组\n * @param data 非数组或者数组\n * @param unique 是否需要去重。默认:`false`\n */\nexport function toArray<T>(data: T | readonly T[], unique?: boolean): T[];\nexport function toArray<T>(data: T | T[], unique?: boolean): T[];\nexport function toArray<T>(data: T | T[], unique: boolean = false): T[] {\n return Array.isArray(data) ? (unique ? [...new Set(data)] : data) : [data];\n}\n","/**\n * 等待指定的时间后再往下执行\n */\nexport const sleep = (durationMS: number): Promise<void> =>\n durationMS <= 0\n ? Promise.resolve(void 0)\n : new Promise((resolve) => {\n setTimeout(resolve, durationMS);\n });\n","export * from './to-array';\nexport * from './sleep';\nexport * from './type';\nexport { default as chalk } from 'chalk';\nexport { default as bytes } from 'bytes';\n"],"mappings":";AAOO,SAAS,QAAW,MAAe,SAAkB,OAAY;AACtE,SAAO,MAAM,QAAQ,IAAI,IAAK,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,OAAQ,CAAC,IAAI;AAC3E;;;ACNO,IAAM,QAAQ,CAAC,eACpB,cAAc,IACV,QAAQ,QAAQ,MAAM,IACtB,IAAI,QAAQ,CAAC,YAAY;AACvB,aAAW,SAAS,UAAU;AAChC,CAAC;;;ACLP,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,gBAAwB;","names":["default"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aomex/internal-tools",
|
|
3
|
+
"version": "0.0.27",
|
|
4
|
+
"description": "实用工具",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"package.json",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [],
|
|
25
|
+
"repository": "git@github.com:aomex/aomex.git",
|
|
26
|
+
"homepage": "https://aomex.js.org",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@types/bytes": "^3.1.4",
|
|
30
|
+
"bytes": "^3.1.2",
|
|
31
|
+
"chalk": "^5.3.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "vitest"
|
|
35
|
+
}
|
|
36
|
+
}
|