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.
Files changed (57) hide show
  1. package/all/bind_apply/index.d.ts +26 -6
  2. package/all/bind_apply/index.js +5 -5
  3. package/all/bind_apply/index.test.ts +19 -0
  4. package/all/bind_call/index.d.ts +22 -4
  5. package/all/bind_call/index.js +1 -1
  6. package/all/bind_call/index.test.ts +18 -0
  7. package/all/call/index.d.ts +1 -1
  8. package/all/ctx/index.d.ts +1 -1
  9. package/all/index.d.ts +2 -3
  10. package/all/index.js +2 -3
  11. package/all/nullish__guard__async/index.js +1 -1
  12. package/all/nullish__none/index.d.ts +1 -1
  13. package/all/rmemo/index.d.ts +2 -2
  14. package/all/rmemo/index.js +3 -3
  15. package/all/rmemo/index.test.ts +6 -6
  16. package/all/rmemo__wait/index.js +2 -2
  17. package/all/run/index.d.ts +0 -1
  18. package/all/run/index.js +0 -1
  19. package/all/tap/index.d.ts +9 -11
  20. package/all/tap/index.test.ts +10 -0
  21. package/all/timeout/index.d.ts +3 -0
  22. package/all/timeout/index.js +8 -0
  23. package/all/timeout/index.test.ts +8 -0
  24. package/all/timeout_promise/index.d.ts +7 -6
  25. package/all/timeout_promise/index.js +28 -8
  26. package/all/{promise_timeout → timeout_promise}/index.test.ts +9 -7
  27. package/all/tup/index.d.ts +0 -28
  28. package/all/tuple/index.d.ts +28 -0
  29. package/all/tuple/index.js +1 -0
  30. package/all/tuple__o/index.d.ts +2 -2
  31. package/all/tuple__union/index.d.ts +1 -1
  32. package/all/tuple_a_o/index.d.ts +1 -1
  33. package/all/waitfor/index.d.ts +1 -0
  34. package/all/waitfor/index.js +3 -2
  35. package/all/waitfor_fibonacci_backoff/index.js +4 -1
  36. package/all/zip__tuple_a/index.d.ts +2 -2
  37. package/falsy/index.d.ts +4 -0
  38. package/falsy/index.js +4 -0
  39. package/function/index.d.ts +5 -4
  40. package/function/index.js +5 -4
  41. package/nullish/index.d.ts +6 -0
  42. package/nullish/index.js +6 -0
  43. package/package.json +250 -239
  44. package/promise/index.d.ts +11 -0
  45. package/promise/index.js +11 -0
  46. package/rmemo/index.d.ts +10 -2
  47. package/rmemo/index.js +10 -2
  48. package/run/index.d.ts +12 -0
  49. package/run/index.js +12 -0
  50. package/tuple/index.d.ts +6 -0
  51. package/tuple/index.js +6 -0
  52. package/all/Timeout/index.d.ts +0 -1
  53. package/all/Timeout/index.js +0 -1
  54. package/all/promise_timeout/index.d.ts +0 -6
  55. package/all/promise_timeout/index.js +0 -30
  56. package/all/waitfor_val/index.d.ts +0 -6
  57. 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
- }
@@ -1,6 +0,0 @@
1
- export declare function waitfor_val<Val>(
2
- fn:()=>Promise<Val>,
3
- condition_fn:(val:Val)=>any,
4
- timeout:number,
5
- period?:number
6
- ):Promise<Val>
@@ -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
- }