ctx-core 6.8.2 → 7.0.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/be_/index.d.ts +24 -0
- package/all/be_/index.js +28 -0
- package/all/be_/index.test.ts +26 -0
- package/all/be_lock_memosig_triple/index.d.ts +7 -8
- package/all/be_lock_memosig_triple/index.js +20 -17
- package/all/be_lock_memosig_triple/index.test.ts +100 -86
- package/all/be_memo_pair/index.d.ts +7 -8
- package/all/be_memo_pair/index.js +22 -20
- package/all/be_memo_pair/index.test.ts +114 -97
- package/all/be_memosig_triple/index.d.ts +7 -8
- package/all/be_memosig_triple/index.test.ts +115 -100
- package/all/be_sig_triple/index.d.ts +7 -8
- package/all/be_sig_triple/index.js +20 -17
- package/all/be_sig_triple/index.test.ts +63 -52
- package/all/event_log/index.js +11 -9
- package/all/is_development/index.js +6 -5
- package/all/is_production/index.js +6 -5
- package/all/is_staging/index.js +5 -4
- package/all/rmemo/index.d.ts +42 -31
- package/all/rmemo/index.js +88 -94
- package/all/rmemo/index.test.ts +131 -115
- package/all/rmemo__wait/index.test.ts +2 -2
- package/all/wanimato/index.js +12 -12
- package/package.json +7 -7
package/all/be_/index.d.ts
CHANGED
|
@@ -101,6 +101,30 @@ export declare function ondelete_be_<
|
|
|
101
101
|
val__new:ondelete_be__val__new_T<val_T, ns_T, ctx_T>,
|
|
102
102
|
config?:be_config_T<ns_T>
|
|
103
103
|
):ondelete_Be<val_T, ns_T, ctx_T>
|
|
104
|
+
export declare function ns_ondelete_be_<
|
|
105
|
+
val_T,
|
|
106
|
+
ns_T extends string,
|
|
107
|
+
ctx_T extends wide_ctx_T<ns_T> = wide_ctx_T<ns_T>,
|
|
108
|
+
>(
|
|
109
|
+
ns:ns_T,
|
|
110
|
+
val__new:ondelete_be__val__new_T<val_T, ns_T, ctx_T>
|
|
111
|
+
):ondelete_Be<val_T, ns_T, ctx_T>
|
|
112
|
+
export declare function id_ondelete_be_<
|
|
113
|
+
val_T,
|
|
114
|
+
ctx_T extends wide_ctx_T<''> = wide_ctx_T<''>,
|
|
115
|
+
>(
|
|
116
|
+
id:string,
|
|
117
|
+
val__new:ondelete_be__val__new_T<val_T, '', ctx_T>
|
|
118
|
+
):ondelete_Be<val_T, '', ctx_T>
|
|
119
|
+
export declare function ns_id_ondelete_be_<
|
|
120
|
+
val_T,
|
|
121
|
+
ns_T extends string,
|
|
122
|
+
ctx_T extends wide_ctx_T<ns_T> = wide_ctx_T<ns_T>,
|
|
123
|
+
>(
|
|
124
|
+
ns:ns_T,
|
|
125
|
+
id:string,
|
|
126
|
+
val__new:be__val__new_T<val_T, ns_T, ctx_T>
|
|
127
|
+
):ondelete_Be<val_T, ns_T, ctx_T>
|
|
104
128
|
export type Be<
|
|
105
129
|
val_T,
|
|
106
130
|
ns_T extends string = '',
|
package/all/be_/index.js
CHANGED
|
@@ -199,3 +199,31 @@ export function ondelete_be_(val__new, config) {
|
|
|
199
199
|
}
|
|
200
200
|
return be
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* @param {string}ns
|
|
204
|
+
* @param {be__val__new_T}val__new
|
|
205
|
+
* @returns {Be}
|
|
206
|
+
* @private
|
|
207
|
+
*/
|
|
208
|
+
export function ns_ondelete_be_(ns, val__new) {
|
|
209
|
+
return ondelete_be_(val__new, { ns })
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @param {string}id
|
|
213
|
+
* @param {be__val__new_T}val__new
|
|
214
|
+
* @returns {Be}
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
export function id_ondelete_be_(id, val__new) {
|
|
218
|
+
return ondelete_be_(val__new, { id })
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @param {string}ns
|
|
222
|
+
* @param {string}id
|
|
223
|
+
* @param {be__val__new_T}val__new
|
|
224
|
+
* @returns {Be}
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
227
|
+
export function ns_id_ondelete_be_(ns, id, val__new) {
|
|
228
|
+
return ondelete_be_(val__new, { ns, id })
|
|
229
|
+
}
|
package/all/be_/index.test.ts
CHANGED
|
@@ -19,8 +19,11 @@ import {
|
|
|
19
19
|
type ctx_T,
|
|
20
20
|
globalThis__be_,
|
|
21
21
|
id_be_,
|
|
22
|
+
id_ondelete_be_,
|
|
22
23
|
ns_be_,
|
|
23
24
|
ns_id_be_,
|
|
25
|
+
ns_id_ondelete_be_,
|
|
26
|
+
ns_ondelete_be_,
|
|
24
27
|
ondelete_be_,
|
|
25
28
|
type wide_ctx_s_T,
|
|
26
29
|
type wide_ctx_T
|
|
@@ -460,6 +463,29 @@ test('ondelete_be_', ()=>{
|
|
|
460
463
|
equal(ondelete0_arg_aa, [[1, ctx, be], [1, ctx, be]])
|
|
461
464
|
equal(ondelete1_arg_aa, [[1, ctx, be], [1, ctx, be]])
|
|
462
465
|
})
|
|
466
|
+
test('ns_ondelete_be_', ()=>{
|
|
467
|
+
const valid_ctx = ns_ctx__new('test_ns')
|
|
468
|
+
const val_ = ns_ondelete_be_('test_ns', ()=>true)
|
|
469
|
+
equal(val_(valid_ctx), true)
|
|
470
|
+
// @ts-expect-error TS2322
|
|
471
|
+
throws(()=>val_(ctx__new()))
|
|
472
|
+
})
|
|
473
|
+
test('id_ondelete_be_', ()=>{
|
|
474
|
+
const valid_ctx = ctx__new()
|
|
475
|
+
const val_ = id_ondelete_be_('test_id', ()=>true)
|
|
476
|
+
equal(val_(valid_ctx), true)
|
|
477
|
+
equal(val_.id, 'test_id')
|
|
478
|
+
// @ts-expect-error TS2322
|
|
479
|
+
throws(()=>val_(ns_ctx__new('test_ns')))
|
|
480
|
+
})
|
|
481
|
+
test('ns_id_ondelete_be_', ()=>{
|
|
482
|
+
const valid_ctx = ns_ctx__new('test_ns')
|
|
483
|
+
const val_ = ns_id_ondelete_be_('test_ns', 'test_id', ()=>true)
|
|
484
|
+
equal(val_(valid_ctx), true)
|
|
485
|
+
equal(val_.id, 'test_id')
|
|
486
|
+
// @ts-expect-error TS2322
|
|
487
|
+
throws(()=>val_(ctx__new()))
|
|
488
|
+
})
|
|
463
489
|
test('ctx__clear', ()=>{
|
|
464
490
|
const ondelete0_arg_aa:[val:number, ctx:ctx_T, be:Be<number, ''|'test_ns'>][] = []
|
|
465
491
|
const ondelete1_arg_aa:[val:number, ctx:ctx_T, be:Be<number, ''|'test_ns'>][] = []
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Be,
|
|
2
|
-
import type { lock_memosig_T } from '../rmemo/index.js'
|
|
1
|
+
import type { Be, ctx__be_T, ctx__get_T, ctx__set_T, wide_ctx_T, } from '../be_/index.js'
|
|
2
|
+
import type { lock_memosig_T, be_rmemo_add_def_T } from '../rmemo/index.js'
|
|
3
3
|
export declare function be_lock_memosig_triple_<
|
|
4
4
|
val_T,
|
|
5
5
|
ns_T extends string = '',
|
|
@@ -13,7 +13,7 @@ export declare function be_lock_memosig_triple_<
|
|
|
13
13
|
ctx_T extends wide_ctx_T<ns_T> = wide_ctx_T<ns_T>,
|
|
14
14
|
>(
|
|
15
15
|
val__new:(ctx:ctx_T, lock_memosig:lock_memosig_T<val_T, E>)=>val_T,
|
|
16
|
-
|
|
16
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, ns_T, E, ctx_T>[]
|
|
17
17
|
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
18
18
|
export declare function ns_be_lock_memosig_triple_<
|
|
19
19
|
val_T,
|
|
@@ -23,6 +23,7 @@ export declare function ns_be_lock_memosig_triple_<
|
|
|
23
23
|
>(
|
|
24
24
|
ns:ns_T,
|
|
25
25
|
val__new:(ctx:ctx_T, lock_memosig:lock_memosig_T<val_T, E>)=>val_T,
|
|
26
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, ns_T, E, ctx_T>[]
|
|
26
27
|
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
27
28
|
export declare function id_be_lock_memosig_triple_<
|
|
28
29
|
val_T,
|
|
@@ -31,6 +32,7 @@ export declare function id_be_lock_memosig_triple_<
|
|
|
31
32
|
>(
|
|
32
33
|
id:string,
|
|
33
34
|
val__new:(ctx:ctx_T, lock_memosig:lock_memosig_T<val_T, E>)=>val_T,
|
|
35
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, '', E, ctx_T>[]
|
|
34
36
|
):be_lock_memosig_triple_T<val_T, '', E, ctx_T>
|
|
35
37
|
export declare function ns_id_be_lock_memosig_triple_<
|
|
36
38
|
val_T,
|
|
@@ -41,6 +43,7 @@ export declare function ns_id_be_lock_memosig_triple_<
|
|
|
41
43
|
ns:ns_T,
|
|
42
44
|
id:string,
|
|
43
45
|
val__new:(ctx:ctx_T, lock_memosig:lock_memosig_T<val_T, E>)=>val_T,
|
|
46
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, ns_T, E, ctx_T>[]
|
|
44
47
|
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
45
48
|
export type be_lock_memosig_triple_T<
|
|
46
49
|
val_T,
|
|
@@ -51,8 +54,4 @@ export type be_lock_memosig_triple_T<
|
|
|
51
54
|
ctx__be_T<lock_memosig_T<val_T, E>, ns_T, ctx_T>,
|
|
52
55
|
ctx__get_T<val_T, ns_T, ctx_T>,
|
|
53
56
|
ctx__set_T<val_T, ns_T, ctx_T>,
|
|
54
|
-
]
|
|
55
|
-
add<add_val_T>(
|
|
56
|
-
add_def:(ctx:ctx_T, sig:lock_memosig_T<val_T, E>)=>add_val_T
|
|
57
|
-
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
58
|
-
}
|
|
57
|
+
]
|
|
@@ -6,72 +6,75 @@ import { be_ } from '../be_/index.js'
|
|
|
6
6
|
import { lock_memosig_ } from '../rmemo/index.js'
|
|
7
7
|
/**
|
|
8
8
|
* @param {Be<sig_T>|be__val__new_T<unknown>}be_OR_val__new
|
|
9
|
+
* @param {be_rmemo_add_def_T[]}[add_def_a1]
|
|
9
10
|
* @param {be_config_T}[config]
|
|
10
11
|
* @returns {be_lock_memosig_triple_T}
|
|
11
12
|
* @private
|
|
12
13
|
*/
|
|
13
14
|
export function be_lock_memosig_triple_(
|
|
14
15
|
be_OR_val__new,
|
|
16
|
+
add_def_a1,
|
|
15
17
|
config
|
|
16
18
|
) {
|
|
17
|
-
let add_def_a = []
|
|
18
19
|
/** @type {Be<sig_T>} */
|
|
19
20
|
let be =
|
|
20
21
|
be_OR_val__new.is_be
|
|
21
22
|
? be_OR_val__new
|
|
22
23
|
: be_(ctx=>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
lock_memosig_(
|
|
25
|
+
memo=>be_OR_val__new(ctx, memo),
|
|
26
|
+
(add_def_a1 ?? []).map(
|
|
27
|
+
add_def=>memo=>add_def(ctx, memo))),
|
|
26
28
|
config)
|
|
27
|
-
|
|
29
|
+
return [
|
|
28
30
|
be,
|
|
29
31
|
ctx=>be(ctx)(),
|
|
30
32
|
(ctx, val)=>{
|
|
31
|
-
be(ctx).
|
|
33
|
+
be(ctx).set(val)
|
|
32
34
|
},
|
|
33
35
|
]
|
|
34
|
-
be_lock_memosig_triple.add = add_def=>{
|
|
35
|
-
add_def_a.push(add_def)
|
|
36
|
-
return be_lock_memosig_triple
|
|
37
|
-
}
|
|
38
|
-
return be_lock_memosig_triple
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
41
38
|
* @param {string}ns
|
|
42
39
|
* @param {be__val__new_T<unknown>}val__new
|
|
40
|
+
* @param {be_rmemo_add_def_T[]}[add_def_a1]
|
|
43
41
|
* @returns {be_lock_memosig_triple_T}
|
|
44
42
|
* @private
|
|
45
43
|
*/
|
|
46
44
|
export function ns_be_lock_memosig_triple_(
|
|
47
45
|
ns,
|
|
48
|
-
val__new
|
|
46
|
+
val__new,
|
|
47
|
+
add_def_a1
|
|
49
48
|
) {
|
|
50
|
-
return be_lock_memosig_triple_(val__new, { ns })
|
|
49
|
+
return be_lock_memosig_triple_(val__new, add_def_a1, { ns })
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* @param {string}id
|
|
54
53
|
* @param {be__val__new_T<unknown>}val__new
|
|
54
|
+
* @param {be_rmemo_add_def_T[]}[add_def_a1]
|
|
55
55
|
* @returns {be_lock_memosig_triple_T}
|
|
56
56
|
* @private
|
|
57
57
|
*/
|
|
58
58
|
export function id_be_lock_memosig_triple_(
|
|
59
59
|
id,
|
|
60
|
-
val__new
|
|
60
|
+
val__new,
|
|
61
|
+
add_def_a1
|
|
61
62
|
) {
|
|
62
|
-
return be_lock_memosig_triple_(val__new, { id })
|
|
63
|
+
return be_lock_memosig_triple_(val__new, add_def_a1, { id })
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* @param {string}ns
|
|
66
67
|
* @param {string}id
|
|
67
68
|
* @param {be__val__new_T<unknown>}val__new
|
|
69
|
+
* @param {be_rmemo_add_def_T[]}[add_def_a1]
|
|
68
70
|
* @returns {be_lock_memosig_triple_T}
|
|
69
71
|
* @private
|
|
70
72
|
*/
|
|
71
73
|
export function ns_id_be_lock_memosig_triple_(
|
|
72
74
|
ns,
|
|
73
75
|
id,
|
|
74
|
-
val__new
|
|
76
|
+
val__new,
|
|
77
|
+
add_def_a1
|
|
75
78
|
) {
|
|
76
|
-
return be_lock_memosig_triple_(val__new, { ns, id })
|
|
79
|
+
return be_lock_memosig_triple_(val__new, add_def_a1, { ns, id })
|
|
77
80
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from 'uvu'
|
|
2
2
|
import { equal } from 'uvu/assert'
|
|
3
3
|
import { be_, type wide_ctx_T } from '../be_/index.js'
|
|
4
|
-
import { be_sig_triple_ } from '../be_sig_triple/index.js'
|
|
4
|
+
import { be_sig_triple_, ns_be_sig_triple_ } from '../be_sig_triple/index.js'
|
|
5
5
|
import { ctx__new, ns_ctx__new } from '../ctx/index.js'
|
|
6
6
|
import { memo_, memosig_, type sig_T } from '../rmemo/index.js'
|
|
7
7
|
import type { Equal, Expect } from '../test/index.js'
|
|
@@ -31,15 +31,15 @@ test('be_lock_memosig_triple_', ()=>{
|
|
|
31
31
|
})
|
|
32
32
|
const ctx = ctx__new()
|
|
33
33
|
equal(foobar$_(ctx).count, undefined)
|
|
34
|
-
equal(foobar$_(ctx)
|
|
34
|
+
equal(foobar$_(ctx)(), 2)
|
|
35
35
|
equal(foobar_(ctx), 2)
|
|
36
36
|
equal(foobar$_(ctx).count, 1)
|
|
37
37
|
foobar__set(ctx, 5)
|
|
38
|
-
equal(foobar$_(ctx)
|
|
38
|
+
equal(foobar$_(ctx)(), 5)
|
|
39
39
|
equal(foobar_(ctx), 5)
|
|
40
40
|
equal(foobar$_(ctx).count, 1)
|
|
41
41
|
base__set(ctx, 2)
|
|
42
|
-
equal(foobar$_(ctx)
|
|
42
|
+
equal(foobar$_(ctx)(), 5)
|
|
43
43
|
equal(foobar_(ctx), 5)
|
|
44
44
|
equal(foobar$_(ctx).count, 1)
|
|
45
45
|
})
|
|
@@ -50,54 +50,58 @@ test('be_lock_memosig_triple_|+id|+ns', ()=>{
|
|
|
50
50
|
,
|
|
51
51
|
base_,
|
|
52
52
|
base__set,
|
|
53
|
-
] =
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
] = ns_be_sig_triple_(
|
|
54
|
+
'test_ns',
|
|
55
|
+
()=>1)
|
|
56
56
|
const [
|
|
57
57
|
,
|
|
58
58
|
add_dep_,
|
|
59
59
|
add_dep__set
|
|
60
|
-
] =
|
|
61
|
-
|
|
60
|
+
] = ns_be_sig_triple_(
|
|
61
|
+
'test_ns',
|
|
62
|
+
()=>1)
|
|
62
63
|
const [
|
|
63
64
|
foobar$_,
|
|
64
65
|
foobar_,
|
|
65
66
|
foobar__set,
|
|
66
|
-
] =
|
|
67
|
+
] = ns_id_be_lock_memosig_triple_<number, 'test_ns'>(
|
|
68
|
+
'test_ns',
|
|
69
|
+
'foobar',
|
|
67
70
|
ctx=>{
|
|
68
71
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
69
72
|
type test_ctx = Expect<Equal<typeof ctx, wide_ctx_T<'test_ns'>>>
|
|
70
73
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
71
74
|
return base_(ctx) + 1
|
|
72
75
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
[
|
|
77
|
+
(ctx, foobar$)=>memo_(()=>{
|
|
78
|
+
add_count++
|
|
79
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
80
|
+
})
|
|
81
|
+
])
|
|
78
82
|
equal(add_count, 0)
|
|
79
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
83
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 2)
|
|
80
84
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
81
|
-
equal(foobar$_(ctx)
|
|
85
|
+
equal(foobar$_(ctx)(), 2)
|
|
82
86
|
equal(foobar_(ctx), 2)
|
|
83
87
|
equal(add_count, 1)
|
|
84
|
-
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)
|
|
88
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)(), 2)
|
|
85
89
|
equal(add_dep_(ctx), 3)
|
|
86
90
|
foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
|
|
87
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
91
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
88
92
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
89
|
-
equal(foobar$_(ctx)
|
|
93
|
+
equal(foobar$_(ctx)(), 5)
|
|
90
94
|
equal(foobar_(ctx), 5)
|
|
91
|
-
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)
|
|
95
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)(), 5)
|
|
92
96
|
equal(add_count, 2)
|
|
93
97
|
equal(add_dep_(ctx), 7)
|
|
94
98
|
base__set(ctx, 2)
|
|
95
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
99
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
96
100
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
97
|
-
equal(foobar$_(ctx)
|
|
101
|
+
equal(foobar$_(ctx)(), 5)
|
|
98
102
|
equal(foobar_(ctx), 5)
|
|
99
103
|
equal(add_count, 2)
|
|
100
|
-
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)
|
|
104
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)(), 5)
|
|
101
105
|
equal(add_dep_(ctx), 7)
|
|
102
106
|
})
|
|
103
107
|
test('be_lock_memosig_triple_|+be', ()=>{
|
|
@@ -107,50 +111,52 @@ test('be_lock_memosig_triple_|+be', ()=>{
|
|
|
107
111
|
,
|
|
108
112
|
base_,
|
|
109
113
|
base__set,
|
|
110
|
-
] =
|
|
111
|
-
|
|
114
|
+
] = ns_be_sig_triple_(
|
|
115
|
+
'test_ns',
|
|
116
|
+
()=>1)
|
|
112
117
|
const [
|
|
113
118
|
foobar$_,
|
|
114
119
|
foobar_,
|
|
115
120
|
foobar__set,
|
|
116
|
-
] = be_lock_memosig_triple_<number, 'test_ns', { custom:
|
|
121
|
+
] = be_lock_memosig_triple_<number, 'test_ns', { custom:string }>(
|
|
117
122
|
be_(ctx=>{
|
|
118
123
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
119
124
|
type test_ctx = Expect<Equal<typeof ctx, wide_ctx_T<'test_ns'>>>
|
|
120
125
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
121
126
|
const foobar$ =
|
|
122
|
-
memosig_<number, { custom:
|
|
123
|
-
()=>base_(ctx) + 1
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
memosig_<number, { custom:string }>(
|
|
128
|
+
()=>base_(ctx) + 1,
|
|
129
|
+
[foobar$=>
|
|
130
|
+
memo_(()=>{
|
|
131
|
+
foobar$()
|
|
132
|
+
add_count++
|
|
133
|
+
})
|
|
134
|
+
])
|
|
129
135
|
foobar$.custom = 'custom-val'
|
|
130
136
|
return foobar$
|
|
131
137
|
}, { id: 'foobar', ns: 'test_ns' }))
|
|
132
138
|
equal(add_count, 0)
|
|
133
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
139
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 2)
|
|
134
140
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
135
|
-
equal(foobar$_(ctx)
|
|
141
|
+
equal(foobar$_(ctx)(), 2)
|
|
136
142
|
equal(foobar_(ctx), 2)
|
|
137
143
|
equal(add_count, 1)
|
|
138
|
-
equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)
|
|
144
|
+
equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)(), 2)
|
|
139
145
|
equal(foobar$_(ctx).custom, 'custom-val')
|
|
140
146
|
foobar__set(ctx, 5)
|
|
141
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
147
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
142
148
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
143
|
-
equal(foobar$_(ctx)
|
|
149
|
+
equal(foobar$_(ctx)(), 5)
|
|
144
150
|
equal(foobar_(ctx), 5)
|
|
145
151
|
equal(add_count, 2)
|
|
146
|
-
equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)
|
|
152
|
+
equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)(), 5)
|
|
147
153
|
equal(foobar$_(ctx).custom, 'custom-val')
|
|
148
154
|
base__set(ns_ctx__new(ctx__new(), ctx), 2)
|
|
149
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
155
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 3)
|
|
150
156
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
|
|
151
|
-
equal(foobar$_(ctx)
|
|
157
|
+
equal(foobar$_(ctx)(), 3)
|
|
152
158
|
equal(foobar_(ctx), 3)
|
|
153
|
-
equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)
|
|
159
|
+
equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)(), 3)
|
|
154
160
|
equal(foobar$_(ctx).custom, 'custom-val')
|
|
155
161
|
equal(add_count, 3)
|
|
156
162
|
})
|
|
@@ -161,15 +167,16 @@ test('ns_be_lock_memosig_triple_', ()=>{
|
|
|
161
167
|
,
|
|
162
168
|
base_,
|
|
163
169
|
base__set,
|
|
164
|
-
] =
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
] = ns_be_sig_triple_(
|
|
171
|
+
'test_ns',
|
|
172
|
+
()=>1)
|
|
167
173
|
const [
|
|
168
174
|
,
|
|
169
175
|
add_dep_,
|
|
170
176
|
add_dep__set
|
|
171
|
-
] =
|
|
172
|
-
|
|
177
|
+
] = ns_be_sig_triple_(
|
|
178
|
+
'test_ns',
|
|
179
|
+
()=>1)
|
|
173
180
|
const [
|
|
174
181
|
foobar$_,
|
|
175
182
|
foobar_,
|
|
@@ -182,28 +189,30 @@ test('ns_be_lock_memosig_triple_', ()=>{
|
|
|
182
189
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
183
190
|
return base_(ctx) + 1
|
|
184
191
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
[
|
|
193
|
+
(ctx, foobar$)=>memo_(()=>{
|
|
194
|
+
add_count++
|
|
195
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
196
|
+
})
|
|
197
|
+
])
|
|
189
198
|
equal(add_count, 0)
|
|
190
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
199
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 2)
|
|
191
200
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
192
|
-
equal(foobar$_(ctx)
|
|
201
|
+
equal(foobar$_(ctx)(), 2)
|
|
193
202
|
equal(foobar_(ctx), 2)
|
|
194
203
|
equal(add_count, 1)
|
|
195
204
|
equal(add_dep_(ctx), 3)
|
|
196
205
|
foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
|
|
197
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
206
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
198
207
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
199
|
-
equal(foobar$_(ctx)
|
|
208
|
+
equal(foobar$_(ctx)(), 5)
|
|
200
209
|
equal(foobar_(ctx), 5)
|
|
201
210
|
equal(add_count, 2)
|
|
202
211
|
equal(add_dep_(ctx), 7)
|
|
203
212
|
base__set(ctx, 2)
|
|
204
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
213
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
205
214
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
206
|
-
equal(foobar$_(ctx)
|
|
215
|
+
equal(foobar$_(ctx)(), 5)
|
|
207
216
|
equal(foobar_(ctx), 5)
|
|
208
217
|
equal(add_count, 2)
|
|
209
218
|
equal(add_dep_(ctx), 7)
|
|
@@ -234,27 +243,29 @@ test('id_be_lock_memosig_triple_', ()=>{
|
|
|
234
243
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
235
244
|
return base_(ctx) + 1
|
|
236
245
|
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
246
|
+
[
|
|
247
|
+
(ctx, foobar$)=>memo_(()=>{
|
|
248
|
+
add_count++
|
|
249
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
250
|
+
})
|
|
251
|
+
])
|
|
241
252
|
equal(add_count, 0)
|
|
242
|
-
equal(foobar$_(ctx)
|
|
253
|
+
equal(foobar$_(ctx)(), 2)
|
|
243
254
|
equal(foobar_(ctx), 2)
|
|
244
255
|
equal(add_count, 1)
|
|
245
|
-
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)
|
|
256
|
+
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)(), 2)
|
|
246
257
|
equal(add_dep_(ctx), 3)
|
|
247
258
|
foobar__set(ctx, 5)
|
|
248
|
-
equal(foobar$_(ctx)
|
|
259
|
+
equal(foobar$_(ctx)(), 5)
|
|
249
260
|
equal(foobar_(ctx), 5)
|
|
250
|
-
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)
|
|
261
|
+
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)(), 5)
|
|
251
262
|
equal(add_count, 2)
|
|
252
263
|
equal(add_dep_(ctx), 7)
|
|
253
264
|
base__set(ctx, 2)
|
|
254
|
-
equal(foobar$_(ctx)
|
|
265
|
+
equal(foobar$_(ctx)(), 5)
|
|
255
266
|
equal(foobar_(ctx), 5)
|
|
256
267
|
equal(add_count, 2)
|
|
257
|
-
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)
|
|
268
|
+
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)(), 5)
|
|
258
269
|
equal(add_dep_(ctx), 7)
|
|
259
270
|
})
|
|
260
271
|
test('ns_id_be_lock_memosig_triple_', ()=>{
|
|
@@ -264,15 +275,16 @@ test('ns_id_be_lock_memosig_triple_', ()=>{
|
|
|
264
275
|
,
|
|
265
276
|
base_,
|
|
266
277
|
base__set,
|
|
267
|
-
] =
|
|
268
|
-
|
|
269
|
-
|
|
278
|
+
] = ns_be_sig_triple_(
|
|
279
|
+
'test_ns',
|
|
280
|
+
()=>1)
|
|
270
281
|
const [
|
|
271
282
|
,
|
|
272
283
|
add_dep_,
|
|
273
284
|
add_dep__set
|
|
274
|
-
] =
|
|
275
|
-
|
|
285
|
+
] = ns_be_sig_triple_(
|
|
286
|
+
'test_ns',
|
|
287
|
+
()=>1)
|
|
276
288
|
const [
|
|
277
289
|
foobar$_,
|
|
278
290
|
foobar_,
|
|
@@ -286,33 +298,35 @@ test('ns_id_be_lock_memosig_triple_', ()=>{
|
|
|
286
298
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
287
299
|
return base_(ctx) + 1
|
|
288
300
|
},
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
301
|
+
[
|
|
302
|
+
(ctx, foobar$)=>memo_(()=>{
|
|
303
|
+
add_count++
|
|
304
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
305
|
+
})
|
|
306
|
+
])
|
|
293
307
|
equal(add_count, 0)
|
|
294
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
308
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 2)
|
|
295
309
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
296
|
-
equal(foobar$_(ctx)
|
|
310
|
+
equal(foobar$_(ctx)(), 2)
|
|
297
311
|
equal(foobar_(ctx), 2)
|
|
298
312
|
equal(add_count, 1)
|
|
299
|
-
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)
|
|
313
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)(), 2)
|
|
300
314
|
equal(add_dep_(ctx), 3)
|
|
301
315
|
foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
|
|
302
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
316
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
303
317
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
304
|
-
equal(foobar$_(ctx)
|
|
318
|
+
equal(foobar$_(ctx)(), 5)
|
|
305
319
|
equal(foobar_(ctx), 5)
|
|
306
|
-
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)
|
|
320
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)(), 5)
|
|
307
321
|
equal(add_count, 2)
|
|
308
322
|
equal(add_dep_(ctx), 7)
|
|
309
323
|
base__set(ctx, 2)
|
|
310
|
-
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))
|
|
324
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))(), 5)
|
|
311
325
|
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
312
|
-
equal(foobar$_(ctx)
|
|
326
|
+
equal(foobar$_(ctx)(), 5)
|
|
313
327
|
equal(foobar_(ctx), 5)
|
|
314
328
|
equal(add_count, 2)
|
|
315
|
-
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)
|
|
329
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)(), 5)
|
|
316
330
|
equal(add_dep_(ctx), 7)
|
|
317
331
|
})
|
|
318
332
|
test.run()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Be,
|
|
2
|
-
import type { memo_T, sig_T } from '../rmemo/index.js'
|
|
1
|
+
import type { Be, ctx__be_T, ctx__get_T, wide_ctx_T } from '../be_/index.js'
|
|
2
|
+
import type { be_rmemo_add_def_T, memo_T, sig_T } from '../rmemo/index.js'
|
|
3
3
|
export declare function be_memo_pair_<
|
|
4
4
|
val_T,
|
|
5
5
|
ns_T extends string = '',
|
|
@@ -13,7 +13,7 @@ export declare function be_memo_pair_<
|
|
|
13
13
|
ctx_T extends wide_ctx_T<ns_T> = wide_ctx_T<ns_T>,
|
|
14
14
|
>(
|
|
15
15
|
val__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
|
|
16
|
-
|
|
16
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, ns_T, E, ctx_T>[]
|
|
17
17
|
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
18
18
|
export declare function ns_be_memo_pair_<
|
|
19
19
|
val_T,
|
|
@@ -23,6 +23,7 @@ export declare function ns_be_memo_pair_<
|
|
|
23
23
|
>(
|
|
24
24
|
ns:ns_T,
|
|
25
25
|
val__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
|
|
26
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, ns_T, E, ctx_T>[]
|
|
26
27
|
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
27
28
|
export declare function id_be_memo_pair_<
|
|
28
29
|
val_T,
|
|
@@ -31,6 +32,7 @@ export declare function id_be_memo_pair_<
|
|
|
31
32
|
>(
|
|
32
33
|
id:string,
|
|
33
34
|
val__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
|
|
35
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, '', E, ctx_T>[]
|
|
34
36
|
):be_memo_pair_T<val_T, '', E, ctx_T>
|
|
35
37
|
export declare function ns_id_be_memo_pair_<
|
|
36
38
|
val_T,
|
|
@@ -41,6 +43,7 @@ export declare function ns_id_be_memo_pair_<
|
|
|
41
43
|
ns:ns_T,
|
|
42
44
|
id:string,
|
|
43
45
|
val__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
|
|
46
|
+
add_def_a1?:be_rmemo_add_def_T<val_T, ns_T, E, ctx_T>[]
|
|
44
47
|
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
45
48
|
export type be_memo_pair_T<
|
|
46
49
|
val_T,
|
|
@@ -50,8 +53,4 @@ export type be_memo_pair_T<
|
|
|
50
53
|
> = [
|
|
51
54
|
ctx__be_T<memo_T<val_T, E>, ns_T, ctx_T>,
|
|
52
55
|
ctx__get_T<val_T, ns_T, ctx_T>,
|
|
53
|
-
]
|
|
54
|
-
add<add_val_T>(
|
|
55
|
-
add_def:(ctx:ctx_T, sig:sig_T<val_T, E>)=>add_val_T
|
|
56
|
-
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
57
|
-
}
|
|
56
|
+
]
|