ctx-core 5.23.0 → 5.25.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.
@@ -17,7 +17,35 @@ 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?:be_config_T<ns_T>
20
+ ...config:be_config_arg_a_T<ns_T>
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>]
26
+ export declare function ns_be_<
27
+ val_T,
28
+ ns_T extends string,
29
+ ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
30
+ >(
31
+ ns:ns_T,
32
+ val__new:be__val__new_T<val_T, ns_T, ctx_T>
33
+ ):Be<val_T, ns_T, ctx_T>
34
+ export declare function id_be_<
35
+ val_T,
36
+ ctx_T extends Ctx_wide_T<''> = Ctx_wide_T<''>,
37
+ >(
38
+ id:string,
39
+ val__new:be__val__new_T<val_T, '', ctx_T>
40
+ ):Be<val_T, '', ctx_T>
41
+ export declare function ns_id_be_<
42
+ val_T,
43
+ ns_T extends string,
44
+ ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
45
+ >(
46
+ ns:ns_T,
47
+ id:string,
48
+ val__new:be__val__new_T<val_T, ns_T, ctx_T>
21
49
  ):Be<val_T, ns_T, ctx_T>
22
50
  export declare function ctx__set<
23
51
  val_T,
@@ -88,10 +116,10 @@ export type be_o_T<
88
116
  ns:ns_T
89
117
  is_be:true
90
118
  }
91
- export type be_config_T<ns_T extends string = string> = {
92
- id?:string
93
- ns?:ns_T
94
- }
119
+ export type be_config_T<ns_T extends string = string> =
120
+ ns_T extends ''
121
+ ? { id?:string, ns?:ns_T }
122
+ : { id?:string, ns:ns_T }
95
123
  export type BeMap<
96
124
  ns_T extends string = ''
97
125
  > =
package/all/be_/index.js CHANGED
@@ -40,6 +40,34 @@ export function be_(val__new, config) {
40
40
  be.is_be = true
41
41
  return be
42
42
  }
43
+ /**
44
+ * @param {string}ns
45
+ * @param {be__val__new_T}val__new
46
+ * @returns {Be}
47
+ * @private
48
+ */
49
+ export function ns_be_(ns, val__new) {
50
+ return be_(val__new, { ns })
51
+ }
52
+ /**
53
+ * @param {string}id
54
+ * @param {be__val__new_T}val__new
55
+ * @returns {Be}
56
+ * @private
57
+ */
58
+ export function id_be_(id, val__new) {
59
+ return be_(val__new, { id })
60
+ }
61
+ /**
62
+ * @param {string}ns
63
+ * @param {string}id
64
+ * @param {be__val__new_T}val__new
65
+ * @returns {Be}
66
+ * @private
67
+ */
68
+ export function ns_id_be_(ns, id, val__new) {
69
+ return be_(val__new, { ns, id })
70
+ }
43
71
  /**
44
72
  * Auto-memoization function for the Ctx.
45
73
  * Memoized on globalThis to allow packages being loaded multiple times, which can happen during bundling.
@@ -19,7 +19,7 @@ import {
19
19
  type Ctx_s_T,
20
20
  type Ctx_s_wide_T,
21
21
  type Ctx_wide_T,
22
- globalThis__be_,
22
+ globalThis__be_, id_be_, ns_be_, ns_id_be_,
23
23
  ondelete_be_
24
24
  } from '../be_/index.js'
25
25
  import { ctx__new, ns_ctx__new } from '../ctx/index.js'
@@ -88,7 +88,9 @@ test('be_|ns_ctx__new', ()=>{
88
88
  equal(ctx1.s[''].has(root_.id), false)
89
89
  equal(ctx2.s[''].has(root_.id), false)
90
90
  equal(ctx3.s[''].has(root_.id), true)
91
- const child_ = be_(ctx=>root_(ctx) + 1, { id: 'child_' })
91
+ const child_ = be_(
92
+ ctx=>root_(ctx) + 1,
93
+ { id: 'child_' })
92
94
  equal(child_(ctx), 2)
93
95
  equal(ctx0.s[''].has(child_.id), true)
94
96
  equal(ctx1.s[''].has(child_.id), false)
@@ -101,13 +103,14 @@ test('be_|ns', ()=>{
101
103
  const ctx1 = ns_ctx__new('ctx1')
102
104
  const ctx = ns_ctx__new(ctx0, ctx1)
103
105
  const be__ctx_a:Ctx_wide_T<'ctx1'>[] = []
104
- const root_ = be_(ctx=>{
105
- be__ctx_a.push(ctx)
106
- return 1
107
- }, {
108
- ns: 'ctx1',
109
- id: 'root_'
110
- })
106
+ const root_ = be_<number, 'ctx1'>(
107
+ ctx=>{
108
+ be__ctx_a.push(ctx)
109
+ return 1
110
+ }, {
111
+ id: 'root_',
112
+ ns: 'ctx1',
113
+ })
111
114
  equal(root_(ctx), 1)
112
115
  equal(be__ctx_a, [ctx])
113
116
  // @ts-expect-error TS2322
@@ -148,7 +151,7 @@ test('be_|ns|types', ()=>{
148
151
  ? typeof ctx
149
152
  : never>>
150
153
  type test_ctx_Ctx = Expect<Equal<typeof ctx, Ctx<''|'ctx1'>>>
151
- const root_ = be_(
154
+ const root_ = be_<number, 'ctx1'>(
152
155
  ctx=>{
153
156
  type test_be_ctx_argument = Expect<Equal<typeof ctx, Ctx_wide_T<'ctx1'>>>
154
157
  return 1
@@ -207,6 +210,29 @@ test('be_|circular dependency|DEBUG=1', async ()=>{
207
210
  await unlink(tempfile)
208
211
  }
209
212
  })
213
+ test('ns_be_', ()=>{
214
+ const valid_ctx = ns_ctx__new('test_ns')
215
+ const val_ = ns_be_('test_ns', ()=>true)
216
+ equal(val_(valid_ctx), true)
217
+ // @ts-expect-error TS2322
218
+ throws(()=>val_(ctx__new()))
219
+ })
220
+ test('id_be_', ()=>{
221
+ const valid_ctx = ctx__new()
222
+ const val_ = id_be_('test_id', ()=>true)
223
+ equal(val_(valid_ctx), true)
224
+ equal(val_.id, 'test_id')
225
+ // @ts-expect-error TS2322
226
+ throws(()=>val_(ns_ctx__new('test_ns')))
227
+ })
228
+ test('ns_id_be_', ()=>{
229
+ const valid_ctx = ns_ctx__new('test_ns')
230
+ const val_ = ns_id_be_('test_ns', 'test_id', ()=>true)
231
+ equal(val_(valid_ctx), true)
232
+ equal(val_.id, 'test_id')
233
+ // @ts-expect-error TS2322
234
+ throws(()=>val_(ctx__new()))
235
+ })
210
236
  test('ctx__set', ()=>{
211
237
  const ctx0 = ns_ctx__new('ctx0')
212
238
  const ctx1 = ctx__new()
@@ -288,8 +314,7 @@ test('ctx__delete|be', ()=>{
288
314
  // @ts-expect-error TS7053
289
315
  equal(ctx1.s[''], undefined)
290
316
  const ns__num_ =
291
- be_(()=>1,
292
- { ns: 'ctx1' })
317
+ ns_be_('ctx1', ()=>1)
293
318
  ns__num_(ns_ctx)
294
319
  // @ts-expect-error TS2345
295
320
  equal(ctx0.s[''].has(ns__num_.id), false)
@@ -1,4 +1,4 @@
1
- import type { Be, be_config_T, ctx__be_T, ctx__get_T, ctx__set_T, Ctx_wide_T, } from '../be_/index.js'
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?:be_config_T<ns_T>
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 { be_lock_memosig_triple_ } from './index.js'
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, be_config_T, ctx__be_T, ctx__get_T, Ctx_wide_T } from '../be_/index.js'
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,
@@ -13,7 +13,34 @@ export declare function be_memo_pair_<
13
13
  ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
14
14
  >(
15
15
  rmemo__new:(ctx:ctx_T, memo:sig_T<val_T, E>)=>val_T,
16
- config?:be_config_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,
17
44
  ):be_memo_pair_T<val_T, ns_T, E, ctx_T>
18
45
  export type be_memo_pair_T<
19
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)=>memo.add((...arg_a)=>add_def(ctx, ...arg_a)),
24
- memo_(memo=>be_OR_val__new(ctx, memo))),
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|+oninit|+add', ()=>{
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, be_config_T, ctx__be_T, ctx__get_T, ctx__set_T, Ctx_wide_T } from '../be_/index.js'
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?:be_config_T<ns_T>
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 { be_memo_pair_ as be_memosig_triple_ }
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
+ }
@@ -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_, memosig_, type sig_T } from '../rmemo/index.js'
7
7
  import type { Equal, Expect } from '../test/index.js'
8
- import { be_memosig_triple_ } from './index.js'
8
+ import { be_memosig_triple_, id_be_memosig_triple_, ns_be_memosig_triple_, ns_id_be_memosig_triple_ } from './index.js'
9
9
  test('be_memosig_triple_', ()=>{
10
10
  const [
11
11
  ,
@@ -60,7 +60,7 @@ test('be_memosig_triple_|+id|+ns', ()=>{
60
60
  foobar$_,
61
61
  foobar_,
62
62
  foobar__set,
63
- ] = be_memosig_triple_(
63
+ ] = be_memosig_triple_<number, 'test_ns'>(
64
64
  ctx=>{
65
65
  /* eslint-disable @typescript-eslint/no-unused-vars */
66
66
  type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
@@ -154,4 +154,174 @@ test('be_memosig_triple_|+be', ()=>{
154
154
  equal(foobar$_(ctx).custom, 'custom-val')
155
155
  equal(add_count, 3)
156
156
  })
157
+ test('ns_be_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_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
+ /* eslint-disable @typescript-eslint/no-unused-vars */
187
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
188
+ /* eslint-enable @typescript-eslint/no-unused-vars */
189
+ add_count++
190
+ add_dep__set(ctx, add_count + foobar$())
191
+ }))
192
+ equal(add_count, 0)
193
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
194
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
195
+ equal(foobar$_(ctx)._, 2)
196
+ equal(foobar_(ctx), 2)
197
+ equal(add_count, 1)
198
+ equal(add_dep_(ctx), 3)
199
+ foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
200
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
201
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
202
+ equal(foobar$_(ctx)._, 5)
203
+ equal(foobar_(ctx), 5)
204
+ equal(add_count, 2)
205
+ equal(add_dep_(ctx), 7)
206
+ base__set(ctx, 2)
207
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
208
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
209
+ equal(foobar$_(ctx)._, 3)
210
+ equal(foobar_(ctx), 3)
211
+ equal(add_count, 3)
212
+ equal(add_dep_(ctx), 6)
213
+ })
214
+ test('id_be_memosig_triple_', ()=>{
215
+ const ctx = ctx__new()
216
+ let add_count = 0
217
+ const [
218
+ ,
219
+ base_,
220
+ base__set,
221
+ ] = be_sig_triple_(
222
+ ()=>1)
223
+ const [
224
+ ,
225
+ add_dep_,
226
+ add_dep__set
227
+ ] = be_sig_triple_(()=>1)
228
+ const [
229
+ foobar$_,
230
+ foobar_,
231
+ foobar__set,
232
+ ] = id_be_memosig_triple_(
233
+ 'foobar',
234
+ ctx=>{
235
+ /* eslint-disable @typescript-eslint/no-unused-vars */
236
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<''>>>
237
+ /* eslint-enable @typescript-eslint/no-unused-vars */
238
+ return base_(ctx) + 1
239
+ }
240
+ ).add((ctx, foobar$)=>memo_(()=>{
241
+ /* eslint-disable @typescript-eslint/no-unused-vars */
242
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<''>>>
243
+ /* eslint-enable @typescript-eslint/no-unused-vars */
244
+ add_count++
245
+ add_dep__set(ctx, add_count + foobar$())
246
+ }))
247
+ equal(add_count, 0)
248
+ equal(foobar$_(ctx)._, 2)
249
+ equal(foobar_(ctx), 2)
250
+ equal(add_count, 1)
251
+ equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 2)
252
+ equal(add_dep_(ctx), 3)
253
+ foobar__set(ctx, 5)
254
+ equal(foobar$_(ctx)._, 5)
255
+ equal(foobar_(ctx), 5)
256
+ equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 5)
257
+ equal(add_count, 2)
258
+ equal(add_dep_(ctx), 7)
259
+ base__set(ctx, 2)
260
+ equal(foobar$_(ctx)._, 3)
261
+ equal(foobar_(ctx), 3)
262
+ equal(add_count, 3)
263
+ equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 3)
264
+ equal(add_dep_(ctx), 6)
265
+ })
266
+ test('ns_id_be_memosig_triple_', ()=>{
267
+ const ctx = ns_ctx__new('test_ns')
268
+ let add_count = 0
269
+ const [
270
+ ,
271
+ base_,
272
+ base__set,
273
+ ] = be_sig_triple_(
274
+ ()=>1,
275
+ { ns: 'test_ns' })
276
+ const [
277
+ ,
278
+ add_dep_,
279
+ add_dep__set
280
+ ] = be_sig_triple_(()=>1,
281
+ { ns: 'test_ns' })
282
+ const [
283
+ foobar$_,
284
+ foobar_,
285
+ foobar__set,
286
+ ] = ns_id_be_memosig_triple_(
287
+ 'test_ns',
288
+ 'foobar',
289
+ ctx=>{
290
+ /* eslint-disable @typescript-eslint/no-unused-vars */
291
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
292
+ /* eslint-enable @typescript-eslint/no-unused-vars */
293
+ return base_(ctx) + 1
294
+ },
295
+ ).add((ctx, foobar$)=>memo_(()=>{
296
+ /* eslint-disable @typescript-eslint/no-unused-vars */
297
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
298
+ /* eslint-enable @typescript-eslint/no-unused-vars */
299
+ add_count++
300
+ add_dep__set(ctx, add_count + foobar$())
301
+ }))
302
+ equal(add_count, 0)
303
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
304
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
305
+ equal(foobar$_(ctx)._, 2)
306
+ equal(foobar_(ctx), 2)
307
+ equal(add_count, 1)
308
+ equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
309
+ equal(add_dep_(ctx), 3)
310
+ foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
311
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
312
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
313
+ equal(foobar$_(ctx)._, 5)
314
+ equal(foobar_(ctx), 5)
315
+ equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 5)
316
+ equal(add_count, 2)
317
+ equal(add_dep_(ctx), 7)
318
+ base__set(ctx, 2)
319
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
320
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
321
+ equal(foobar$_(ctx)._, 3)
322
+ equal(foobar_(ctx), 3)
323
+ equal(add_count, 3)
324
+ equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 3)
325
+ equal(add_dep_(ctx), 6)
326
+ })
157
327
  test.run()
@@ -1,4 +1,4 @@
1
- import type { Be, be_config_T, ctx__be_T, ctx__get_T, ctx__set_T, Ctx_wide_T } from '../be_/index.js'
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_sig_triple_<
4
4
  val_T,
@@ -13,7 +13,34 @@ export declare function be_sig_triple_<
13
13
  ctx_T extends Ctx_wide_T<ns_T> = Ctx_wide_T<ns_T>,
14
14
  >(
15
15
  val__new:(ctx:ctx_T)=>val_T,
16
- config?:be_config_T<ns_T>
16
+ ...config:be_config_arg_a_T<ns_T>
17
+ ):be_sig_triple_T<val_T, ns_T, E, ctx_T>
18
+ export declare function ns_be_sig_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_sig_triple_T<val_T, ns_T, E, ctx_T>
27
+ export declare function id_be_sig_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_sig_triple_T<val_T, '', E, ctx_T>
35
+ export declare function ns_id_be_sig_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_sig_triple_T<val_T, ns_T, E, ctx_T>
18
45
  export type be_sig_triple_T<
19
46
  val_T,
@@ -36,3 +36,41 @@ export function be_sig_triple_(
36
36
  }
37
37
  return be_sig_triple
38
38
  }
39
+ /**
40
+ * @param {string}ns
41
+ * @param {be__val__new_T<unknown>}val__new
42
+ * @returns {be_sig_triple_T}
43
+ * @private
44
+ */
45
+ export function ns_be_sig_triple_(
46
+ ns,
47
+ val__new
48
+ ) {
49
+ return be_sig_triple_(val__new, { ns })
50
+ }
51
+ /**
52
+ * @param {string}id
53
+ * @param {be__val__new_T<unknown>}val__new
54
+ * @returns {be_sig_triple_T}
55
+ * @private
56
+ */
57
+ export function id_be_sig_triple_(
58
+ id,
59
+ val__new
60
+ ) {
61
+ return be_sig_triple_(val__new, { id })
62
+ }
63
+ /**
64
+ * @param {string}ns
65
+ * @param {string}id
66
+ * @param {be__val__new_T<unknown>}val__new
67
+ * @returns {be_sig_triple_T}
68
+ * @private
69
+ */
70
+ export function ns_id_be_sig_triple_(
71
+ ns,
72
+ id,
73
+ val__new
74
+ ) {
75
+ return be_sig_triple_(val__new, { ns, id })
76
+ }
@@ -4,7 +4,7 @@ import { be_, type Ctx_wide_T } from '../be_/index.js'
4
4
  import { ctx__new, ns_ctx__new } from '../ctx/index.js'
5
5
  import { memo_, sig_, type sig_T } from '../rmemo/index.js'
6
6
  import type { Equal, Expect } from '../test/index.js'
7
- import { be_sig_triple_ } from './index.js'
7
+ import { be_sig_triple_, id_be_sig_triple_, ns_be_sig_triple_, ns_id_be_sig_triple_ } from './index.js'
8
8
  test('be_sig_triple_', ()=>{
9
9
  const [
10
10
  foobar$_,
@@ -24,7 +24,7 @@ test('be_sig_triple_', ()=>{
24
24
  equal(foobar$_(ctx)._, 2)
25
25
  equal(foobar_(ctx), 2)
26
26
  })
27
- test('be_sig_triple_|+id|+ns', ()=>{
27
+ test('be_sig_triple_|+id|+ns|+add', ()=>{
28
28
  const ctx = ns_ctx__new('test_ns')
29
29
  let add_count = 0
30
30
  const [
@@ -72,13 +72,13 @@ test('be_sig_triple_|+be', ()=>{
72
72
  foobar$_,
73
73
  foobar_,
74
74
  foobar__set,
75
- ] = be_sig_triple_<number, 'test_ns', { custom: string }>(
75
+ ] = be_sig_triple_<number, 'test_ns', { custom:string }>(
76
76
  be_(ctx=>{
77
77
  /* eslint-disable @typescript-eslint/no-unused-vars */
78
78
  type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
79
79
  /* eslint-enable @typescript-eslint/no-unused-vars */
80
80
  const foobar$ =
81
- sig_<number, { custom: string }>(
81
+ sig_<number, { custom:string }>(
82
82
  1
83
83
  ).add(()=>add_count++)
84
84
  foobar$.custom = 'custom-val'
@@ -101,4 +101,128 @@ test('be_sig_triple_|+be', ()=>{
101
101
  equal(foobar$_(ctx).custom, 'custom-val')
102
102
  equal(add_count, 1)
103
103
  })
104
+ test('ns_be_sig_triple_', ()=>{
105
+ const ctx = ns_ctx__new('test_ns')
106
+ let add_count = 0
107
+ const [
108
+ ,
109
+ add_dep_,
110
+ add_dep__set
111
+ ] = ns_be_sig_triple_(
112
+ 'test_ns',
113
+ ()=>1)
114
+ const [
115
+ foobar$_,
116
+ foobar_,
117
+ foobar__set,
118
+ ] = ns_be_sig_triple_(
119
+ 'test_ns',
120
+ ctx=>{
121
+ /* eslint-disable @typescript-eslint/no-unused-vars */
122
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
123
+ /* eslint-enable @typescript-eslint/no-unused-vars */
124
+ return 1
125
+ }
126
+ ).add((ctx, foobar$)=>memo_(()=>{
127
+ add_count++
128
+ add_dep__set(ctx, add_count + foobar$())
129
+ }))
130
+ equal(add_count, 0)
131
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 1)
132
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 1)
133
+ equal(foobar$_(ctx)._, 1)
134
+ equal(foobar_(ctx), 1)
135
+ equal(add_count, 1)
136
+ equal(add_dep_(ctx), 2)
137
+ foobar__set(ns_ctx__new(ctx__new(), ctx), 2)
138
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
139
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
140
+ equal(foobar$_(ctx)._, 2)
141
+ equal(foobar_(ctx), 2)
142
+ equal(add_count, 2)
143
+ equal(add_dep_(ctx), 4)
144
+ })
145
+ test('id_be_sig_triple_', ()=>{
146
+ const ctx = ctx__new()
147
+ let add_count = 0
148
+ const [
149
+ ,
150
+ add_dep_,
151
+ add_dep__set
152
+ ] = id_be_sig_triple_(
153
+ 'add_dep',
154
+ ()=>1)
155
+ const [
156
+ foobar$_,
157
+ foobar_,
158
+ foobar__set,
159
+ ] = id_be_sig_triple_(
160
+ 'foobar',
161
+ ctx=>{
162
+ /* eslint-disable @typescript-eslint/no-unused-vars */
163
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<''>>>
164
+ /* eslint-enable @typescript-eslint/no-unused-vars */
165
+ return 1
166
+ }
167
+ ).add((ctx, foobar$)=>memo_(()=>{
168
+ add_count++
169
+ add_dep__set(ctx, add_count + foobar$())
170
+ }))
171
+ equal(add_count, 0)
172
+ equal(foobar$_(ctx)._, 1)
173
+ equal(foobar_(ctx), 1)
174
+ equal(add_count, 1)
175
+ equal(add_dep_(ctx), 2)
176
+ equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 1)
177
+ foobar__set(ctx, 2)
178
+ equal(foobar$_(ctx)._, 2)
179
+ equal(foobar_(ctx), 2)
180
+ equal((ctx.s[''].get('foobar')![0] as sig_T<number>)._, 2)
181
+ equal(add_count, 2)
182
+ equal(add_dep_(ctx), 4)
183
+ })
184
+ test('ns_id_be_sig_triple_', ()=>{
185
+ const ctx = ns_ctx__new('test_ns')
186
+ let add_count = 0
187
+ const [
188
+ ,
189
+ add_dep_,
190
+ add_dep__set
191
+ ] = ns_id_be_sig_triple_(
192
+ 'test_ns',
193
+ 'app_dep',
194
+ ()=>1)
195
+ const [
196
+ foobar$_,
197
+ foobar_,
198
+ foobar__set,
199
+ ] = ns_id_be_sig_triple_(
200
+ 'test_ns',
201
+ 'foobar',
202
+ ctx=>{
203
+ /* eslint-disable @typescript-eslint/no-unused-vars */
204
+ type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
205
+ /* eslint-enable @typescript-eslint/no-unused-vars */
206
+ return 1
207
+ }).add((ctx, foobar$)=>memo_(()=>{
208
+ add_count++
209
+ add_dep__set(ctx, add_count + foobar$())
210
+ }))
211
+ equal(add_count, 0)
212
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 1)
213
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 1)
214
+ equal(foobar$_(ctx)._, 1)
215
+ equal(foobar_(ctx), 1)
216
+ equal(add_count, 1)
217
+ equal(add_dep_(ctx), 2)
218
+ equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 1)
219
+ foobar__set(ns_ctx__new(ctx__new(), ctx), 2)
220
+ equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
221
+ equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
222
+ equal(foobar$_(ctx)._, 2)
223
+ equal(foobar_(ctx), 2)
224
+ equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
225
+ equal(add_count, 2)
226
+ equal(add_dep_(ctx), 4)
227
+ })
104
228
  test.run()
@@ -2,8 +2,12 @@ import type { Ctx } from '../be_/index.js'
2
2
  import type { TupleToUnion } from '../tuple/index.js'
3
3
  export declare function ctx__new():Ctx<''>
4
4
  export { ctx__new as ctx_ }
5
- export declare function ns_ctx__new<ns0_T extends string|Ctx, ns_a_T extends (string|Ctx)[]>(
6
- ns0:ns0_T, ...ns_a:ns_a_T
5
+ export declare function ns_ctx__new<
6
+ ns0_T extends string|Ctx,
7
+ ns_a_T extends (string|Ctx)[]
8
+ >(
9
+ ns0:ns0_T,
10
+ ...ns_a:ns_a_T
7
11
  ):Ctx<Exclude<TupleToUnion<ns_a__flat_T<[ns0_T]>>|TupleToUnion<ns_a__flat_T<ns_a_T>>, undefined>>
8
12
  export { ns_ctx__new as ns_ctx_ }
9
13
  export declare function is_ctx_(val:unknown):boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-core",
3
- "version": "5.23.0",
3
+ "version": "5.25.0",
4
4
  "description": "ctx-core core library",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -188,14 +188,14 @@
188
188
  "import": {
189
189
  "./be": "{ be_, ctx_, ns_ctx_ }"
190
190
  },
191
- "limit": "190 B"
191
+ "limit": "191 B"
192
192
  },
193
193
  {
194
194
  "name": "be_ ctx_ ns_ctx_",
195
195
  "import": {
196
196
  "./be": "{ be_, ctx_, ns_ctx_ }"
197
197
  },
198
- "limit": "190 B"
198
+ "limit": "191 B"
199
199
  },
200
200
  {
201
201
  "name": "memo_",
@@ -223,7 +223,7 @@
223
223
  "import": {
224
224
  "./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
225
225
  },
226
- "limit": "576 B"
226
+ "limit": "570 B"
227
227
  },
228
228
  {
229
229
  "name": "uuid",