@aomex/internal-tools 3.29.0 → 3.29.2
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 +19 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.29.2](https://github.com/aomex/aomex/compare/v3.29.1...v3.29.2) (2025-08-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aomex/internal-tools
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.29.1](https://github.com/aomex/aomex/compare/v3.29.0...v3.29.1) (2025-07-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **tools:** sleep指定时间超过最大值时会立刻执行 ([7c0b771](https://github.com/aomex/aomex/commit/7c0b771b04037fcfde6d262fb4bde433b8d59429))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [3.29.0](https://github.com/aomex/aomex/compare/v3.28.3...v3.29.0) (2025-07-17)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @aomex/internal-tools
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,14 @@ function toArray(data, unique = false) {
|
|
|
5
5
|
|
|
6
6
|
// src/sleep.ts
|
|
7
7
|
import timers from "timers/promises";
|
|
8
|
-
var
|
|
9
|
-
|
|
8
|
+
var MAX_DURATION = 2147483647;
|
|
9
|
+
var sleep = async (durationMS) => {
|
|
10
|
+
if (durationMS <= 0) return;
|
|
11
|
+
if (durationMS <= MAX_DURATION) return timers.setTimeout(durationMS);
|
|
12
|
+
do {
|
|
13
|
+
await timers.setTimeout(durationMS > MAX_DURATION ? MAX_DURATION : durationMS);
|
|
14
|
+
durationMS -= MAX_DURATION;
|
|
15
|
+
} while (durationMS > 0);
|
|
10
16
|
};
|
|
11
17
|
|
|
12
18
|
// src/index.ts
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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","import timers from 'node:timers/promises';\n\n/**\n * 等待指定的时间(毫秒)后再往下执行\n */\nexport const sleep = (durationMS: number): Promise<void> => {\n
|
|
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","import timers from 'node:timers/promises';\n\n// TimeoutOverflowWarning: 2147483648 does not fit into a 32-bit signed integer. Timeout duration was set to 1.\n// setTimeout最大执行时间:2^31 - 1\nconst MAX_DURATION = 2147483647;\n\n/**\n * 等待指定的时间(毫秒)后再往下执行\n */\nexport const sleep = async (durationMS: number): Promise<void> => {\n if (durationMS <= 0) return;\n if (durationMS <= MAX_DURATION) return timers.setTimeout(durationMS);\n do {\n await timers.setTimeout(durationMS > MAX_DURATION ? MAX_DURATION : durationMS);\n durationMS -= MAX_DURATION;\n } while (durationMS > 0);\n};\n","export * from './to-array';\nexport * from './sleep';\nexport * from './type';\nexport { default as bytes } from 'bytes';\nexport { OpenAPIV3 as OpenAPI } from 'openapi-types';\nexport * from '@i18nx/node';\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;;;ACTA,OAAO,YAAY;AAInB,IAAM,eAAe;AAKd,IAAM,QAAQ,OAAO,eAAsC;AAChE,MAAI,cAAc,EAAG;AACrB,MAAI,cAAc,aAAc,QAAO,OAAO,WAAW,UAAU;AACnE,KAAG;AACD,UAAM,OAAO,WAAW,aAAa,eAAe,eAAe,UAAU;AAC7E,kBAAc;AAAA,EAChB,SAAS,aAAa;AACxB;;;ACbA,SAAoB,WAAXA,gBAAwB;AACjC,SAAsB,iBAAe;AACrC,cAAc;","names":["default"]}
|