ctx-core 5.16.2 → 5.17.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.
@@ -6,23 +6,23 @@ test('batch_queue_(1).add|enqueue 1 at a time & run 1 at a time', async ()=>{
6
6
  const batch_queue = batch_queue_(1)
7
7
  const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
8
8
  const fn_a = [()=>promise_o_a[0].promise, ()=>promise_o_a[1].promise, ()=>promise_o_a[2].promise]
9
- const ret0_a:any[] = [null, null, null]
10
- const ret1_a:any[] = [null, null, null]
9
+ const ret0_a:unknown[] = [null, null, null]
10
+ const ret1_a:unknown[] = [null, null, null]
11
11
  batch_queue.add(fn_a[0])
12
- .then(([ret0, ret1_p])=>{
13
- ret0_a[0] = ret0
14
- ret1_p.then(ret0=>ret1_a[0] = ret0)
15
- })
12
+ .then(([ret0, ret1_p])=>{
13
+ ret0_a[0] = ret0
14
+ ret1_p.then(ret0=>ret1_a[0] = ret0)
15
+ })
16
16
  batch_queue.add(fn_a[1])
17
- .then(([ret0, ret1_p])=>{
18
- ret0_a[1] = ret0
19
- ret1_p.then(ret1=>ret1_a[1] = ret1)
20
- })
17
+ .then(([ret0, ret1_p])=>{
18
+ ret0_a[1] = ret0
19
+ ret1_p.then(ret1=>ret1_a[1] = ret1)
20
+ })
21
21
  batch_queue.add(fn_a[2])
22
- .then(([ret0, ret1_p])=>{
23
- ret0_a[2] = ret0
24
- ret1_p.then(ret1=>ret1_a[2] = ret1)
25
- })
22
+ .then(([ret0, ret1_p])=>{
23
+ ret0_a[2] = ret0
24
+ ret1_p.then(ret1=>ret1_a[2] = ret1)
25
+ })
26
26
  equal(ret0_a, [null, null, null])
27
27
  equal(ret1_a, [null, null, null])
28
28
  await new Promise(res=>queueMicrotask(()=>res(null)))
@@ -55,23 +55,23 @@ test('batch_queue_(1, 2).add|enqueue 2 at a time & run 1 at a time', async ()=>{
55
55
  const batch_queue = batch_queue_(1, 2)
56
56
  const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
57
57
  const fn_a = [()=>promise_o_a[0].promise, ()=>promise_o_a[1].promise, ()=>promise_o_a[2].promise]
58
- const ret0_a:any[] = [null, null, null]
59
- const ret1_a:any[] = [null, null, null]
58
+ const ret0_a:unknown[] = [null, null, null]
59
+ const ret1_a:unknown[] = [null, null, null]
60
60
  batch_queue.add(fn_a[0])
61
- .then(([ret0, ret1_p])=>{
62
- ret0_a[0] = ret0
63
- ret1_p.then(ret0=>ret1_a[0] = ret0)
64
- })
61
+ .then(([ret0, ret1_p])=>{
62
+ ret0_a[0] = ret0
63
+ ret1_p.then(ret0=>ret1_a[0] = ret0)
64
+ })
65
65
  batch_queue.add(fn_a[1])
66
- .then(([ret0, ret1_p])=>{
67
- ret0_a[1] = ret0
68
- ret1_p.then(ret1=>ret1_a[1] = ret1)
69
- })
66
+ .then(([ret0, ret1_p])=>{
67
+ ret0_a[1] = ret0
68
+ ret1_p.then(ret1=>ret1_a[1] = ret1)
69
+ })
70
70
  batch_queue.add(fn_a[2])
71
- .then(([ret0, ret1_p])=>{
72
- ret0_a[2] = ret0
73
- ret1_p.then(ret1=>ret1_a[2] = ret1)
74
- })
71
+ .then(([ret0, ret1_p])=>{
72
+ ret0_a[2] = ret0
73
+ ret1_p.then(ret1=>ret1_a[2] = ret1)
74
+ })
75
75
  equal(ret0_a, [null, null, null])
76
76
  equal(ret1_a, [null, null, null])
77
77
  await new Promise(res=>queueMicrotask(()=>res(null)))
@@ -104,23 +104,23 @@ test('batch_queue_(2).add|enqueue 2 at a time & run 2 at a time', async ()=>{
104
104
  const batch_queue = batch_queue_(2)
105
105
  const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
106
106
  const fn_a = [()=>promise_o_a[0].promise, ()=>promise_o_a[1].promise, ()=>promise_o_a[2].promise]
107
- const ret0_a:any[] = [null, null, null]
108
- const ret1_a:any[] = [null, null, null]
107
+ const ret0_a:unknown[] = [null, null, null]
108
+ const ret1_a:unknown[] = [null, null, null]
109
109
  batch_queue.add(fn_a[0])
110
- .then(([ret0, ret1_p])=>{
111
- ret0_a[0] = ret0
112
- ret1_p.then(ret0=>ret1_a[0] = ret0)
113
- })
110
+ .then(([ret0, ret1_p])=>{
111
+ ret0_a[0] = ret0
112
+ ret1_p.then(ret0=>ret1_a[0] = ret0)
113
+ })
114
114
  batch_queue.add(fn_a[1])
115
- .then(([ret0, ret1_p])=>{
116
- ret0_a[1] = ret0
117
- ret1_p.then(ret1=>ret1_a[1] = ret1)
118
- })
115
+ .then(([ret0, ret1_p])=>{
116
+ ret0_a[1] = ret0
117
+ ret1_p.then(ret1=>ret1_a[1] = ret1)
118
+ })
119
119
  batch_queue.add(fn_a[2])
120
- .then(([ret0, ret1_p])=>{
121
- ret0_a[2] = ret0
122
- ret1_p.then(ret1=>ret1_a[2] = ret1)
123
- })
120
+ .then(([ret0, ret1_p])=>{
121
+ ret0_a[2] = ret0
122
+ ret1_p.then(ret1=>ret1_a[2] = ret1)
123
+ })
124
124
  equal(ret0_a, [null, null, null])
125
125
  equal(ret1_a, [null, null, null])
126
126
  await new Promise(res=>queueMicrotask(()=>res(null)))
@@ -3,7 +3,7 @@ import { equal } from 'uvu/assert'
3
3
  import { be_, type Ctx_wide_T } from '../be_/index.js'
4
4
  import { be_sig_triple_ } from '../be_sig_triple/index.js'
5
5
  import { ctx__new, ns_ctx__new } from '../ctx/index.js'
6
- import { memosig_, type sig_T } from '../rmemo/index.js'
6
+ import { memo_, memosig_, type sig_T } from '../rmemo/index.js'
7
7
  import type { Equal, Expect } from '../test/index.js'
8
8
  import { be_lock_memosig_triple_ } from './index.js'
9
9
  test('be_lock_memosig_triple_', ()=>{
@@ -42,7 +42,7 @@ test('be_lock_memosig_triple_', ()=>{
42
42
  })
43
43
  test('be_lock_memosig_triple_|+id|+ns', ()=>{
44
44
  const ctx = ns_ctx__new('test_ns')
45
- let subscriber_count = 0
45
+ let add_count = 0
46
46
  const [
47
47
  ,
48
48
  base_,
@@ -52,8 +52,8 @@ test('be_lock_memosig_triple_|+id|+ns', ()=>{
52
52
  { ns: 'test_ns' })
53
53
  const [
54
54
  ,
55
- subscriber_dep_,
56
- subscriber_dep__set
55
+ add_dep_,
56
+ add_dep__set
57
57
  ] = be_sig_triple_(()=>1,
58
58
  { ns: 'test_ns' })
59
59
  const [
@@ -68,38 +68,38 @@ test('be_lock_memosig_triple_|+id|+ns', ()=>{
68
68
  return base_(ctx) + 1
69
69
  },
70
70
  { id: 'foobar', ns: 'test_ns' }
71
- ).add((ctx, foobar$)=>{
72
- subscriber_count++
73
- subscriber_dep__set(ctx, subscriber_count + foobar$())
74
- })
75
- equal(subscriber_count, 0)
71
+ ).add((ctx, foobar$)=>memo_(()=>{
72
+ add_count++
73
+ add_dep__set(ctx, add_count + foobar$())
74
+ }))
75
+ equal(add_count, 0)
76
76
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
77
77
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
78
78
  equal(foobar$_(ctx)._, 2)
79
79
  equal(foobar_(ctx), 2)
80
- equal(subscriber_count, 1)
80
+ equal(add_count, 1)
81
81
  equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)._, 2)
82
- equal(subscriber_dep_(ctx), 3)
82
+ equal(add_dep_(ctx), 3)
83
83
  foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
84
84
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
85
85
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
86
86
  equal(foobar$_(ctx)._, 5)
87
87
  equal(foobar_(ctx), 5)
88
88
  equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)._, 5)
89
- equal(subscriber_count, 2)
90
- equal(subscriber_dep_(ctx), 7)
89
+ equal(add_count, 2)
90
+ equal(add_dep_(ctx), 7)
91
91
  base__set(ctx, 2)
92
92
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
93
93
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
94
94
  equal(foobar$_(ctx)._, 5)
95
95
  equal(foobar_(ctx), 5)
96
- equal(subscriber_count, 2)
96
+ equal(add_count, 2)
97
97
  equal((ctx.s['test_ns'].get('foobar')![0] as sig_T<number>)._, 5)
98
- equal(subscriber_dep_(ctx), 7)
98
+ equal(add_dep_(ctx), 7)
99
99
  })
100
100
  test('be_lock_memosig_triple_|+be', ()=>{
101
101
  const ctx = ns_ctx__new('test_ns')
102
- let subscriber_count = 0
102
+ let add_count = 0
103
103
  const [
104
104
  ,
105
105
  base_,
@@ -118,19 +118,20 @@ test('be_lock_memosig_triple_|+be', ()=>{
118
118
  const foobar$ =
119
119
  memosig_(
120
120
  ()=>base_(ctx) + 1
121
- ).add(foobar$=>{
122
- foobar$()
123
- subscriber_count++
124
- }) as custom_sig_T
121
+ ).add(foobar$=>
122
+ memo_(()=>{
123
+ foobar$()
124
+ add_count++
125
+ })) as custom_sig_T
125
126
  foobar$.custom = 'custom-val'
126
127
  return foobar$
127
128
  }, { id: 'foobar', ns: 'test_ns' }))
128
- equal(subscriber_count, 0)
129
+ equal(add_count, 0)
129
130
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
130
131
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
131
132
  equal(foobar$_(ctx)._, 2)
132
133
  equal(foobar_(ctx), 2)
133
- equal(subscriber_count, 1)
134
+ equal(add_count, 1)
134
135
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
135
136
  equal(foobar$_(ctx).custom, 'custom-val')
136
137
  foobar__set(ctx, 5)
@@ -138,7 +139,7 @@ test('be_lock_memosig_triple_|+be', ()=>{
138
139
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
139
140
  equal(foobar$_(ctx)._, 5)
140
141
  equal(foobar_(ctx), 5)
141
- equal(subscriber_count, 2)
142
+ equal(add_count, 2)
142
143
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 5)
143
144
  equal(foobar$_(ctx).custom, 'custom-val')
144
145
  base__set(ns_ctx__new(ctx__new(), ctx), 2)
@@ -148,7 +149,7 @@ test('be_lock_memosig_triple_|+be', ()=>{
148
149
  equal(foobar_(ctx), 3)
149
150
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 3)
150
151
  equal(foobar$_(ctx).custom, 'custom-val')
151
- equal(subscriber_count, 3)
152
+ equal(add_count, 3)
152
153
  })
153
154
  test.run()
154
155
  type custom_sig_T = sig_T<number>&{
@@ -3,8 +3,7 @@ import { equal } from 'uvu/assert'
3
3
  import { be_, type Ctx_wide_T } from '../be_/index.js'
4
4
  import { be_sig_triple_ } from '../be_sig_triple/index.js'
5
5
  import { ctx__new, ns_ctx__new } from '../ctx/index.js'
6
- import type { memo_T, sig_T } from '../rmemo/index.js'
7
- import { memo_ } from '../rmemo/index.js'
6
+ import { memo_, type memo_T } from '../rmemo/index.js'
8
7
  import type { Equal, Expect } from '../test/index.js'
9
8
  import { be_memo_pair_ } from './index.js'
10
9
  test('be_memo_pair_', ()=>{
@@ -16,7 +15,7 @@ test('be_memo_pair_', ()=>{
16
15
  const [
17
16
  foobar$_,
18
17
  foobar_,
19
- ] = be_memo_pair_<number, '', sig_T<number>&{ count:number }>((
18
+ ] = be_memo_pair_<number, '', memo_T<number>&{ count:number }>((
20
19
  _ctx,
21
20
  foobar$
22
21
  )=>{
@@ -37,13 +36,13 @@ test('be_memo_pair_', ()=>{
37
36
  equal(foobar_(ctx), 3)
38
37
  equal(foobar$_(ctx).count, 2)
39
38
  })
40
- test('be_memo_pair_|+id|+ns|+oninit|+subscriber_a', ()=>{
39
+ test('be_memo_pair_|+id|+ns|+oninit|+add', ()=>{
41
40
  const ctx = ns_ctx__new('test_ns')
42
- let subscriber_count = 0
41
+ let add_count = 0
43
42
  const [
44
43
  ,
45
- subscriber_dep_,
46
- subscriber_dep__set
44
+ add_dep_,
45
+ add_dep__set
47
46
  ] = be_sig_triple_(()=>1,
48
47
  { ns: 'test_ns' })
49
48
  const [
@@ -58,31 +57,31 @@ test('be_memo_pair_|+id|+ns|+oninit|+subscriber_a', ()=>{
58
57
  ] = be_memo_pair_<number, 'test_ns'>(
59
58
  ctx=>base_(ctx) + 1,
60
59
  { id: 'foobar', ns: 'test_ns' }
61
- ).add((ctx, foobar$)=>{
60
+ ).add((ctx, foobar$)=>memo_(()=>{
62
61
  /* eslint-disable @typescript-eslint/no-unused-vars */
63
62
  type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
64
63
  /* eslint-enable @typescript-eslint/no-unused-vars */
65
- subscriber_count++
66
- subscriber_dep__set(ctx, subscriber_count + foobar$())
67
- })
68
- equal(subscriber_count, 0)
64
+ add_count++
65
+ add_dep__set(ctx, add_count + foobar$())
66
+ }))
67
+ equal(add_count, 0)
69
68
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
70
69
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
71
70
  equal(foobar$_(ctx)._, 2)
72
71
  equal(foobar_(ctx), 2)
73
72
  equal((ctx.s.test_ns.get('foobar')![0] as memo_T<number>)._, 2)
74
- equal(subscriber_count, 1)
75
- equal(subscriber_dep_(ctx), 3)
73
+ equal(add_count, 1)
74
+ equal(add_dep_(ctx), 3)
76
75
  base__set(ctx, 2)
77
76
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
78
77
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
79
78
  equal(foobar$_(ctx)._, 3)
80
79
  equal(foobar_(ctx), 3)
81
80
  equal((ctx.s.test_ns.get('foobar')![0] as memo_T<number>)._, 3)
82
- equal(subscriber_count, 2)
83
- equal(subscriber_dep_(ctx), 5)
81
+ equal(add_count, 2)
82
+ equal(add_dep_(ctx), 5)
84
83
  })
85
- test('be_memo_pair_|subscriber|receives a memosig to set the value of the memo', ()=>{
84
+ test('be_memo_pair_|add|receives a memosig to set the value of the memo', ()=>{
86
85
  const ctx = ctx__new()
87
86
  const [
88
87
  ,
@@ -97,9 +96,9 @@ test('be_memo_pair_|subscriber|receives a memosig to set the value of the memo',
97
96
  type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<''>>>
98
97
  /* eslint-enable @typescript-eslint/no-unused-vars */
99
98
  return 1
100
- }).add((ctx, foobar$)=>{
99
+ }).add((ctx, foobar$)=>memo_(()=>{
101
100
  foobar$._ = base_(ctx) + 1
102
- })
101
+ }))
103
102
  equal(foobar$_(ctx)._, 2)
104
103
  equal(foobar_(ctx), 2)
105
104
  base__set(ctx, 2)
@@ -108,7 +107,7 @@ test('be_memo_pair_|subscriber|receives a memosig to set the value of the memo',
108
107
  })
109
108
  test('be_memo_pair_|be', ()=>{
110
109
  const ctx = ns_ctx__new('test_ns')
111
- let subscriber_count = 0
110
+ let add_count = 0
112
111
  const [
113
112
  ,
114
113
  base_,
@@ -125,7 +124,7 @@ test('be_memo_pair_|be', ()=>{
125
124
  /* eslint-enable @typescript-eslint/no-unused-vars */
126
125
  const foobar$ = memo_(
127
126
  ()=>base_(ctx) + 1
128
- ).add(()=>subscriber_count++) as custom_memo_T
127
+ ).add(()=>add_count++) as custom_memo_T
129
128
  equal(_ctx.s.test_ns, ctx.s.test_ns)
130
129
  foobar$.custom = 'custom-val'
131
130
  return foobar$
@@ -133,14 +132,14 @@ test('be_memo_pair_|be', ()=>{
133
132
  id: 'foobar',
134
133
  ns: 'test_ns',
135
134
  }))
136
- equal(subscriber_count, 0)
135
+ equal(add_count, 0)
137
136
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
138
137
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
139
138
  equal(foobar$_(ctx)._, 2)
140
139
  equal(foobar_(ctx), 2)
141
140
  equal((ctx.s.test_ns.get('foobar')![0] as memo_T<number>)._, 2)
142
141
  equal(foobar$_(ctx).custom, 'custom-val')
143
- equal(subscriber_count, 1)
142
+ equal(add_count, 1)
144
143
  base__set(ctx, 2)
145
144
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
146
145
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
@@ -148,7 +147,7 @@ test('be_memo_pair_|be', ()=>{
148
147
  equal(foobar_(ctx), 3)
149
148
  equal((ctx.s.test_ns.get('foobar')![0] as memo_T<number>)._, 3)
150
149
  equal(foobar$_(ctx).custom, 'custom-val')
151
- equal(subscriber_count, 1)
150
+ equal(add_count, 1)
152
151
  })
153
152
  test.run()
154
- type custom_memo_T = sig_T<number>&{ custom:string }
153
+ type custom_memo_T = memo_T<number>&{ custom:string }
@@ -3,7 +3,7 @@ import { equal } from 'uvu/assert'
3
3
  import { be_, type Ctx_wide_T } from '../be_/index.js'
4
4
  import { be_sig_triple_ } from '../be_sig_triple/index.js'
5
5
  import { ctx__new, ns_ctx__new } from '../ctx/index.js'
6
- import { memosig_, type sig_T } from '../rmemo/index.js'
6
+ import { memo_, memosig_, type sig_T } from '../rmemo/index.js'
7
7
  import type { Equal, Expect } from '../test/index.js'
8
8
  import { be_memosig_triple_ } from './index.js'
9
9
  test('be_memosig_triple_', ()=>{
@@ -42,7 +42,7 @@ test('be_memosig_triple_', ()=>{
42
42
  })
43
43
  test('be_memosig_triple_|+id|+ns', ()=>{
44
44
  const ctx = ns_ctx__new('test_ns')
45
- let subscriber_count = 0
45
+ let add_count = 0
46
46
  const [
47
47
  ,
48
48
  base_,
@@ -52,8 +52,8 @@ test('be_memosig_triple_|+id|+ns', ()=>{
52
52
  { ns: 'test_ns' })
53
53
  const [
54
54
  ,
55
- subscriber_dep_,
56
- subscriber_dep__set
55
+ add_dep_,
56
+ add_dep__set
57
57
  ] = be_sig_triple_(()=>1,
58
58
  { ns: 'test_ns' })
59
59
  const [
@@ -68,41 +68,41 @@ test('be_memosig_triple_|+id|+ns', ()=>{
68
68
  return base_(ctx) + 1
69
69
  },
70
70
  { id: 'foobar', ns: 'test_ns' }
71
- ).add((ctx, foobar$)=>{
71
+ ).add((ctx, foobar$)=>memo_(()=>{
72
72
  /* eslint-disable @typescript-eslint/no-unused-vars */
73
73
  type test_ctx = Expect<Equal<typeof ctx, Ctx_wide_T<'test_ns'>>>
74
74
  /* eslint-enable @typescript-eslint/no-unused-vars */
75
- subscriber_count++
76
- subscriber_dep__set(ctx, subscriber_count + foobar$())
77
- })
78
- equal(subscriber_count, 0)
75
+ add_count++
76
+ add_dep__set(ctx, add_count + foobar$())
77
+ }))
78
+ equal(add_count, 0)
79
79
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
80
80
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
81
81
  equal(foobar$_(ctx)._, 2)
82
82
  equal(foobar_(ctx), 2)
83
- equal(subscriber_count, 1)
83
+ equal(add_count, 1)
84
84
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
85
- equal(subscriber_dep_(ctx), 3)
85
+ equal(add_dep_(ctx), 3)
86
86
  foobar__set(ns_ctx__new(ctx__new(), ctx), 5)
87
87
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 5)
88
88
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
89
89
  equal(foobar$_(ctx)._, 5)
90
90
  equal(foobar_(ctx), 5)
91
91
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 5)
92
- equal(subscriber_count, 2)
93
- equal(subscriber_dep_(ctx), 7)
92
+ equal(add_count, 2)
93
+ equal(add_dep_(ctx), 7)
94
94
  base__set(ctx, 2)
95
95
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 3)
96
96
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 3)
97
97
  equal(foobar$_(ctx)._, 3)
98
98
  equal(foobar_(ctx), 3)
99
- equal(subscriber_count, 3)
99
+ equal(add_count, 3)
100
100
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 3)
101
- equal(subscriber_dep_(ctx), 6)
101
+ equal(add_dep_(ctx), 6)
102
102
  })
103
103
  test('be_memosig_triple_|+be', ()=>{
104
104
  const ctx = ns_ctx__new('test_ns')
105
- let subscriber_count = 0
105
+ let add_count = 0
106
106
  const [
107
107
  ,
108
108
  base_,
@@ -121,19 +121,20 @@ test('be_memosig_triple_|+be', ()=>{
121
121
  const foobar$ =
122
122
  memosig_(
123
123
  ()=>base_(ctx) + 1
124
- ).add(foobar$=>{
125
- foobar$()
126
- subscriber_count++
127
- }) as custom_sig_T
124
+ ).add(foobar$=>
125
+ memo_(()=>{
126
+ foobar$()
127
+ add_count++
128
+ })) as custom_sig_T
128
129
  foobar$.custom = 'custom-val'
129
130
  return foobar$
130
131
  }, { id: 'foobar', ns: 'test_ns' }))
131
- equal(subscriber_count, 0)
132
+ equal(add_count, 0)
132
133
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
133
134
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 2)
134
135
  equal(foobar$_(ctx)._, 2)
135
136
  equal(foobar_(ctx), 2)
136
- equal(subscriber_count, 1)
137
+ equal(add_count, 1)
137
138
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
138
139
  equal(foobar$_(ctx).custom, 'custom-val')
139
140
  foobar__set(ctx, 5)
@@ -141,7 +142,7 @@ test('be_memosig_triple_|+be', ()=>{
141
142
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 5)
142
143
  equal(foobar$_(ctx)._, 5)
143
144
  equal(foobar_(ctx), 5)
144
- equal(subscriber_count, 2)
145
+ equal(add_count, 2)
145
146
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 5)
146
147
  equal(foobar$_(ctx).custom, 'custom-val')
147
148
  base__set(ns_ctx__new(ctx__new(), ctx), 2)
@@ -151,7 +152,7 @@ test('be_memosig_triple_|+be', ()=>{
151
152
  equal(foobar_(ctx), 3)
152
153
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 3)
153
154
  equal(foobar$_(ctx).custom, 'custom-val')
154
- equal(subscriber_count, 3)
155
+ equal(add_count, 3)
155
156
  })
156
157
  test.run()
157
158
  type custom_sig_T = sig_T<number>&{
@@ -26,6 +26,6 @@ export type be_sig_triple_T<
26
26
  ctx__set_T<ctx_T, val_T>
27
27
  ]&{
28
28
  add<add_val_T>(
29
- add_def:(ctx:ctx_T, sig:_sig_T, prev_val:add_val_T|undefined)=>add_val_T
29
+ add_def:(ctx:ctx_T, sig:_sig_T)=>add_val_T
30
30
  ):be_sig_triple_T<val_T, ns_T, _sig_T, ctx_T>
31
31
  }
@@ -2,7 +2,7 @@ import { test } from 'uvu'
2
2
  import { equal } from 'uvu/assert'
3
3
  import { be_, type Ctx_wide_T } from '../be_/index.js'
4
4
  import { ctx__new, ns_ctx__new } from '../ctx/index.js'
5
- import { sig_, type sig_T } from '../rmemo/index.js'
5
+ import { memo_, sig_, type sig_T } from '../rmemo/index.js'
6
6
  import type { Equal, Expect } from '../test/index.js'
7
7
  import { be_sig_triple_ } from './index.js'
8
8
  test('be_sig_triple_', ()=>{
@@ -26,11 +26,11 @@ test('be_sig_triple_', ()=>{
26
26
  })
27
27
  test('be_sig_triple_|+id|+ns', ()=>{
28
28
  const ctx = ns_ctx__new('test_ns')
29
- let subscriber_count = 0
29
+ let add_count = 0
30
30
  const [
31
31
  ,
32
- subscriber_dep_,
33
- subscriber_dep__set
32
+ add_dep_,
33
+ add_dep__set
34
34
  ] = be_sig_triple_(()=>1,
35
35
  { ns: 'test_ns' })
36
36
  const [
@@ -44,17 +44,17 @@ test('be_sig_triple_|+id|+ns', ()=>{
44
44
  /* eslint-enable @typescript-eslint/no-unused-vars */
45
45
  return 1
46
46
  }, { id: 'foobar', ns: 'test_ns' }
47
- ).add((ctx, foobar$)=>{
48
- subscriber_count++
49
- subscriber_dep__set(ctx, subscriber_count + foobar$())
50
- })
51
- equal(subscriber_count, 0)
47
+ ).add((ctx, foobar$)=>memo_(()=>{
48
+ add_count++
49
+ add_dep__set(ctx, add_count + foobar$())
50
+ }))
51
+ equal(add_count, 0)
52
52
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 1)
53
53
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 1)
54
54
  equal(foobar$_(ctx)._, 1)
55
55
  equal(foobar_(ctx), 1)
56
- equal(subscriber_count, 1)
57
- equal(subscriber_dep_(ctx), 2)
56
+ equal(add_count, 1)
57
+ equal(add_dep_(ctx), 2)
58
58
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 1)
59
59
  foobar__set(ns_ctx__new(ctx__new(), ctx), 2)
60
60
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 2)
@@ -62,12 +62,12 @@ test('be_sig_triple_|+id|+ns', ()=>{
62
62
  equal(foobar$_(ctx)._, 2)
63
63
  equal(foobar_(ctx), 2)
64
64
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
65
- equal(subscriber_count, 2)
66
- equal(subscriber_dep_(ctx), 4)
65
+ equal(add_count, 2)
66
+ equal(add_dep_(ctx), 4)
67
67
  })
68
68
  test('be_sig_triple_|+be', ()=>{
69
69
  const ctx = ns_ctx__new('test_ns')
70
- let subscriber_count = 0
70
+ let add_count = 0
71
71
  const [
72
72
  foobar$_,
73
73
  foobar_,
@@ -80,16 +80,16 @@ test('be_sig_triple_|+be', ()=>{
80
80
  const foobar$ =
81
81
  sig_(
82
82
  1
83
- ).add(()=>subscriber_count++) as custom_sig_T
83
+ ).add(()=>add_count++) as custom_sig_T
84
84
  foobar$.custom = 'custom-val'
85
85
  return foobar$ as custom_sig_T
86
86
  }, { id: 'foobar', ns: 'test_ns' }))
87
- equal(subscriber_count, 0)
87
+ equal(add_count, 0)
88
88
  equal(foobar$_(ns_ctx__new(ctx__new(), ctx))._, 1)
89
89
  equal(foobar_(ns_ctx__new(ctx__new(), ctx)), 1)
90
90
  equal(foobar$_(ctx)._, 1)
91
91
  equal(foobar_(ctx), 1)
92
- equal(subscriber_count, 1)
92
+ equal(add_count, 1)
93
93
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 1)
94
94
  equal(foobar$_(ctx).custom, 'custom-val')
95
95
  foobar__set(ns_ctx__new(ctx__new(), ctx), 2)
@@ -99,7 +99,7 @@ test('be_sig_triple_|+be', ()=>{
99
99
  equal(foobar_(ctx), 2)
100
100
  equal((ctx.s.test_ns.get('foobar')![0] as sig_T<number>)._, 2)
101
101
  equal(foobar$_(ctx).custom, 'custom-val')
102
- equal(subscriber_count, 1)
102
+ equal(add_count, 1)
103
103
  })
104
104
  test.run()
105
105
  type custom_sig_T = sig_T<number>&{
@@ -3,11 +3,12 @@ export declare function memo_<val_T>(def:memo_def_T<val_T>):memo_T<val_T>
3
3
  export declare function sig_<val_T>(init_val:val_T):sig_T<val_T>
4
4
  export declare function memosig_<val_T>(def:memo_def_T<val_T>):sig_T<val_T>
5
5
  export declare function lock_memosig_<val_T>(def:memo_def_T<val_T>):sig_T<val_T>
6
- export declare function rmemo__on(rmemo:rmemo_T<unknown>):void
7
- export declare function rmemo__off(rmemo:rmemo_T<unknown>):void
6
+ export declare function rmemo__on<val_T>(rmemo:rmemo_T<val_T>, off_fn?:(rmemo:rmemo_T<val_T>)=>unknown):void
7
+ export declare function rmemo__off<val_T>(rmemo:rmemo_T<val_T>):void
8
+ export declare function rmemo__off__add<val_T>(rmemo:rmemo_T<val_T>, off_fn:(rmemo:rmemo_T<val_T>)=>unknown):void
8
9
  export declare function rmemo__add<val_T, listener_val_T>(
9
10
  rmemo:rmemo_T<val_T>,
10
- listener:(sig:sig_T<val_T>, prev_val:listener_val_T|undefined)=>listener_val_T
11
+ listener:(sig:sig_T<val_T>)=>listener_val_T
11
12
  ):()=>void
12
13
  export type rmemo_T<val_T> = memo_T<val_T>|sig_T<val_T>|lock_memosig_T<val_T>
13
14
  export type circular_rmemo_T = circular_memo_T|circular_sig_T|circular_lock_memosig_T
@@ -15,8 +16,8 @@ export type memo_T<val_T> = (()=>val_T)&{
15
16
  readonly _:val_T
16
17
  readonly a?:rmemo_a_T[]
17
18
  readonly f?:rmemo_f_T
18
- readonly memor:rmemo_r_T[]
19
- readonly r?:rmemo_r_T
19
+ readonly s?:rmemo_r_T
20
+ readonly t:rmemo_r_T[]
20
21
  readonly val:val_T
21
22
  add<add_val_T>(add_def:rmemo_add_def_T<val_T, add_val_T>):memo_T<val_T>
22
23
  memo_<_val_T>(def:memo_def_T<_val_T>):memo_T<_val_T>
@@ -25,14 +26,10 @@ export interface circular_memo_T extends memo_T<circular_memo_T> {
25
26
  }
26
27
  export type sig_T<val_T> = (()=>val_T)&{
27
28
  _:val_T
28
- readonly a?:rmemo_a_T[]
29
- readonly f?:(()=>void)&{
30
- readonly l:number
31
- readonly s:rmemo_T<unknown>[]
32
- readonly S:rmemo_T<unknown>[]
33
- }
34
- readonly memor:rmemo_r_T[]
35
- readonly r?:rmemo_r_T
29
+ readonly a?:rmemo_a_T
30
+ readonly f?:rmemo_f_T
31
+ readonly s?:rmemo_r_T
32
+ readonly t:rmemo_r_T[]
36
33
  readonly val:val_T
37
34
  add<add_val_T>(fn:rmemo_add_def_T<val_T, add_val_T>):sig_T<val_T>
38
35
  memo_<_val_T>(def:memo_def_T<_val_T>):memo_T<_val_T>
@@ -48,12 +45,11 @@ export type rmemo_val_T<sig_T> = sig_T extends { ():infer val_T }
48
45
  ? val_T
49
46
  : unknown
50
47
  export type memo_def_T<val_T> = (sig:sig_T<val_T>)=>val_T
51
- export type rmemo_a_T = [memo_T<unknown>, unknown]
52
- export type rmemo_add_T<val_T, SV> = (sig:sig_T<val_T>, old_val:SV|undefined)=>SV
53
- export type rmemo_add_def_T<val_T, add_val_T> = (sig:sig_T<val_T>, prev_val:add_val_T|undefined)=>add_val_T
48
+ export type rmemo_a_T = unknown[]
49
+ export type rmemo_add_def_T<val_T, add_val_T> = (sig:sig_T<val_T>)=>add_val_T
54
50
  export type rmemo_f_T = (()=>void)&{
55
51
  readonly l:number
56
52
  readonly s:rmemo_T<unknown>[]
57
- readonly S:rmemo_T<unknown>[]
53
+ readonly t:rmemo_T<unknown>[]
58
54
  }
59
55
  export type rmemo_r_T = WeakRef<rmemo_f_T>&{ readonly d?: ()=>rmemo_f_T }