ciorent 0.12.0 → 0.12.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/index.d.ts +6 -0
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export declare const nextTick: Promise<void>;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const state: (p: Promise<any>) => Promise<0 | 1 | 2>;
|
|
19
19
|
/**
|
|
20
|
+
* Timeout a promise
|
|
21
|
+
* @param p
|
|
22
|
+
* @param ms
|
|
23
|
+
*/
|
|
24
|
+
export declare const timeout: <T>(p: Promise<T>, ms: number) => Promise<T | void>;
|
|
25
|
+
/**
|
|
20
26
|
* Sleep for a duration.
|
|
21
27
|
* @param ms - Sleep duration in milliseconds
|
|
22
28
|
*/
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export let nextTick=Promise.resolve();export let state=async r=>{let i=2;r.then(()=>{i=1},
|
|
1
|
+
export let nextTick=Promise.resolve();export let state=async r=>{let i=2;r.then(()=>{i=1},()=>{i=0;return r});await nextTick;return i};export let timeout=(e,r)=>new Promise((i,a)=>{e.then(i,r=>{a(r);return e});setTimeout(i,r)});export let sleep=globalThis.Bun?.sleep??globalThis.process?.getBuiltinModule?.(`timers/promises`).setTimeout??(e=>new Promise(r=>{setTimeout(r,e)}));let sharedBuf=new Int32Array(new SharedArrayBuffer(4));export let sleepSync=globalThis.Bun?.sleepSync??(e=>{Atomics.wait(sharedBuf,0,0,e)});export*as signal from"./signal.js";export*as rateLimit from"./rate-limit.js";export*as semaphore from"./semaphore.js";
|