ctx-core 4.13.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/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 +1 -1
|
@@ -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/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'
|