ctx-core 5.10.0 → 5.13.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/all/bind_apply/index.d.ts +26 -6
- package/all/bind_apply/index.js +5 -5
- package/all/bind_apply/index.test.ts +19 -0
- package/all/bind_call/index.d.ts +22 -4
- package/all/bind_call/index.js +1 -1
- package/all/bind_call/index.test.ts +18 -0
- package/all/call/index.d.ts +1 -1
- package/all/ctx/index.d.ts +1 -1
- package/all/index.d.ts +2 -3
- package/all/index.js +2 -3
- package/all/nullish__guard__async/index.js +1 -1
- package/all/nullish__none/index.d.ts +1 -1
- package/all/rmemo/index.d.ts +2 -2
- package/all/rmemo/index.js +3 -3
- package/all/rmemo/index.test.ts +6 -6
- package/all/rmemo__wait/index.js +2 -2
- package/all/run/index.d.ts +0 -1
- package/all/run/index.js +0 -1
- package/all/tap/index.d.ts +9 -11
- package/all/tap/index.test.ts +10 -0
- package/all/timeout/index.d.ts +3 -0
- package/all/timeout/index.js +8 -0
- package/all/timeout/index.test.ts +8 -0
- package/all/timeout_promise/index.d.ts +7 -6
- package/all/timeout_promise/index.js +28 -8
- package/all/{promise_timeout → timeout_promise}/index.test.ts +9 -7
- package/all/tup/index.d.ts +0 -28
- package/all/tuple/index.d.ts +28 -0
- package/all/tuple/index.js +1 -0
- package/all/tuple__o/index.d.ts +2 -2
- package/all/tuple__union/index.d.ts +1 -1
- package/all/tuple_a_o/index.d.ts +1 -1
- package/all/waitfor/index.d.ts +1 -0
- package/all/waitfor/index.js +3 -2
- package/all/waitfor_fibonacci_backoff/index.js +4 -1
- package/all/zip__tuple_a/index.d.ts +2 -2
- package/falsy/index.d.ts +4 -0
- package/falsy/index.js +4 -0
- package/function/index.d.ts +5 -4
- package/function/index.js +5 -4
- package/nullish/index.d.ts +6 -0
- package/nullish/index.js +6 -0
- package/package.json +250 -239
- package/promise/index.d.ts +11 -0
- package/promise/index.js +11 -0
- package/rmemo/index.d.ts +10 -2
- package/rmemo/index.js +10 -2
- package/run/index.d.ts +12 -0
- package/run/index.js +12 -0
- package/tuple/index.d.ts +6 -0
- package/tuple/index.js +6 -0
- package/all/Timeout/index.d.ts +0 -1
- package/all/Timeout/index.js +0 -1
- package/all/promise_timeout/index.d.ts +0 -6
- package/all/promise_timeout/index.js +0 -30
- package/all/waitfor_val/index.d.ts +0 -6
- package/all/waitfor_val/index.js +0 -20
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {(()=>Promise<unknown>)|Promise<unknown>}promise
|
|
3
|
-
* @param {number}ms
|
|
4
|
-
* @param {Error}[error]
|
|
5
|
-
* @returns {cancel_Promise}
|
|
6
|
-
*/
|
|
7
|
-
export function promise_timeout(
|
|
8
|
-
promise,
|
|
9
|
-
ms,
|
|
10
|
-
error
|
|
11
|
-
) {
|
|
12
|
-
error ??= Error(`Timeout ${ms}ms`)
|
|
13
|
-
let id
|
|
14
|
-
let timeout = new Promise((_resolve, reject)=>{
|
|
15
|
-
id = setTimeout(()=>reject(error), ms)
|
|
16
|
-
})
|
|
17
|
-
let cancel_promise__resolve
|
|
18
|
-
let cancel_promise = new Promise(resolve=>cancel_promise__resolve = resolve)
|
|
19
|
-
/** @type {cancel_Promise} */
|
|
20
|
-
let ret_promise = Promise.race([
|
|
21
|
-
typeof promise === 'function' ? promise() : promise,
|
|
22
|
-
timeout,
|
|
23
|
-
cancel_promise,
|
|
24
|
-
]).then(result=>{
|
|
25
|
-
clearTimeout(id)
|
|
26
|
-
return result
|
|
27
|
-
})
|
|
28
|
-
ret_promise.cancel = cancel_promise__resolve
|
|
29
|
-
return ret_promise
|
|
30
|
-
}
|
package/all/waitfor_val/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { promise_timeout } from '../promise_timeout/index.js'
|
|
2
|
-
import { sleep } from '../sleep/index.js'
|
|
3
|
-
/**
|
|
4
|
-
* @param {()=>Promise<unknown>}fn
|
|
5
|
-
* @param {(val:unknown)=>unknown}condition_fn
|
|
6
|
-
* @param {number}timeout
|
|
7
|
-
* @param {number}[period]
|
|
8
|
-
* @returns {Promise<unknown>}
|
|
9
|
-
*/
|
|
10
|
-
export async function waitfor_val(
|
|
11
|
-
fn, condition_fn, timeout, period = 0
|
|
12
|
-
) {
|
|
13
|
-
return await promise_timeout(async ()=>{
|
|
14
|
-
for (; ;) {
|
|
15
|
-
const val = await fn()
|
|
16
|
-
if (condition_fn(val)) return val
|
|
17
|
-
await sleep(period)
|
|
18
|
-
}
|
|
19
|
-
}, timeout)
|
|
20
|
-
}
|