ctx-core 5.24.0 → 5.25.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/all/be_/index.d.ts +5 -4
- package/all/be_lock_memosig_triple/index.d.ts +29 -2
- package/all/be_lock_memosig_triple/index.js +38 -0
- package/all/be_lock_memosig_triple/index.test.ts +167 -1
- package/all/be_memo_pair/index.d.ts +30 -2
- package/all/be_memo_pair/index.js +43 -3
- package/all/be_memo_pair/index.test.ts +130 -2
- package/all/be_memosig_triple/index.d.ts +29 -2
- package/all/be_memosig_triple/index.js +7 -2
- package/all/be_memosig_triple/index.test.ts +171 -1
- package/all/be_sig_triple/index.d.ts +29 -2
- package/all/be_sig_triple/index.js +38 -0
- package/all/be_sig_triple/index.test.ts +128 -4
- package/package.json +252 -253
package/all/be_/index.d.ts
CHANGED
|
@@ -17,11 +17,12 @@ export declare function be_<
|
|
|
17
17
|
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
18
18
|
>(
|
|
19
19
|
val__new:be__val__new_T<val_T, ns_T, ctx_T>,
|
|
20
|
-
...config:
|
|
21
|
-
ns_T extends ''
|
|
22
|
-
? []|[config:be_config_T<ns_T>]
|
|
23
|
-
: [config:be_config_T<ns_T>]
|
|
20
|
+
...config:be_config_arg_a_T<ns_T>
|
|
24
21
|
):Be<val_T, ns_T, ctx_T>
|
|
22
|
+
export type be_config_arg_a_T<ns_T extends string = ''> =
|
|
23
|
+
ns_T extends ''
|
|
24
|
+
? []|[config:be_config_T<ns_T>]
|
|
25
|
+
: [config:be_config_T<ns_T>]
|
|
25
26
|
export declare function ns_be_<
|
|
26
27
|
val_T,
|
|
27
28
|
ns_T extends string,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Be,
|
|
1
|
+
import type { Be, be_config_arg_a_T, ctx__be_T, ctx__get_T, ctx__set_T, Ctx_wide_T, } from '../be_/index.js'
|
|
2
2
|
import type { lock_memosig_T } from '../rmemo/index.js'
|
|
3
3
|
export declare function be_lock_memosig_triple_<
|
|
4
4
|
val_T,
|
|
@@ -13,7 +13,34 @@ export declare function be_lock_memosig_triple_<
|
|
|
13
13
|
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
14
14
|
>(
|
|
15
15
|
rmemo__new:(ctx:ctx_T, memosig:lock_memosig_T<val_T, E>)=>val_T,
|
|
16
|
-
config
|
|
16
|
+
...config:be_config_arg_a_T<ns_T>
|
|
17
|
+
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
18
|
+
export declare function ns_be_lock_memosig_triple_<
|
|
19
|
+
val_T,
|
|
20
|
+
ns_T extends string,
|
|
21
|
+
E = unknown,
|
|
22
|
+
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
23
|
+
>(
|
|
24
|
+
ns:ns_T,
|
|
25
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
26
|
+
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
27
|
+
export declare function id_be_lock_memosig_triple_<
|
|
28
|
+
val_T,
|
|
29
|
+
E = unknown,
|
|
30
|
+
ctx_T extends Ctx_wide_T<''> = Ctx_wide_T<''>,
|
|
31
|
+
>(
|
|
32
|
+
id:string,
|
|
33
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
34
|
+
):be_lock_memosig_triple_T<val_T, '', E, ctx_T>
|
|
35
|
+
export declare function ns_id_be_lock_memosig_triple_<
|
|
36
|
+
val_T,
|
|
37
|
+
ns_T extends string,
|
|
38
|
+
E = unknown,
|
|
39
|
+
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
40
|
+
>(
|
|
41
|
+
ns:ns_T,
|
|
42
|
+
id:string,
|
|
43
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
17
44
|
):be_lock_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
18
45
|
export type be_lock_memosig_triple_T<
|
|
19
46
|
val_T,
|
|
@@ -37,3 +37,41 @@ export function be_lock_memosig_triple_(
|
|
|
37
37
|
}
|
|
38
38
|
return be_lock_memosig_triple
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @param {string}ns
|
|
42
|
+
* @param {be__val__new_T<unknown>}val__new
|
|
43
|
+
* @returns {be_lock_memosig_triple_T}
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
export function ns_be_lock_memosig_triple_(
|
|
47
|
+
ns,
|
|
48
|
+
val__new
|
|
49
|
+
) {
|
|
50
|
+
return be_lock_memosig_triple_(val__new, { ns })
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @param {string}id
|
|
54
|
+
* @param {be__val__new_T<unknown>}val__new
|
|
55
|
+
* @returns {be_lock_memosig_triple_T}
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
export function id_be_lock_memosig_triple_(
|
|
59
|
+
id,
|
|
60
|
+
val__new
|
|
61
|
+
) {
|
|
62
|
+
return be_lock_memosig_triple_(val__new, { id })
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @param {string}ns
|
|
66
|
+
* @param {string}id
|
|
67
|
+
* @param {be__val__new_T<unknown>}val__new
|
|
68
|
+
* @returns {be_lock_memosig_triple_T}
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
export function ns_id_be_lock_memosig_triple_(
|
|
72
|
+
ns,
|
|
73
|
+
id,
|
|
74
|
+
val__new
|
|
75
|
+
) {
|
|
76
|
+
return be_lock_memosig_triple_(val__new, { ns, id })
|
|
77
|
+
}
|
|
@@ -5,7 +5,12 @@ import { 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'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
be_lock_memosig_triple_,
|
|
10
|
+
id_be_lock_memosig_triple_,
|
|
11
|
+
ns_be_lock_memosig_triple_,
|
|
12
|
+
ns_id_be_lock_memosig_triple_
|
|
13
|
+
} from './index.js'
|
|
9
14
|
test('be_lock_memosig_triple_', ()=>{
|
|
10
15
|
const [
|
|
11
16
|
,
|
|
@@ -149,4 +154,165 @@ test('be_lock_memosig_triple_|+be', ()=>{
|
|
|
149
154
|
equal(foobar$_(ctx).custom, 'custom-val')
|
|
150
155
|
equal(add_count, 3)
|
|
151
156
|
})
|
|
157
|
+
test('ns_be_lock_memosig_triple_', ()=>{
|
|
158
|
+
const ctx = ns_ctx__new('test_ns')
|
|
159
|
+
let add_count = 0
|
|
160
|
+
const [
|
|
161
|
+
,
|
|
162
|
+
base_,
|
|
163
|
+
base__set,
|
|
164
|
+
] = be_sig_triple_(
|
|
165
|
+
()=>1,
|
|
166
|
+
{ ns: 'test_ns' })
|
|
167
|
+
const [
|
|
168
|
+
,
|
|
169
|
+
add_dep_,
|
|
170
|
+
add_dep__set
|
|
171
|
+
] = be_sig_triple_(()=>1,
|
|
172
|
+
{ ns: 'test_ns' })
|
|
173
|
+
const [
|
|
174
|
+
foobar$_,
|
|
175
|
+
foobar_,
|
|
176
|
+
foobar__set,
|
|
177
|
+
] = ns_be_lock_memosig_triple_(
|
|
178
|
+
'test_ns',
|
|
179
|
+
ctx=>{
|
|
180
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
181
|
+
type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
|
|
182
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
183
|
+
return base_(ctx) + 1
|
|
184
|
+
},
|
|
185
|
+
).add((ctx, foobar$)=>memo_(()=>{
|
|
186
|
+
add_count++
|
|
187
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
188
|
+
}))
|
|
189
|
+
equal(add_count, 0)
|
|
190
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
|
|
191
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
192
|
+
equal(foobar$_(ctx)._, 2)
|
|
193
|
+
equal(foobar_(ctx), 2)
|
|
194
|
+
equal(add_count, 1)
|
|
195
|
+
equal(add_dep_(ctx), 3)
|
|
196
|
+
foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
|
|
197
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
|
|
198
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
199
|
+
equal(foobar$_(ctx)._, 5)
|
|
200
|
+
equal(foobar_(ctx), 5)
|
|
201
|
+
equal(add_count, 2)
|
|
202
|
+
equal(add_dep_(ctx), 7)
|
|
203
|
+
base__set(ctx, 2)
|
|
204
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
|
|
205
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
206
|
+
equal(foobar$_(ctx)._, 5)
|
|
207
|
+
equal(foobar_(ctx), 5)
|
|
208
|
+
equal(add_count, 2)
|
|
209
|
+
equal(add_dep_(ctx), 7)
|
|
210
|
+
})
|
|
211
|
+
test('id_be_lock_memosig_triple_', ()=>{
|
|
212
|
+
const ctx = ctx__new()
|
|
213
|
+
let add_count = 0
|
|
214
|
+
const [
|
|
215
|
+
,
|
|
216
|
+
base_,
|
|
217
|
+
base__set,
|
|
218
|
+
] = be_sig_triple_(
|
|
219
|
+
()=>1)
|
|
220
|
+
const [
|
|
221
|
+
,
|
|
222
|
+
add_dep_,
|
|
223
|
+
add_dep__set
|
|
224
|
+
] = be_sig_triple_(()=>1)
|
|
225
|
+
const [
|
|
226
|
+
foobar$_,
|
|
227
|
+
foobar_,
|
|
228
|
+
foobar__set,
|
|
229
|
+
] = id_be_lock_memosig_triple_(
|
|
230
|
+
'foobar',
|
|
231
|
+
ctx=>{
|
|
232
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
233
|
+
type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<''>>>
|
|
234
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
235
|
+
return base_(ctx) + 1
|
|
236
|
+
},
|
|
237
|
+
).add((ctx, foobar$)=>memo_(()=>{
|
|
238
|
+
add_count++
|
|
239
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
240
|
+
}))
|
|
241
|
+
equal(add_count, 0)
|
|
242
|
+
equal(foobar$_(ctx)._, 2)
|
|
243
|
+
equal(foobar_(ctx), 2)
|
|
244
|
+
equal(add_count, 1)
|
|
245
|
+
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 2)
|
|
246
|
+
equal(add_dep_(ctx), 3)
|
|
247
|
+
foobar__set(ctx, 5)
|
|
248
|
+
equal(foobar$_(ctx)._, 5)
|
|
249
|
+
equal(foobar_(ctx), 5)
|
|
250
|
+
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 5)
|
|
251
|
+
equal(add_count, 2)
|
|
252
|
+
equal(add_dep_(ctx), 7)
|
|
253
|
+
base__set(ctx, 2)
|
|
254
|
+
equal(foobar$_(ctx)._, 5)
|
|
255
|
+
equal(foobar_(ctx), 5)
|
|
256
|
+
equal(add_count, 2)
|
|
257
|
+
equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 5)
|
|
258
|
+
equal(add_dep_(ctx), 7)
|
|
259
|
+
})
|
|
260
|
+
test('ns_id_be_lock_memosig_triple_', ()=>{
|
|
261
|
+
const ctx = ns_ctx__new('test_ns')
|
|
262
|
+
let add_count = 0
|
|
263
|
+
const [
|
|
264
|
+
,
|
|
265
|
+
base_,
|
|
266
|
+
base__set,
|
|
267
|
+
] = be_sig_triple_(
|
|
268
|
+
()=>1,
|
|
269
|
+
{ ns: 'test_ns' })
|
|
270
|
+
const [
|
|
271
|
+
,
|
|
272
|
+
add_dep_,
|
|
273
|
+
add_dep__set
|
|
274
|
+
] = be_sig_triple_(()=>1,
|
|
275
|
+
{ ns: 'test_ns' })
|
|
276
|
+
const [
|
|
277
|
+
foobar$_,
|
|
278
|
+
foobar_,
|
|
279
|
+
foobar__set,
|
|
280
|
+
] = ns_id_be_lock_memosig_triple_(
|
|
281
|
+
'test_ns',
|
|
282
|
+
'foobar',
|
|
283
|
+
ctx=>{
|
|
284
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
285
|
+
type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
|
|
286
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
287
|
+
return base_(ctx) + 1
|
|
288
|
+
},
|
|
289
|
+
).add((ctx, foobar$)=>memo_(()=>{
|
|
290
|
+
add_count++
|
|
291
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
292
|
+
}))
|
|
293
|
+
equal(add_count, 0)
|
|
294
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
|
|
295
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
296
|
+
equal(foobar$_(ctx)._, 2)
|
|
297
|
+
equal(foobar_(ctx), 2)
|
|
298
|
+
equal(add_count, 1)
|
|
299
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)._, 2)
|
|
300
|
+
equal(add_dep_(ctx), 3)
|
|
301
|
+
foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
|
|
302
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
|
|
303
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
304
|
+
equal(foobar$_(ctx)._, 5)
|
|
305
|
+
equal(foobar_(ctx), 5)
|
|
306
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)._, 5)
|
|
307
|
+
equal(add_count, 2)
|
|
308
|
+
equal(add_dep_(ctx), 7)
|
|
309
|
+
base__set(ctx, 2)
|
|
310
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
|
|
311
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
|
|
312
|
+
equal(foobar$_(ctx)._, 5)
|
|
313
|
+
equal(foobar_(ctx), 5)
|
|
314
|
+
equal(add_count, 2)
|
|
315
|
+
equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)._, 5)
|
|
316
|
+
equal(add_dep_(ctx), 7)
|
|
317
|
+
})
|
|
152
318
|
test.run()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Be,
|
|
1
|
+
import type { Be, be_config_arg_a_T, ctx__be_T, ctx__get_T, Ctx_wide_T } from '../be_/index.js'
|
|
2
2
|
import type { memo_T, sig_T } from '../rmemo/index.js'
|
|
3
3
|
export declare function be_memo_pair_<
|
|
4
4
|
val_T,
|
|
@@ -12,7 +12,35 @@ export declare function be_memo_pair_<
|
|
|
12
12
|
E = unknown,
|
|
13
13
|
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
14
14
|
>(
|
|
15
|
-
rmemo__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
|
|
15
|
+
rmemo__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
|
|
16
|
+
...config:be_config_arg_a_T<ns_T>
|
|
17
|
+
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
18
|
+
export declare function ns_be_memo_pair_<
|
|
19
|
+
val_T,
|
|
20
|
+
ns_T extends string,
|
|
21
|
+
E = unknown,
|
|
22
|
+
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
23
|
+
>(
|
|
24
|
+
ns:ns_T,
|
|
25
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
26
|
+
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
27
|
+
export declare function id_be_memo_pair_<
|
|
28
|
+
val_T,
|
|
29
|
+
E = unknown,
|
|
30
|
+
ctx_T extends Ctx_wide_T<''> = Ctx_wide_T<''>,
|
|
31
|
+
>(
|
|
32
|
+
id:string,
|
|
33
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
34
|
+
):be_memo_pair_T<val_T, '', E, ctx_T>
|
|
35
|
+
export declare function ns_id_be_memo_pair_<
|
|
36
|
+
val_T,
|
|
37
|
+
ns_T extends string,
|
|
38
|
+
E = unknown,
|
|
39
|
+
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
40
|
+
>(
|
|
41
|
+
ns:ns_T,
|
|
42
|
+
id:string,
|
|
43
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
16
44
|
):be_memo_pair_T<val_T, ns_T, E, ctx_T>
|
|
17
45
|
export type be_memo_pair_T<
|
|
18
46
|
val_T,
|
|
@@ -11,7 +11,7 @@ import { memo_ } from '../rmemo/index.js'
|
|
|
11
11
|
*/
|
|
12
12
|
export function be_memo_pair_(
|
|
13
13
|
be_OR_val__new,
|
|
14
|
-
config
|
|
14
|
+
config,
|
|
15
15
|
) {
|
|
16
16
|
let add_def_a = []
|
|
17
17
|
/** @type {Be} */
|
|
@@ -20,8 +20,10 @@ export function be_memo_pair_(
|
|
|
20
20
|
? be_OR_val__new
|
|
21
21
|
: be_(ctx=>
|
|
22
22
|
add_def_a.reduce(
|
|
23
|
-
(memo, add_def)=>
|
|
24
|
-
|
|
23
|
+
(memo, add_def)=>
|
|
24
|
+
memo.add((...arg_a)=>add_def(ctx, ...arg_a)),
|
|
25
|
+
memo_(
|
|
26
|
+
memo=>be_OR_val__new(ctx, memo))),
|
|
25
27
|
config)
|
|
26
28
|
let be_memo_pair = [
|
|
27
29
|
be,
|
|
@@ -36,3 +38,41 @@ export function be_memo_pair_(
|
|
|
36
38
|
}
|
|
37
39
|
return be_memo_pair
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @param {string}ns
|
|
43
|
+
* @param {be__val__new_T<unknown>}val__new
|
|
44
|
+
* @returns {be_memo_pair_T}
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
export function ns_be_memo_pair_(
|
|
48
|
+
ns,
|
|
49
|
+
val__new
|
|
50
|
+
) {
|
|
51
|
+
return be_memo_pair_(val__new, { ns })
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @param {string}id
|
|
55
|
+
* @param {be__val__new_T<unknown>}val__new
|
|
56
|
+
* @returns {be_memo_pair_T}
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
export function id_be_memo_pair_(
|
|
60
|
+
id,
|
|
61
|
+
val__new
|
|
62
|
+
) {
|
|
63
|
+
return be_memo_pair_(val__new, { id })
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param {string}ns
|
|
67
|
+
* @param {string}id
|
|
68
|
+
* @param {be__val__new_T<unknown>}val__new
|
|
69
|
+
* @returns {be_memo_pair_T}
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
export function ns_id_be_memo_pair_(
|
|
73
|
+
ns,
|
|
74
|
+
id,
|
|
75
|
+
val__new
|
|
76
|
+
) {
|
|
77
|
+
return be_memo_pair_(val__new, { ns, id })
|
|
78
|
+
}
|
|
@@ -5,7 +5,7 @@ import { 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_, type memo_T } from '../rmemo/index.js'
|
|
7
7
|
import type { Equal, Expect } from '../test/index.js'
|
|
8
|
-
import { be_memo_pair_ } from './index.js'
|
|
8
|
+
import { be_memo_pair_, id_be_memo_pair_, ns_be_memo_pair_, ns_id_be_memo_pair_ } from './index.js'
|
|
9
9
|
test('be_memo_pair_', ()=>{
|
|
10
10
|
const [
|
|
11
11
|
,
|
|
@@ -36,7 +36,7 @@ test('be_memo_pair_', ()=>{
|
|
|
36
36
|
equal(foobar_(ctx), 3)
|
|
37
37
|
equal(foobar$_(ctx).count, 2)
|
|
38
38
|
})
|
|
39
|
-
test('be_memo_pair_|+id|+ns|+
|
|
39
|
+
test('be_memo_pair_|+id|+ns|+add', ()=>{
|
|
40
40
|
const ctx = ns_ctx__new('test_ns')
|
|
41
41
|
let add_count = 0
|
|
42
42
|
const [
|
|
@@ -149,4 +149,132 @@ test('be_memo_pair_|be', ()=>{
|
|
|
149
149
|
equal(foobar$_(ctx).custom, 'custom-val')
|
|
150
150
|
equal(add_count, 1)
|
|
151
151
|
})
|
|
152
|
+
test('ns_be_memo_pair_', ()=>{
|
|
153
|
+
const ctx = ns_ctx__new('test_ns')
|
|
154
|
+
let add_count = 0
|
|
155
|
+
const [
|
|
156
|
+
,
|
|
157
|
+
add_dep_,
|
|
158
|
+
add_dep__set
|
|
159
|
+
] = be_sig_triple_(()=>1,
|
|
160
|
+
{ ns: 'test_ns' })
|
|
161
|
+
const [
|
|
162
|
+
,
|
|
163
|
+
base_,
|
|
164
|
+
base__set,
|
|
165
|
+
] = be_sig_triple_(()=>1,
|
|
166
|
+
{ ns: 'test_ns' })
|
|
167
|
+
const [
|
|
168
|
+
foobar$_,
|
|
169
|
+
foobar_,
|
|
170
|
+
] = ns_be_memo_pair_(
|
|
171
|
+
'test_ns',
|
|
172
|
+
ctx=>base_(ctx) + 1,
|
|
173
|
+
).add((ctx, foobar$)=>memo_(()=>{
|
|
174
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
175
|
+
type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
|
|
176
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
177
|
+
add_count++
|
|
178
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
179
|
+
}))
|
|
180
|
+
equal(add_count, 0)
|
|
181
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
|
|
182
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
183
|
+
equal(foobar$_(ctx)._, 2)
|
|
184
|
+
equal(foobar_(ctx), 2)
|
|
185
|
+
equal(add_count, 1)
|
|
186
|
+
equal(add_dep_(ctx), 3)
|
|
187
|
+
base__set(ctx, 2)
|
|
188
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
|
|
189
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
|
|
190
|
+
equal(foobar$_(ctx)._, 3)
|
|
191
|
+
equal(foobar_(ctx), 3)
|
|
192
|
+
equal(add_count, 2)
|
|
193
|
+
equal(add_dep_(ctx), 5)
|
|
194
|
+
})
|
|
195
|
+
test('id_be_memo_pair_', ()=>{
|
|
196
|
+
const ctx = ctx__new()
|
|
197
|
+
let add_count = 0
|
|
198
|
+
const [
|
|
199
|
+
,
|
|
200
|
+
add_dep_,
|
|
201
|
+
add_dep__set
|
|
202
|
+
] = be_sig_triple_(()=>1)
|
|
203
|
+
const [
|
|
204
|
+
,
|
|
205
|
+
base_,
|
|
206
|
+
base__set,
|
|
207
|
+
] = be_sig_triple_(()=>1)
|
|
208
|
+
const [
|
|
209
|
+
foobar$_,
|
|
210
|
+
foobar_,
|
|
211
|
+
] = id_be_memo_pair_(
|
|
212
|
+
'foobar',
|
|
213
|
+
ctx=>base_(ctx) + 1
|
|
214
|
+
).add((ctx, foobar$)=>memo_(()=>{
|
|
215
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
216
|
+
type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<''>>>
|
|
217
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
218
|
+
add_count++
|
|
219
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
220
|
+
}))
|
|
221
|
+
equal(add_count, 0)
|
|
222
|
+
equal(foobar$_(ctx)._, 2)
|
|
223
|
+
equal(foobar_(ctx), 2)
|
|
224
|
+
equal((ctx.s[''].get('foobar')![0] as memo_T<number>)._, 2)
|
|
225
|
+
equal(add_count, 1)
|
|
226
|
+
equal(add_dep_(ctx), 3)
|
|
227
|
+
base__set(ctx, 2)
|
|
228
|
+
equal(foobar$_(ctx)._, 3)
|
|
229
|
+
equal(foobar_(ctx), 3)
|
|
230
|
+
equal((ctx.s[''].get('foobar')![0] as memo_T<number>)._, 3)
|
|
231
|
+
equal(add_count, 2)
|
|
232
|
+
equal(add_dep_(ctx), 5)
|
|
233
|
+
})
|
|
234
|
+
test('ns_id_be_memo_pair_', ()=>{
|
|
235
|
+
const ctx = ns_ctx__new('test_ns')
|
|
236
|
+
let add_count = 0
|
|
237
|
+
const [
|
|
238
|
+
,
|
|
239
|
+
add_dep_,
|
|
240
|
+
add_dep__set
|
|
241
|
+
] = be_sig_triple_(()=>1,
|
|
242
|
+
{ ns: 'test_ns' })
|
|
243
|
+
const [
|
|
244
|
+
,
|
|
245
|
+
base_,
|
|
246
|
+
base__set,
|
|
247
|
+
] = be_sig_triple_(()=>1,
|
|
248
|
+
{ ns: 'test_ns' })
|
|
249
|
+
const [
|
|
250
|
+
foobar$_,
|
|
251
|
+
foobar_,
|
|
252
|
+
] = ns_id_be_memo_pair_(
|
|
253
|
+
'test_ns',
|
|
254
|
+
'foobar',
|
|
255
|
+
ctx=>base_(ctx) + 1
|
|
256
|
+
).add((ctx, foobar$)=>memo_(()=>{
|
|
257
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
258
|
+
type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
|
|
259
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
260
|
+
add_count++
|
|
261
|
+
add_dep__set(ctx, add_count + foobar$())
|
|
262
|
+
}))
|
|
263
|
+
equal(add_count, 0)
|
|
264
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
|
|
265
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
|
|
266
|
+
equal(foobar$_(ctx)._, 2)
|
|
267
|
+
equal(foobar_(ctx), 2)
|
|
268
|
+
equal((ctx.s.test_ns.get('foobar')![0] as memo_T<number>)._, 2)
|
|
269
|
+
equal(add_count, 1)
|
|
270
|
+
equal(add_dep_(ctx), 3)
|
|
271
|
+
base__set(ctx, 2)
|
|
272
|
+
equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
|
|
273
|
+
equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
|
|
274
|
+
equal(foobar$_(ctx)._, 3)
|
|
275
|
+
equal(foobar_(ctx), 3)
|
|
276
|
+
equal((ctx.s.test_ns.get('foobar')![0] as memo_T<number>)._, 3)
|
|
277
|
+
equal(add_count, 2)
|
|
278
|
+
equal(add_dep_(ctx), 5)
|
|
279
|
+
})
|
|
152
280
|
test.run()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Be,
|
|
1
|
+
import type { Be, be_config_arg_a_T, ctx__be_T, ctx__get_T, ctx__set_T, Ctx_wide_T } from '../be_/index.js'
|
|
2
2
|
import type { sig_T } from '../rmemo/index.js'
|
|
3
3
|
export declare function be_memosig_triple_<
|
|
4
4
|
val_T,
|
|
@@ -13,7 +13,34 @@ export declare function be_memosig_triple_<
|
|
|
13
13
|
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
14
14
|
>(
|
|
15
15
|
rmemo__new:(ctx:ctx_T, memosig:sig_T<val_T, E>)=>val_T,
|
|
16
|
-
config
|
|
16
|
+
...config:be_config_arg_a_T<ns_T>
|
|
17
|
+
):be_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
18
|
+
export declare function ns_be_memosig_triple_<
|
|
19
|
+
val_T,
|
|
20
|
+
ns_T extends string,
|
|
21
|
+
E = unknown,
|
|
22
|
+
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
23
|
+
>(
|
|
24
|
+
ns:ns_T,
|
|
25
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
26
|
+
):be_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
27
|
+
export declare function id_be_memosig_triple_<
|
|
28
|
+
val_T,
|
|
29
|
+
E = unknown,
|
|
30
|
+
ctx_T extends Ctx_wide_T<''> = Ctx_wide_T<''>,
|
|
31
|
+
>(
|
|
32
|
+
id:string,
|
|
33
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
34
|
+
):be_memosig_triple_T<val_T, '', E, ctx_T>
|
|
35
|
+
export declare function ns_id_be_memosig_triple_<
|
|
36
|
+
val_T,
|
|
37
|
+
ns_T extends string,
|
|
38
|
+
E = unknown,
|
|
39
|
+
ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
|
|
40
|
+
>(
|
|
41
|
+
ns:ns_T,
|
|
42
|
+
id:string,
|
|
43
|
+
val__new:(ctx:ctx_T)=>val_T,
|
|
17
44
|
):be_memosig_triple_T<val_T, ns_T, E, ctx_T>
|
|
18
45
|
export type be_memosig_triple_T<
|
|
19
46
|
val_T,
|
|
@@ -2,5 +2,10 @@
|
|
|
2
2
|
/// <reference types="../be_sig_triple/index.d.ts" />
|
|
3
3
|
/// <reference types="../rmemo/index.d.ts" />
|
|
4
4
|
/// <reference types="./index.d.ts" />
|
|
5
|
-
import { be_memo_pair_ } from '../be_memo_pair/index.js'
|
|
6
|
-
export {
|
|
5
|
+
import { be_memo_pair_, id_be_memo_pair_, ns_be_memo_pair_, ns_id_be_memo_pair_ } from '../be_memo_pair/index.js'
|
|
6
|
+
export {
|
|
7
|
+
be_memo_pair_ as be_memosig_triple_,
|
|
8
|
+
ns_be_memo_pair_ as ns_be_memosig_triple_,
|
|
9
|
+
id_be_memo_pair_ as id_be_memosig_triple_,
|
|
10
|
+
ns_id_be_memo_pair_ as ns_id_be_memosig_triple_,
|
|
11
|
+
}
|