@tb-dev/utils 7.1.1 → 7.2.0
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/dist/index.js +5 -1
- package/dist/promise/index.d.ts +1 -0
- package/dist/promise/timeout.d.ts +1 -0
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -87,6 +87,10 @@ function sleep(ms) {
|
|
|
87
87
|
return new Promise((resolve) => void setTimeout(resolve, ms));
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function timeout(f, ms) {
|
|
91
|
+
return Promise.race([f(), sleep(ms).then(() => null)]);
|
|
92
|
+
}
|
|
93
|
+
|
|
90
94
|
function splitWhitespace(value, options = {}) {
|
|
91
95
|
if (value) {
|
|
92
96
|
if (Array.isArray(value)) {
|
|
@@ -104,4 +108,4 @@ function toPixel(value) {
|
|
|
104
108
|
return value;
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
export { PromiseSet, flushPromises, isNil, noop, panic, sleep, splitWhitespace, toArray, toPixel, todo, trimArray, unimplemented, unreachable, unwrap, unwrapOr, unwrapOrElse, upsert };
|
|
111
|
+
export { PromiseSet, flushPromises, isNil, noop, panic, sleep, splitWhitespace, timeout, toArray, toPixel, todo, trimArray, unimplemented, unreachable, unwrap, unwrapOr, unwrapOrElse, upsert };
|
package/dist/promise/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function timeout<T>(f: () => Promise<T>, ms: number): Promise<T | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/utils",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "TypeScript utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"typescript"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tb-dev/eslint-config": "^8.2.
|
|
28
|
-
"@types/node": "^25.0
|
|
29
|
-
"@vitest/ui": "^4.0.
|
|
27
|
+
"@tb-dev/eslint-config": "^8.2.4",
|
|
28
|
+
"@types/node": "^25.1.0",
|
|
29
|
+
"@vitest/ui": "^4.0.18",
|
|
30
30
|
"eslint": "^9.39.2",
|
|
31
31
|
"tslib": "^2.8.1",
|
|
32
|
-
"typedoc": "^0.28.
|
|
33
|
-
"typedoc-plugin-mdn-links": "^5.
|
|
32
|
+
"typedoc": "^0.28.16",
|
|
33
|
+
"typedoc-plugin-mdn-links": "^5.1.1",
|
|
34
34
|
"typescript": "^5.9.3",
|
|
35
|
-
"vite": "^7.3.
|
|
35
|
+
"vite": "^7.3.1",
|
|
36
36
|
"vite-plugin-dts": "^4.5.4",
|
|
37
|
-
"vitest": "^4.0.
|
|
37
|
+
"vitest": "^4.0.18"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"dist"
|