ctx-core 4.12.0 → 4.14.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/{memo → arg_memo}/index.d.ts +1 -1
- package/all/{memo → arg_memo}/index.js +3 -7
- package/all/{memo → arg_memo}/index.test.ts +21 -21
- package/all/be_/index.d.ts +1 -1
- package/all/be_/index.js +31 -44
- package/all/be_/index.test.ts +47 -50
- package/all/be_memo_pair/index.d.ts +9 -0
- package/all/be_memosig_triple/index.d.ts +9 -0
- package/all/be_sig_triple/index.js +2 -1
- package/all/index.d.ts +15 -15
- package/all/index.js +15 -15
- package/all/index.test.ts +7 -0
- package/function/index.d.ts +1 -1
- package/function/index.js +1 -1
- package/package.json +5 -5
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { isPrimitive } from '../isPrimitive/index.js'
|
|
2
2
|
import { prototype_ } from '../prototype/index.js'
|
|
3
|
-
let empty_sym
|
|
3
|
+
let empty_sym = Symbol('E')
|
|
4
4
|
/**
|
|
5
5
|
* @param {(...arg_a:any[])=>any}fn
|
|
6
6
|
* @returns A memo caching arguments & return values. Arguments that are Objects are cached with a WeakRef.
|
|
7
7
|
* @private
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function arg_memo_(fn) {
|
|
10
10
|
let m = new Map
|
|
11
11
|
let wm = new WeakMap
|
|
12
|
-
if (!empty_sym) {
|
|
13
|
-
empty_sym = Symbol('E')
|
|
14
|
-
WeakRef_proto = WeakRef.prototype
|
|
15
|
-
}
|
|
16
12
|
let memo = (...arg_a)=>{
|
|
17
13
|
if (!arg_a.length) {
|
|
18
14
|
if (!m.has(empty_sym)) {
|
|
@@ -35,7 +31,7 @@ export function memo_(fn) {
|
|
|
35
31
|
if (cache__arg_a.length !== length) continue
|
|
36
32
|
for (let arg_a__i = length; arg_a__i--;) {
|
|
37
33
|
let cache__arg_val = cache__arg_a[arg_a__i]
|
|
38
|
-
if (prototype_(cache__arg_val) ===
|
|
34
|
+
if (prototype_(cache__arg_val) === WeakRef.prototype) {
|
|
39
35
|
cache__arg_val = cache__arg_val.deref()
|
|
40
36
|
if (!cache__arg_val) { // cleanup cache__arg_a when arg is GC
|
|
41
37
|
cache__arg_a_T_ret__a.splice(cache__arg_a_T_ret__a__i, 1)
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { test } from 'uvu'
|
|
2
2
|
import { equal } from 'uvu/assert'
|
|
3
|
-
import {
|
|
4
|
-
test('
|
|
3
|
+
import { arg_memo_ } from './index.js'
|
|
4
|
+
test('arg_memo_|empty', ()=>{
|
|
5
5
|
let call_count = 0
|
|
6
|
-
|
|
6
|
+
const fn = ()=>{
|
|
7
7
|
call_count++
|
|
8
8
|
return 'memo-return'
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const memo = arg_memo_(fn)
|
|
11
11
|
equal(call_count, 0)
|
|
12
12
|
equal(memo(), 'memo-return')
|
|
13
13
|
equal(call_count, 1)
|
|
14
14
|
equal(memo(), 'memo-return')
|
|
15
15
|
equal(call_count, 1)
|
|
16
16
|
})
|
|
17
|
-
test('
|
|
17
|
+
test('arg_memo_|primitive arguments', ()=>{
|
|
18
18
|
let call_count = 0
|
|
19
|
-
|
|
19
|
+
const fn = (arg0:number, arg1:number)=>{
|
|
20
20
|
call_count++
|
|
21
21
|
return arg0 + arg1
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const memo = arg_memo_(fn)
|
|
24
24
|
equal(call_count, 0)
|
|
25
25
|
equal(memo(1, 2), 3)
|
|
26
26
|
equal(call_count, 1)
|
|
@@ -32,35 +32,35 @@ test('memo_|primitive arguments', ()=>{
|
|
|
32
32
|
equal(memo(1, 2), 3)
|
|
33
33
|
equal(call_count, 3)
|
|
34
34
|
})
|
|
35
|
-
test('
|
|
35
|
+
test('arg_memo_|primitive|with objects', ()=>{
|
|
36
36
|
let call_count = 0
|
|
37
|
-
|
|
37
|
+
const fn = (arg0:number, arg1:object)=>{
|
|
38
38
|
call_count++
|
|
39
39
|
return { ...arg1, arg0 }
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const memo = arg_memo_(fn)
|
|
42
|
+
const arg0 = { arg1: true }
|
|
43
|
+
const arg0_2 = { arg1_2: true }
|
|
44
44
|
equal(call_count, 0)
|
|
45
|
-
equal(memo(1,
|
|
45
|
+
equal(memo(1, arg0), { arg1: true, arg0: 1 })
|
|
46
46
|
equal(call_count, 1)
|
|
47
|
-
equal(memo(1,
|
|
47
|
+
equal(memo(1, arg0), { arg1: true, arg0: 1 })
|
|
48
48
|
equal(call_count, 1)
|
|
49
|
-
equal(memo(1,
|
|
49
|
+
equal(memo(1, arg0_2), { arg1_2: true, arg0: 1 })
|
|
50
50
|
equal(call_count, 2)
|
|
51
51
|
memo.clear()
|
|
52
|
-
equal(memo(1,
|
|
52
|
+
equal(memo(1, arg0), { arg1: true, arg0: 1 })
|
|
53
53
|
equal(call_count, 3)
|
|
54
54
|
})
|
|
55
|
-
test('
|
|
55
|
+
test('arg_memo_|objects|with primitives', ()=>{
|
|
56
56
|
let call_count = 0
|
|
57
|
-
|
|
57
|
+
const fn = (arg0:object, arg1:number)=>{
|
|
58
58
|
call_count++
|
|
59
59
|
return { ...arg0, arg1 }
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const memo = arg_memo_(fn)
|
|
62
|
+
const arg0 = { arg0: true }
|
|
63
|
+
const arg0_2 = { arg0_2: true }
|
|
64
64
|
equal(call_count, 0)
|
|
65
65
|
equal(memo(arg0, 1), { arg0: true, arg1: 1 })
|
|
66
66
|
equal(call_count, 1)
|
package/all/be_/index.d.ts
CHANGED
package/all/be_/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { globalThis__prop__ensure } from '../globalThis__prop__ensure/index.js'
|
|
2
1
|
/** @typedef {import('./index.d.ts').Be} */
|
|
3
2
|
/** @typedef {import('./index.d.ts').be_} */
|
|
4
3
|
/** @typedef {import('./index.d.ts').be_config_T} */
|
|
@@ -6,22 +5,6 @@ import { globalThis__prop__ensure } from '../globalThis__prop__ensure/index.js'
|
|
|
6
5
|
/** @typedef {import('./index.d.ts').MapCtx} */
|
|
7
6
|
/** @typedef {import('./index.d.ts').be__val__new_T} */
|
|
8
7
|
/** @typedef {import('./index.d.ts').is_source__T} */
|
|
9
|
-
/**
|
|
10
|
-
* Auto-memoization function for the Ctx.
|
|
11
|
-
* Memoized on globalThis to allow packages being loaded multiple times, which can happen during bundling.
|
|
12
|
-
*
|
|
13
|
-
* Returns a function to ensure that a member id_OR_val_ is defined on a ctx object,
|
|
14
|
-
* otherwise it caches & uses the return value of val__new.
|
|
15
|
-
* @param {string|symbol}id
|
|
16
|
-
* @param {be__val__new_T}val__new
|
|
17
|
-
* @param {be_config_T}config
|
|
18
|
-
* @returns {Be}
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
export function globalThis__be_(val__new, config) {
|
|
22
|
-
return globalThis__prop__ensure(config.id, ()=>
|
|
23
|
-
be_(val__new, config))
|
|
24
|
-
}
|
|
25
8
|
/**
|
|
26
9
|
* Auto-memoization function for the Ctx.
|
|
27
10
|
*
|
|
@@ -34,30 +17,42 @@ export function globalThis__be_(val__new, config) {
|
|
|
34
17
|
*/
|
|
35
18
|
export function be_(val__new, config) {
|
|
36
19
|
let be = argv__ctx=>{
|
|
37
|
-
let flat__argv__ctx =
|
|
20
|
+
let flat__argv__ctx = argv__ctx.flat && argv__ctx.flat(Infinity)
|
|
38
21
|
let be__ctx =
|
|
39
|
-
|
|
40
|
-
? flat__argv__ctx.find(ctx=>ctx.has(be))
|
|
41
|
-
: argv__ctx.has(be) && argv__ctx
|
|
22
|
+
flat__argv__ctx
|
|
23
|
+
? flat__argv__ctx.find(ctx=>ctx.has(be.id))
|
|
24
|
+
: argv__ctx.has(be.id) && argv__ctx
|
|
42
25
|
if (!be__ctx) {
|
|
43
26
|
be__ctx =
|
|
44
27
|
flat__argv__ctx
|
|
45
28
|
? flat__argv__ctx.find(ctx=>!be.is_source_ || be.is_source_(ctx, argv__ctx))
|
|
46
29
|
: (!be.is_source_ || be.is_source_(argv__ctx, argv__ctx)) && argv__ctx
|
|
47
30
|
// circular dependency state
|
|
48
|
-
// if val__new calls this be before returning,
|
|
31
|
+
// if val__new calls this be before returning, 'cir' will be the value of this be
|
|
49
32
|
// 'cir' is used instead of 'circular' to reduce the payload by a few bytes
|
|
50
|
-
be__ctx.set(be,
|
|
51
|
-
be__ctx.set(be, val__new(argv__ctx, be))
|
|
52
|
-
if (be.id) be__ctx.set(be.id, be__ctx.get(be))
|
|
33
|
+
be__ctx.set(be.id, 'cir')
|
|
34
|
+
be__ctx.set(be.id, val__new(argv__ctx, be))
|
|
53
35
|
}
|
|
54
|
-
return be__ctx.get(be)
|
|
36
|
+
return be__ctx.get(be.id)
|
|
55
37
|
}
|
|
56
|
-
be.id = config?.id
|
|
38
|
+
be.id = config?.id ?? be
|
|
57
39
|
be.is_source_ = config?.is_source_
|
|
58
40
|
be.is_be = true
|
|
59
41
|
return be
|
|
60
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Auto-memoization function for the Ctx.
|
|
45
|
+
* Memoized on globalThis to allow packages being loaded multiple times, which can happen during bundling.
|
|
46
|
+
*
|
|
47
|
+
* Returns a function to ensure that a member id_OR_val_ is defined on a ctx object,
|
|
48
|
+
* otherwise it caches & uses the return value of val__new.
|
|
49
|
+
* @param {string|symbol}id
|
|
50
|
+
* @param {be__val__new_T}val__new
|
|
51
|
+
* @param {be_config_T}config
|
|
52
|
+
* @returns {Be}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
export { be_ as globalThis__be_ }
|
|
61
56
|
/**
|
|
62
57
|
* @param {Ctx}ctx
|
|
63
58
|
* @param {Be|string|symbol}be_OR_id
|
|
@@ -74,11 +69,7 @@ export function ctx__set(
|
|
|
74
69
|
) {
|
|
75
70
|
let source__map_ctx = source__map_ctx_(ctx, is_source_)
|
|
76
71
|
if (source__map_ctx) {
|
|
77
|
-
source__map_ctx.set(be_OR_id, val)
|
|
78
|
-
let { id } = be_OR_id
|
|
79
|
-
if (id) {
|
|
80
|
-
source__map_ctx.set(id, val)
|
|
81
|
-
}
|
|
72
|
+
source__map_ctx.set(be_OR_id.id ?? be_OR_id, val)
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
75
|
/**
|
|
@@ -94,13 +85,7 @@ export function ctx__delete(
|
|
|
94
85
|
ctx__delete(_ctx, be_OR_id)
|
|
95
86
|
}
|
|
96
87
|
} else {
|
|
97
|
-
|
|
98
|
-
let map_ctx = /** @type {any} */ctx
|
|
99
|
-
let { id } = be_OR_id
|
|
100
|
-
if (id) {
|
|
101
|
-
map_ctx.delete(id)
|
|
102
|
-
}
|
|
103
|
-
map_ctx.delete(be_OR_id)
|
|
88
|
+
ctx.delete(be_OR_id.id ?? be_OR_id)
|
|
104
89
|
}
|
|
105
90
|
}
|
|
106
91
|
/**
|
|
@@ -121,11 +106,11 @@ export function be__has_(be_or_id, argv__ctx) {
|
|
|
121
106
|
export function be__ctx_(be_or_id, argv__ctx) {
|
|
122
107
|
if (Array.isArray(argv__ctx)) {
|
|
123
108
|
for (let ctx of argv__ctx) {
|
|
124
|
-
let be__ctx = be__ctx_(be_or_id, ctx)
|
|
109
|
+
let be__ctx = be__ctx_(be_or_id.id ?? be_or_id, ctx)
|
|
125
110
|
if (be__ctx) return be__ctx
|
|
126
111
|
}
|
|
127
112
|
} else {
|
|
128
|
-
if (argv__ctx.has(be_or_id)) return argv__ctx
|
|
113
|
+
if (argv__ctx.has(be_or_id.id ?? be_or_id)) return argv__ctx
|
|
129
114
|
}
|
|
130
115
|
}
|
|
131
116
|
export { be__ctx_ as be__has__ctx_ }
|
|
@@ -137,7 +122,7 @@ export { be__ctx_ as be__has__ctx_ }
|
|
|
137
122
|
*/
|
|
138
123
|
export function be__val_(be_or_id, argv__ctx) {
|
|
139
124
|
let be__ctx = be__ctx_(be_or_id, argv__ctx)
|
|
140
|
-
if (be__ctx) return be__ctx.get(be_or_id)
|
|
125
|
+
if (be__ctx) return be__ctx.get(be_or_id.id ?? be_or_id)
|
|
141
126
|
}
|
|
142
127
|
/**
|
|
143
128
|
* @param {Ctx}argv__ctx
|
|
@@ -151,7 +136,9 @@ export function source__map_ctx_(argv__ctx, is_source_) {
|
|
|
151
136
|
let source__map_ctx = source__map_ctx_(ctx, is_source_)
|
|
152
137
|
if (source__map_ctx) return source__map_ctx
|
|
153
138
|
}
|
|
154
|
-
} else
|
|
155
|
-
|
|
139
|
+
} else {
|
|
140
|
+
if (!is_source_ || is_source_(argv__ctx, argv__ctx)) {
|
|
141
|
+
return argv__ctx
|
|
142
|
+
}
|
|
156
143
|
}
|
|
157
144
|
}
|
package/all/be_/index.test.ts
CHANGED
|
@@ -18,26 +18,23 @@ test.after(()=>{
|
|
|
18
18
|
})
|
|
19
19
|
test('globalThis__be_', ()=>{
|
|
20
20
|
const ctx = ctx__new()
|
|
21
|
-
equal(root_be_(), undefined)
|
|
22
21
|
const be = globalThis__be_(()=>1, { id: 'root_be' })
|
|
23
|
-
equal(root_be_(), be)
|
|
24
|
-
equal(root_be_()!(ctx), 1)
|
|
25
22
|
equal(be(ctx), 1)
|
|
26
23
|
const be2 = globalThis__be_(()=>1, { id: 'root_be' })
|
|
27
|
-
equal(be2, be)
|
|
28
|
-
equal(root_be_(), be2)
|
|
29
|
-
equal(root_be_()!(ctx), 1)
|
|
30
24
|
equal(be2(ctx), 1)
|
|
31
|
-
function root_be_() {
|
|
32
|
-
return (globalThis as { root_be?:Be<unknown> }).root_be
|
|
33
|
-
}
|
|
34
25
|
})
|
|
35
26
|
test('be_|Map', ()=>{
|
|
36
27
|
const ctx = ctx__new()
|
|
37
28
|
let incrementer_num = 0
|
|
38
29
|
const incrementer = ()=>++incrementer_num
|
|
39
|
-
const root_ = be_(()=>
|
|
40
|
-
|
|
30
|
+
const root_ = be_(()=>{
|
|
31
|
+
console.debug('root_|debug|1')
|
|
32
|
+
return incrementer()
|
|
33
|
+
}, { id: 'root_' })
|
|
34
|
+
const child_ = be_(ctx=>{
|
|
35
|
+
console.debug('child_|debug|1')
|
|
36
|
+
return root_(ctx) + incrementer()
|
|
37
|
+
}, { id: 'child_' })
|
|
41
38
|
const child1_ = be_(ctx=>root_(ctx) + child_(ctx), { id: 'child1_' })
|
|
42
39
|
equal(root_(ctx), 1)
|
|
43
40
|
equal(ctx.get('root_'), 1)
|
|
@@ -53,12 +50,12 @@ test('be_|simple array', ()=>{
|
|
|
53
50
|
const root_ = be_(()=>1, { id: 'root_' })
|
|
54
51
|
equal(root_(ctx1), 1)
|
|
55
52
|
equal(root_(ctx), 1)
|
|
56
|
-
equal(ctx0.has(root_), false)
|
|
57
|
-
equal(ctx1.has(root_), true)
|
|
53
|
+
equal(ctx0.has(root_.id), false)
|
|
54
|
+
equal(ctx1.has(root_.id), true)
|
|
58
55
|
const child_ = be_(ctx=>root_(ctx) + 1, { id: 'child_' })
|
|
59
56
|
equal(child_(ctx), 2)
|
|
60
|
-
equal(ctx0.has(child_), true)
|
|
61
|
-
equal(ctx1.has(child_), false)
|
|
57
|
+
equal(ctx0.has(child_.id), true)
|
|
58
|
+
equal(ctx1.has(child_.id), false)
|
|
62
59
|
})
|
|
63
60
|
test('be_|nested array', ()=>{
|
|
64
61
|
const ctx0 = ctx__new()
|
|
@@ -69,16 +66,16 @@ test('be_|nested array', ()=>{
|
|
|
69
66
|
const root_ = be_(()=>1, { id: 'root_' })
|
|
70
67
|
equal(root_(ctx3), 1)
|
|
71
68
|
equal(root_(ctx), 1)
|
|
72
|
-
equal(ctx0.has(root_), false)
|
|
73
|
-
equal(ctx1.has(root_), false)
|
|
74
|
-
equal(ctx2.has(root_), false)
|
|
75
|
-
equal(ctx3.has(root_), true)
|
|
69
|
+
equal(ctx0.has(root_.id), false)
|
|
70
|
+
equal(ctx1.has(root_.id), false)
|
|
71
|
+
equal(ctx2.has(root_.id), false)
|
|
72
|
+
equal(ctx3.has(root_.id), true)
|
|
76
73
|
const child_ = be_(ctx=>root_(ctx) + 1, { id: 'child_' })
|
|
77
74
|
equal(child_(ctx), 2)
|
|
78
|
-
equal(ctx0.has(child_), true)
|
|
79
|
-
equal(ctx1.has(child_), false)
|
|
80
|
-
equal(ctx2.has(child_), false)
|
|
81
|
-
equal(ctx3.has(child_), false)
|
|
75
|
+
equal(ctx0.has(child_.id), true)
|
|
76
|
+
equal(ctx1.has(child_.id), false)
|
|
77
|
+
equal(ctx2.has(child_.id), false)
|
|
78
|
+
equal(ctx3.has(child_.id), false)
|
|
82
79
|
})
|
|
83
80
|
test('be_|is_source_', ()=>{
|
|
84
81
|
const ctx0 = ctx__new()
|
|
@@ -95,8 +92,8 @@ test('be_|is_source_', ()=>{
|
|
|
95
92
|
})
|
|
96
93
|
equal(root_(ctx), 1)
|
|
97
94
|
equal(be__ctx_a, [[ctx0, ctx1]])
|
|
98
|
-
equal(ctx0.has(root_), false)
|
|
99
|
-
equal(ctx1.has(root_), true)
|
|
95
|
+
equal(ctx0.has(root_.id), false)
|
|
96
|
+
equal(ctx1.has(root_.id), true)
|
|
100
97
|
})
|
|
101
98
|
test('be_|Ctx generic type', ()=>{
|
|
102
99
|
const valid_ctx = ctx__new() as test_ctx_T
|
|
@@ -116,8 +113,8 @@ test('be_|circular dependency', ()=>{
|
|
|
116
113
|
const be0:Be<symbol> = be_(ctx=>be1(ctx))
|
|
117
114
|
const be1:Be<symbol> = be_(ctx=>be0(ctx))
|
|
118
115
|
const ctx = ctx__new()
|
|
119
|
-
equal(
|
|
120
|
-
equal(
|
|
116
|
+
equal(be0(ctx), 'cir')
|
|
117
|
+
equal(be1(ctx), 'cir')
|
|
121
118
|
})
|
|
122
119
|
test('ctx__set', ()=>{
|
|
123
120
|
const ctx0 = ctx__new()
|
|
@@ -152,46 +149,46 @@ test('ctx__delete|be', ()=>{
|
|
|
152
149
|
const ctx0 = ctx__new()
|
|
153
150
|
const num_ = be_(()=>1)
|
|
154
151
|
ctx__delete(ctx0, num_)
|
|
155
|
-
equal(ctx0.has(num_), false)
|
|
152
|
+
equal(ctx0.has(num_.id), false)
|
|
156
153
|
num_(ctx0)
|
|
157
|
-
equal(ctx0.has(num_), true)
|
|
154
|
+
equal(ctx0.has(num_.id), true)
|
|
158
155
|
ctx__delete(ctx0, num_)
|
|
159
|
-
equal(ctx0.has(num_), false)
|
|
156
|
+
equal(ctx0.has(num_.id), false)
|
|
160
157
|
num_(ctx0)
|
|
161
|
-
equal(ctx0.has(num_), true)
|
|
158
|
+
equal(ctx0.has(num_.id), true)
|
|
162
159
|
ctx__delete(ctx0, num_)
|
|
163
|
-
equal(ctx0.has(num_), false)
|
|
160
|
+
equal(ctx0.has(num_.id), false)
|
|
164
161
|
const ctx1 = ctx__new()
|
|
165
162
|
ctx1.set('ctx1', true)
|
|
166
163
|
const nested__ctx = [ctx0, ctx1]
|
|
167
164
|
num_(ctx0)
|
|
168
165
|
num_(ctx1)
|
|
169
|
-
equal(ctx0.has(num_), true)
|
|
170
|
-
equal(ctx1.has(num_), true)
|
|
166
|
+
equal(ctx0.has(num_.id), true)
|
|
167
|
+
equal(ctx1.has(num_.id), true)
|
|
171
168
|
ctx__delete(nested__ctx, num_)
|
|
172
|
-
equal(ctx0.has(num_), false)
|
|
173
|
-
equal(ctx1.has(num_), false)
|
|
169
|
+
equal(ctx0.has(num_.id), false)
|
|
170
|
+
equal(ctx1.has(num_.id), false)
|
|
174
171
|
num_(ctx0)
|
|
175
172
|
num_(ctx1)
|
|
176
|
-
equal(ctx0.has(num_), true)
|
|
177
|
-
equal(ctx1.has(num_), true)
|
|
173
|
+
equal(ctx0.has(num_.id), true)
|
|
174
|
+
equal(ctx1.has(num_.id), true)
|
|
178
175
|
ctx__delete(nested__ctx, num_)
|
|
179
|
-
equal(ctx0.has(num_), false)
|
|
180
|
-
equal(ctx1.has(num_), false)
|
|
176
|
+
equal(ctx0.has(num_.id), false)
|
|
177
|
+
equal(ctx1.has(num_.id), false)
|
|
181
178
|
const is_source__num_ =
|
|
182
179
|
be_(()=>1, { is_source_: ctx=>!!ctx.get('ctx1') })
|
|
183
180
|
is_source__num_(nested__ctx)
|
|
184
|
-
equal(ctx0.has(is_source__num_), false)
|
|
185
|
-
equal(ctx1.has(is_source__num_), true)
|
|
181
|
+
equal(ctx0.has(is_source__num_.id), false)
|
|
182
|
+
equal(ctx1.has(is_source__num_.id), true)
|
|
186
183
|
ctx__delete(nested__ctx, is_source__num_)
|
|
187
|
-
equal(ctx0.has(is_source__num_), false)
|
|
188
|
-
equal(ctx1.has(is_source__num_), false)
|
|
184
|
+
equal(ctx0.has(is_source__num_.id), false)
|
|
185
|
+
equal(ctx1.has(is_source__num_.id), false)
|
|
189
186
|
is_source__num_(nested__ctx)
|
|
190
|
-
equal(ctx0.has(is_source__num_), false)
|
|
191
|
-
equal(ctx1.has(is_source__num_), true)
|
|
187
|
+
equal(ctx0.has(is_source__num_.id), false)
|
|
188
|
+
equal(ctx1.has(is_source__num_.id), true)
|
|
192
189
|
ctx__delete(nested__ctx, is_source__num_)
|
|
193
|
-
equal(ctx0.has(is_source__num_), false)
|
|
194
|
-
equal(ctx1.has(is_source__num_), false)
|
|
190
|
+
equal(ctx0.has(is_source__num_.id), false)
|
|
191
|
+
equal(ctx1.has(is_source__num_.id), false)
|
|
195
192
|
})
|
|
196
193
|
test('be__has_', ()=>{
|
|
197
194
|
const ctx0 = ctx__new()
|
|
@@ -223,7 +220,7 @@ test('be__val_', ()=>{
|
|
|
223
220
|
const ctx = ctx__new()
|
|
224
221
|
const val_ = be_<boolean>(()=>true, { id: 'val_' })
|
|
225
222
|
equal(val_(ctx), true)
|
|
226
|
-
equal(ctx.get(val_), true)
|
|
223
|
+
equal(ctx.get(val_.id), true)
|
|
227
224
|
equal(be__val_(val_, ctx), true)
|
|
228
225
|
ctx__set(ctx, val_, false)
|
|
229
226
|
equal(val_(ctx), false)
|
|
@@ -232,5 +229,5 @@ test('be__val_', ()=>{
|
|
|
232
229
|
test.run()
|
|
233
230
|
declare const test_ctx_sym:unique symbol
|
|
234
231
|
type test_ctx_T = Ctx&{
|
|
235
|
-
[test_ctx_sym]:
|
|
232
|
+
[test_ctx_sym]:unknown
|
|
236
233
|
}
|
|
@@ -15,6 +15,15 @@ export declare function be_memo_pair_<
|
|
|
15
15
|
|[...((ctx:Ctx, memosig:sig_T<val_T>)=>unknown)[]]
|
|
16
16
|
|[...((ctx:Ctx, memosig:sig_T<val_T>)=>unknown)[], config:be_config_T]
|
|
17
17
|
):be_memo_pair_T<val_T, _memo_T, ctx_T>
|
|
18
|
+
export declare function globalThis__be_memo_pair_<
|
|
19
|
+
val_T,
|
|
20
|
+
_memo_T extends memo_T<val_T> = memo_T<val_T>,
|
|
21
|
+
ctx_T extends Ctx = Ctx
|
|
22
|
+
>(
|
|
23
|
+
rmemo__new:(ctx:Ctx, memo:_memo_T&{ _:val_T })=>val_T,
|
|
24
|
+
...subscriber_a_THEN_config:
|
|
25
|
+
|[...((ctx:Ctx, memosig:sig_T<val_T>)=>unknown)[], config:be_config_T&{ id:string }]
|
|
26
|
+
):be_memo_pair_T<val_T, _memo_T, ctx_T>
|
|
18
27
|
export type be_memo_pair_T<
|
|
19
28
|
val_T,
|
|
20
29
|
_memo_T extends memo_T<val_T> = memo_T<val_T>,
|
|
@@ -15,6 +15,15 @@ export declare function be_memosig_triple_<
|
|
|
15
15
|
|[...((ctx:Ctx, sig:_sig_T)=>unknown)[]]
|
|
16
16
|
|[...((ctx:Ctx, sig:_sig_T)=>unknown)[], config:be_config_T]
|
|
17
17
|
):be_memosig_triple_T<val_T, _sig_T, ctx_T>
|
|
18
|
+
export declare function globalThis__be_memosig_triple_<
|
|
19
|
+
val_T,
|
|
20
|
+
_sig_T extends sig_T<val_T> = sig_T<val_T>,
|
|
21
|
+
ctx_T extends Ctx = Ctx
|
|
22
|
+
>(
|
|
23
|
+
rmemo__new:(ctx:Ctx, memosig:_sig_T)=>val_T,
|
|
24
|
+
...subscriber_a_THEN_config:
|
|
25
|
+
|[...((ctx:Ctx, sig:_sig_T)=>unknown)[], config:be_config_T&{ id:string }]
|
|
26
|
+
):be_memosig_triple_T<val_T, _sig_T, ctx_T>
|
|
18
27
|
export type be_memosig_triple_T<
|
|
19
28
|
val_T,
|
|
20
29
|
_sig_T extends sig_T<val_T> = sig_T<val_T>,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="../be_/index.d.ts" />
|
|
2
2
|
/// <reference types="../rmemo/index.d.ts" />
|
|
3
3
|
/// <reference types="./index.d.ts" />
|
|
4
|
-
import { be_ } from '../be_/index.js'
|
|
4
|
+
import { be_, globalThis__be_ } from '../be_/index.js'
|
|
5
|
+
import { ctx_, ctx__new } from '../ctx'
|
|
5
6
|
import { sig_ } from '../rmemo/index.js'
|
|
6
7
|
/**
|
|
7
8
|
* @param {Be<sig_T>|be__val__new_T<unknown>}be_OR_val__new
|
package/all/index.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export * from './LessThan/index.js'
|
|
2
|
-
export * from './MAX_INT/index.js'
|
|
3
|
-
export * from './MIN_INT/index.js'
|
|
4
|
-
export * from './Map__object/index.js'
|
|
5
|
-
export * from './NumericRange/index.js'
|
|
6
|
-
export * from './NumericUnit/index.js'
|
|
7
|
-
export * from './PHI/index.js'
|
|
8
|
-
export * from './Request/index.js'
|
|
9
|
-
export * from './Response/index.js'
|
|
10
|
-
export * from './Timeout/index.js'
|
|
11
1
|
export * from './a/index.js'
|
|
12
2
|
export * from './a_assign/index.js'
|
|
13
3
|
export * from './a_in_idx_a_map/index.js'
|
|
@@ -27,6 +17,7 @@ export * from './andand_or/index.js'
|
|
|
27
17
|
export * from './andandfn/index.js'
|
|
28
18
|
export * from './apply/index.js'
|
|
29
19
|
export * from './arg_i0_a/index.js'
|
|
20
|
+
export * from './arg_memo/index.js'
|
|
30
21
|
export * from './array_types/index.js'
|
|
31
22
|
export * from './array_types/index.js'
|
|
32
23
|
export * from './assign/index.js'
|
|
@@ -142,10 +133,10 @@ export * from './format_date_prose/index.js'
|
|
|
142
133
|
export * from './format_utc_date_prose/index.js'
|
|
143
134
|
export * from './globalThis__prop__ensure/index.js'
|
|
144
135
|
export * from './gte_0_a/index.js'
|
|
145
|
-
export * from './hasOwnProperty_pick/index.js'
|
|
146
136
|
export * from './has_key/index.js'
|
|
147
137
|
export * from './has_multiple/index.js'
|
|
148
138
|
export * from './has_some_key/index.js'
|
|
139
|
+
export * from './hasOwnProperty_pick/index.js'
|
|
149
140
|
export * from './head_arg_a/index.js'
|
|
150
141
|
export * from './headers/index.js'
|
|
151
142
|
export * from './hex__digest/index.js'
|
|
@@ -199,6 +190,7 @@ export * from './keys/index.js'
|
|
|
199
190
|
export * from './last/index.js'
|
|
200
191
|
export * from './left_and/index.js'
|
|
201
192
|
export * from './left_or/index.js'
|
|
193
|
+
export * from './LessThan/index.js'
|
|
202
194
|
export * from './lte_0_a/index.js'
|
|
203
195
|
export * from './m_m_yyyy/index.js'
|
|
204
196
|
export * from './m_yy/index.js'
|
|
@@ -206,6 +198,7 @@ export * from './m_yyyy/index.js'
|
|
|
206
198
|
export * from './many_andand/index.js'
|
|
207
199
|
export * from './many_andand_or/index.js'
|
|
208
200
|
export * from './map/index.js'
|
|
201
|
+
export * from './Map__object/index.js'
|
|
209
202
|
export * from './map_andand/index.js'
|
|
210
203
|
export * from './map_andand_or/index.js'
|
|
211
204
|
export * from './map_andandfn/index.js'
|
|
@@ -220,12 +213,12 @@ export * from './matrix__dot/index.js'
|
|
|
220
213
|
export * from './matrix__dot__scalar/index.js'
|
|
221
214
|
export * from './matrix__normalize/index.js'
|
|
222
215
|
export * from './matrix__validate_length/index.js'
|
|
216
|
+
export * from './MAX_INT/index.js'
|
|
223
217
|
export * from './maybe/index.js'
|
|
224
218
|
export * from './mean/index.js'
|
|
225
219
|
export * from './median/index.js'
|
|
226
|
-
export * from './memo/index.js'
|
|
227
|
-
export * from './rmemo__wait/index.js'
|
|
228
220
|
export * from './merge/index.js'
|
|
221
|
+
export * from './MIN_INT/index.js'
|
|
229
222
|
export * from './minute/index.js'
|
|
230
223
|
export * from './minute/index.js'
|
|
231
224
|
export * from './minute_seconds/index.js'
|
|
@@ -264,6 +257,8 @@ export * from './number_or_mdash_str/index.js'
|
|
|
264
257
|
export * from './numerator_or_0_avg/index.js'
|
|
265
258
|
export * from './numerator_or_0_sum/index.js'
|
|
266
259
|
export * from './numeric_range/index.js'
|
|
260
|
+
export * from './NumericRange/index.js'
|
|
261
|
+
export * from './NumericUnit/index.js'
|
|
267
262
|
export * from './o_a_present/index.js'
|
|
268
263
|
export * from './o_a_present/index.js'
|
|
269
264
|
export * from './o_some/index.js'
|
|
@@ -287,6 +282,7 @@ export * from './pathname/index.js'
|
|
|
287
282
|
export * from './percentage_str/index.js'
|
|
288
283
|
export * from './percentage_str_float/index.js'
|
|
289
284
|
export * from './performance__now/index.js'
|
|
285
|
+
export * from './PHI/index.js'
|
|
290
286
|
export * from './pick/index.js'
|
|
291
287
|
export * from './pick_keys/index.js'
|
|
292
288
|
export * from './pick_val_a/index.js'
|
|
@@ -312,14 +308,17 @@ export * from './reduce/index.js'
|
|
|
312
308
|
export * from './reject/index.js'
|
|
313
309
|
export * from './remove/index.js'
|
|
314
310
|
export * from './remove_idx/index.js'
|
|
311
|
+
export * from './Request/index.js'
|
|
315
312
|
export * from './resolver_curry/index.js'
|
|
316
313
|
export * from './resolver_curry/index.js'
|
|
314
|
+
export * from './Response/index.js'
|
|
317
315
|
export * from './response_o/index.js'
|
|
318
316
|
export * from './response_pair/index.js'
|
|
319
317
|
export * from './reverse/index.js'
|
|
320
318
|
export * from './right_and/index.js'
|
|
321
319
|
export * from './right_or/index.js'
|
|
322
320
|
export * from './rmemo/index.js'
|
|
321
|
+
export * from './rmemo__wait/index.js'
|
|
323
322
|
export * from './round/index.js'
|
|
324
323
|
export * from './run/index.js'
|
|
325
324
|
export * from './run_pipe/index.js'
|
|
@@ -356,6 +355,7 @@ export * from './throttle/index.js'
|
|
|
356
355
|
export * from './tick/index.js'
|
|
357
356
|
export * from './timedout/index.js'
|
|
358
357
|
export * from './timedout/index.js'
|
|
358
|
+
export * from './Timeout/index.js'
|
|
359
359
|
export * from './timeout_promise/index.js'
|
|
360
360
|
export * from './times/index.js'
|
|
361
361
|
export * from './timestamp_ms/index.js'
|
|
@@ -378,9 +378,9 @@ export * from './url_basename/index.js'
|
|
|
378
378
|
export * from './url_segment/index.js'
|
|
379
379
|
export * from './url_segment/index.js'
|
|
380
380
|
export * from './urn_url/index.js'
|
|
381
|
-
export * from './utc_MM_yyyy/index.js'
|
|
382
|
-
export * from './utc_M_yyyy/index.js'
|
|
383
381
|
export * from './utc_m_yy/index.js'
|
|
382
|
+
export * from './utc_M_yyyy/index.js'
|
|
383
|
+
export * from './utc_MM_yyyy/index.js'
|
|
384
384
|
export * from './utc_yyyymmdd/index.js'
|
|
385
385
|
export * from './utc_yyyymmddhhmmss/index.js'
|
|
386
386
|
export * from './uuid/index.js'
|
package/all/index.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export * from './LessThan/index.js'
|
|
2
|
-
export * from './MAX_INT/index.js'
|
|
3
|
-
export * from './MIN_INT/index.js'
|
|
4
|
-
export * from './Map__object/index.js'
|
|
5
|
-
export * from './NumericRange/index.js'
|
|
6
|
-
export * from './NumericUnit/index.js'
|
|
7
|
-
export * from './PHI/index.js'
|
|
8
|
-
export * from './Request/index.js'
|
|
9
|
-
export * from './Response/index.js'
|
|
10
|
-
export * from './Timeout/index.js'
|
|
11
1
|
export * from './a/index.js'
|
|
12
2
|
export * from './a_assign/index.js'
|
|
13
3
|
export * from './a_in_idx_a_map/index.js'
|
|
@@ -27,6 +17,7 @@ export * from './andand_or/index.js'
|
|
|
27
17
|
export * from './andandfn/index.js'
|
|
28
18
|
export * from './apply/index.js'
|
|
29
19
|
export * from './arg_i0_a/index.js'
|
|
20
|
+
export * from './arg_memo/index.js'
|
|
30
21
|
export * from './array_types/index.js'
|
|
31
22
|
export * from './array_types/index.js'
|
|
32
23
|
export * from './assign/index.js'
|
|
@@ -142,10 +133,10 @@ export * from './format_date_prose/index.js'
|
|
|
142
133
|
export * from './format_utc_date_prose/index.js'
|
|
143
134
|
export * from './globalThis__prop__ensure/index.js'
|
|
144
135
|
export * from './gte_0_a/index.js'
|
|
145
|
-
export * from './hasOwnProperty_pick/index.js'
|
|
146
136
|
export * from './has_key/index.js'
|
|
147
137
|
export * from './has_multiple/index.js'
|
|
148
138
|
export * from './has_some_key/index.js'
|
|
139
|
+
export * from './hasOwnProperty_pick/index.js'
|
|
149
140
|
export * from './head_arg_a/index.js'
|
|
150
141
|
export * from './headers/index.js'
|
|
151
142
|
export * from './hex__digest/index.js'
|
|
@@ -199,6 +190,7 @@ export * from './keys/index.js'
|
|
|
199
190
|
export * from './last/index.js'
|
|
200
191
|
export * from './left_and/index.js'
|
|
201
192
|
export * from './left_or/index.js'
|
|
193
|
+
export * from './LessThan/index.js'
|
|
202
194
|
export * from './lte_0_a/index.js'
|
|
203
195
|
export * from './m_m_yyyy/index.js'
|
|
204
196
|
export * from './m_yy/index.js'
|
|
@@ -206,6 +198,7 @@ export * from './m_yyyy/index.js'
|
|
|
206
198
|
export * from './many_andand/index.js'
|
|
207
199
|
export * from './many_andand_or/index.js'
|
|
208
200
|
export * from './map/index.js'
|
|
201
|
+
export * from './Map__object/index.js'
|
|
209
202
|
export * from './map_andand/index.js'
|
|
210
203
|
export * from './map_andand_or/index.js'
|
|
211
204
|
export * from './map_andandfn/index.js'
|
|
@@ -220,12 +213,12 @@ export * from './matrix__dot/index.js'
|
|
|
220
213
|
export * from './matrix__dot__scalar/index.js'
|
|
221
214
|
export * from './matrix__normalize/index.js'
|
|
222
215
|
export * from './matrix__validate_length/index.js'
|
|
216
|
+
export * from './MAX_INT/index.js'
|
|
223
217
|
export * from './maybe/index.js'
|
|
224
218
|
export * from './mean/index.js'
|
|
225
219
|
export * from './median/index.js'
|
|
226
|
-
export * from './memo/index.js'
|
|
227
|
-
export * from './rmemo__wait/index.js'
|
|
228
220
|
export * from './merge/index.js'
|
|
221
|
+
export * from './MIN_INT/index.js'
|
|
229
222
|
export * from './minute/index.js'
|
|
230
223
|
export * from './minute/index.js'
|
|
231
224
|
export * from './minute_seconds/index.js'
|
|
@@ -264,6 +257,8 @@ export * from './number_or_mdash_str/index.js'
|
|
|
264
257
|
export * from './numerator_or_0_avg/index.js'
|
|
265
258
|
export * from './numerator_or_0_sum/index.js'
|
|
266
259
|
export * from './numeric_range/index.js'
|
|
260
|
+
export * from './NumericRange/index.js'
|
|
261
|
+
export * from './NumericUnit/index.js'
|
|
267
262
|
export * from './o_a_present/index.js'
|
|
268
263
|
export * from './o_a_present/index.js'
|
|
269
264
|
export * from './o_some/index.js'
|
|
@@ -287,6 +282,7 @@ export * from './pathname/index.js'
|
|
|
287
282
|
export * from './percentage_str/index.js'
|
|
288
283
|
export * from './percentage_str_float/index.js'
|
|
289
284
|
export * from './performance__now/index.js'
|
|
285
|
+
export * from './PHI/index.js'
|
|
290
286
|
export * from './pick/index.js'
|
|
291
287
|
export * from './pick_keys/index.js'
|
|
292
288
|
export * from './pick_val_a/index.js'
|
|
@@ -312,14 +308,17 @@ export * from './reduce/index.js'
|
|
|
312
308
|
export * from './reject/index.js'
|
|
313
309
|
export * from './remove/index.js'
|
|
314
310
|
export * from './remove_idx/index.js'
|
|
311
|
+
export * from './Request/index.js'
|
|
315
312
|
export * from './resolver_curry/index.js'
|
|
316
313
|
export * from './resolver_curry/index.js'
|
|
314
|
+
export * from './Response/index.js'
|
|
317
315
|
export * from './response_o/index.js'
|
|
318
316
|
export * from './response_pair/index.js'
|
|
319
317
|
export * from './reverse/index.js'
|
|
320
318
|
export * from './right_and/index.js'
|
|
321
319
|
export * from './right_or/index.js'
|
|
322
320
|
export * from './rmemo/index.js'
|
|
321
|
+
export * from './rmemo__wait/index.js'
|
|
323
322
|
export * from './round/index.js'
|
|
324
323
|
export * from './run/index.js'
|
|
325
324
|
export * from './run_pipe/index.js'
|
|
@@ -356,6 +355,7 @@ export * from './throttle/index.js'
|
|
|
356
355
|
export * from './tick/index.js'
|
|
357
356
|
export * from './timedout/index.js'
|
|
358
357
|
export * from './timedout/index.js'
|
|
358
|
+
export * from './Timeout/index.js'
|
|
359
359
|
export * from './timeout_promise/index.js'
|
|
360
360
|
export * from './times/index.js'
|
|
361
361
|
export * from './timestamp_ms/index.js'
|
|
@@ -378,9 +378,9 @@ export * from './url_basename/index.js'
|
|
|
378
378
|
export * from './url_segment/index.js'
|
|
379
379
|
export * from './url_segment/index.js'
|
|
380
380
|
export * from './urn_url/index.js'
|
|
381
|
-
export * from './utc_MM_yyyy/index.js'
|
|
382
|
-
export * from './utc_M_yyyy/index.js'
|
|
383
381
|
export * from './utc_m_yy/index.js'
|
|
382
|
+
export * from './utc_M_yyyy/index.js'
|
|
383
|
+
export * from './utc_MM_yyyy/index.js'
|
|
384
384
|
export * from './utc_yyyymmdd/index.js'
|
|
385
385
|
export * from './utc_yyyymmddhhmmss/index.js'
|
|
386
386
|
export * from './uuid/index.js'
|
package/function/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export * from '../all/map_apply/index.js'
|
|
|
45
45
|
export * from '../all/map_call/index.js'
|
|
46
46
|
export * from '../all/map_fn/index.js'
|
|
47
47
|
export * from '../all/maybe/index.js'
|
|
48
|
-
export * from '../all/
|
|
48
|
+
export * from '../all/arg_memo/index.js'
|
|
49
49
|
export * from '../all/neq/index.js'
|
|
50
50
|
export * from '../all/neql/index.js'
|
|
51
51
|
export * from '../all/nf/index.js'
|
package/function/index.js
CHANGED
|
@@ -45,7 +45,7 @@ export * from '../all/map_apply/index.js'
|
|
|
45
45
|
export * from '../all/map_call/index.js'
|
|
46
46
|
export * from '../all/map_fn/index.js'
|
|
47
47
|
export * from '../all/maybe/index.js'
|
|
48
|
-
export * from '../all/
|
|
48
|
+
export * from '../all/arg_memo/index.js'
|
|
49
49
|
export * from '../all/neq/index.js'
|
|
50
50
|
export * from '../all/neql/index.js'
|
|
51
51
|
export * from '../all/nf/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ctx-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"description": "ctx-core core library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -135,14 +135,14 @@
|
|
|
135
135
|
"import": {
|
|
136
136
|
"./be": "{ be_ }"
|
|
137
137
|
},
|
|
138
|
-
"limit": "
|
|
138
|
+
"limit": "147 B"
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
141
|
"name": "be_ ctx_",
|
|
142
142
|
"import": {
|
|
143
143
|
"./be": "{ be_, ctx_ }"
|
|
144
144
|
},
|
|
145
|
-
"limit": "
|
|
145
|
+
"limit": "173 B"
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"name": "memo_",
|
|
@@ -163,14 +163,14 @@
|
|
|
163
163
|
"import": {
|
|
164
164
|
"./rmemo": "{ sig_, memo_, be_, ctx_ }"
|
|
165
165
|
},
|
|
166
|
-
"limit": "
|
|
166
|
+
"limit": "494 B"
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
169
|
"name": "memo_ sig_ be_ ctx_ be_memo_pair_ be_sig_triple_",
|
|
170
170
|
"import": {
|
|
171
171
|
"./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
|
|
172
172
|
},
|
|
173
|
-
"limit": "
|
|
173
|
+
"limit": "591 B"
|
|
174
174
|
}
|
|
175
175
|
],
|
|
176
176
|
"scripts": {
|