@stryke/helpers 0.10.10 → 0.10.12
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 +24 -0
- package/README.md +16 -26
- package/dist/index.cjs +1 -21
- package/dist/index.d.cts +1 -10
- package/dist/index.d.mts +1 -10
- package/dist/index.mjs +1 -10
- package/dist/match-sorter.mjs.map +1 -1
- package/dist/types/src/base.d.cts +3 -1
- package/dist/types/src/base.d.cts.map +1 -1
- package/dist/types/src/base.d.mts +3 -1
- package/dist/types/src/base.d.mts.map +1 -1
- package/dist/types/src/object.d.cts +1 -2
- package/dist/types/src/object.d.cts.map +1 -1
- package/dist/types/src/object.d.mts +1 -2
- package/dist/types/src/object.d.mts.map +1 -1
- package/package.json +2 -33
- package/dist/debounce.cjs +0 -63
- package/dist/debounce.d.cts +0 -45
- package/dist/debounce.d.cts.map +0 -1
- package/dist/debounce.d.mts +0 -45
- package/dist/debounce.d.mts.map +0 -1
- package/dist/debounce.mjs +0 -63
- package/dist/debounce.mjs.map +0 -1
- package/dist/delay.cjs +0 -91
- package/dist/delay.d.cts +0 -75
- package/dist/delay.d.cts.map +0 -1
- package/dist/delay.d.mts +0 -75
- package/dist/delay.d.mts.map +0 -1
- package/dist/delay.mjs +0 -91
- package/dist/delay.mjs.map +0 -1
- package/dist/errors.cjs +0 -24
- package/dist/errors.d.cts +0 -16
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.mts +0 -16
- package/dist/errors.d.mts.map +0 -1
- package/dist/errors.mjs +0 -23
- package/dist/errors.mjs.map +0 -1
- package/dist/mutex.cjs +0 -80
- package/dist/mutex.d.cts +0 -72
- package/dist/mutex.d.cts.map +0 -1
- package/dist/mutex.d.mts +0 -72
- package/dist/mutex.d.mts.map +0 -1
- package/dist/mutex.mjs +0 -81
- package/dist/mutex.mjs.map +0 -1
- package/dist/once.cjs +0 -27
- package/dist/once.d.cts +0 -13
- package/dist/once.d.cts.map +0 -1
- package/dist/once.d.mts +0 -13
- package/dist/once.d.mts.map +0 -1
- package/dist/once.mjs +0 -26
- package/dist/once.mjs.map +0 -1
- package/dist/parallel.cjs +0 -39
- package/dist/parallel.d.cts +0 -25
- package/dist/parallel.d.cts.map +0 -1
- package/dist/parallel.d.mts +0 -25
- package/dist/parallel.d.mts.map +0 -1
- package/dist/parallel.mjs +0 -39
- package/dist/parallel.mjs.map +0 -1
- package/dist/semaphore.cjs +0 -105
- package/dist/semaphore.d.cts +0 -86
- package/dist/semaphore.d.cts.map +0 -1
- package/dist/semaphore.d.mts +0 -86
- package/dist/semaphore.d.mts.map +0 -1
- package/dist/semaphore.mjs +0 -105
- package/dist/semaphore.mjs.map +0 -1
- package/dist/throttle.cjs +0 -43
- package/dist/throttle.d.cts +0 -32
- package/dist/throttle.d.cts.map +0 -1
- package/dist/throttle.d.mts +0 -32
- package/dist/throttle.d.mts.map +0 -1
- package/dist/throttle.mjs +0 -43
- package/dist/throttle.mjs.map +0 -1
- package/dist/timeout.cjs +0 -18
- package/dist/timeout.d.cts +0 -12
- package/dist/timeout.d.cts.map +0 -1
- package/dist/timeout.d.mts +0 -12
- package/dist/timeout.d.mts.map +0 -1
- package/dist/timeout.mjs +0 -19
- package/dist/timeout.mjs.map +0 -1
- package/dist/types/src/utilities.d.cts +0 -7
- package/dist/types/src/utilities.d.cts.map +0 -1
- package/dist/types/src/utilities.d.mts +0 -7
- package/dist/types/src/utilities.d.mts.map +0 -1
- package/dist/with-timeout.cjs +0 -28
- package/dist/with-timeout.d.cts +0 -24
- package/dist/with-timeout.d.cts.map +0 -1
- package/dist/with-timeout.d.mts +0 -24
- package/dist/with-timeout.d.mts.map +0 -1
- package/dist/with-timeout.mjs +0 -29
- package/dist/with-timeout.mjs.map +0 -1
package/dist/with-timeout.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { timeout } from "./timeout.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/with-timeout.ts
|
|
4
|
-
/**
|
|
5
|
-
* Executes an async function and enforces a timeout.
|
|
6
|
-
*
|
|
7
|
-
* If the promise does not resolve within the specified time,
|
|
8
|
-
* the timeout will trigger and the returned promise will be rejected.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* try {
|
|
13
|
-
* await withTimeout(() => {}, 1000); // Timeout exception after 1 second
|
|
14
|
-
* } catch (error) {
|
|
15
|
-
* console.error(error); // Will log 'TimeoutError'
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param run - A function that returns a promise to be executed.
|
|
20
|
-
* @param ms - The timeout duration in milliseconds.
|
|
21
|
-
* @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached.
|
|
22
|
-
*/
|
|
23
|
-
async function withTimeout(run, ms) {
|
|
24
|
-
return Promise.race([run(), timeout(ms)]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { withTimeout };
|
|
29
|
-
//# sourceMappingURL=with-timeout.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-timeout.mjs","names":[],"sources":["../src/with-timeout.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { timeout } from \"./timeout\";\n\n/**\n * Executes an async function and enforces a timeout.\n *\n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n * @example\n * ```typescript\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n * ```\n *\n * @param run - A function that returns a promise to be executed.\n * @param ms - The timeout duration in milliseconds.\n * @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n */\nexport async function withTimeout<T>(\n run: () => Promise<T>,\n ms: number\n): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,eAAsB,YACpB,KACA,IACY;AACZ,QAAO,QAAQ,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,CAAM,CAAC"}
|