ctx-core 5.5.0 → 5.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all/be/index.d.ts +6 -2
- package/all/be/index.js +3 -2
- package/all/btoa/index.js +4 -3
- package/all/hex__base64/index.d.ts +2 -0
- package/all/hex__base64/index.js +6 -0
- package/all/hex__base64/index.test.ts +15 -0
- package/all/index.d.ts +2 -0
- package/all/index.js +2 -0
- package/all/is_entry_file/index.d.ts +4 -0
- package/all/is_entry_file/index.js +8 -0
- package/all/is_entry_file/index.test.ts +30 -0
- package/all/ms/index.js +2 -2
- package/all/queue/index.test.ts +20 -20
- package/all/rmemo/index.js +5 -5
- package/all/run/index.d.ts +4 -0
- package/all/run/index.js +7 -4
- package/all/run/index.test.ts +19 -0
- package/all/tick/index.js +4 -5
- package/all/uuid/index.d.ts +2 -0
- package/all/uuid/index.js +31 -12
- package/all/uuid/index.test.ts +27 -0
- package/crypto/index.d.ts +2 -0
- package/crypto/index.js +2 -0
- package/fs/index.d.ts +1 -0
- package/fs/index.js +1 -0
- package/package.json +239 -224
- package/rmemo/index.d.ts +1 -0
- package/rmemo/index.js +1 -0
- package/uuid/index.d.ts +1 -0
- package/uuid/index.js +1 -0
package/all/be/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { be__val__new_T, Ctx, Ctx_wide_T } from '../be_/index.js'
|
|
1
|
+
import type { be__val__new_T, be_config_T, Ctx, Ctx_wide_T } from '../be_/index.js'
|
|
2
2
|
export declare function be<
|
|
3
3
|
Out extends NonNullable<unknown>,
|
|
4
4
|
ns_T extends string = '',
|
|
5
5
|
ctx_T extends Ctx = Ctx_wide_T<ns_T>
|
|
6
|
-
>(
|
|
6
|
+
>(
|
|
7
|
+
ctx:ctx_T,
|
|
8
|
+
val_:be__val__new_T<Out, ns_T, ctx_T>,
|
|
9
|
+
config:be_config_T<ns_T>
|
|
10
|
+
):Out
|
|
7
11
|
export { be as b, }
|
package/all/be/index.js
CHANGED
|
@@ -3,9 +3,10 @@ import { be_ } from '../be_/index.js'
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {Ctx}ctx
|
|
5
5
|
* @param {be__val__new_T}val_
|
|
6
|
+
* @param {be_config_T}[config]
|
|
6
7
|
* @returns {NonNullable<unknown>}
|
|
7
8
|
*/
|
|
8
|
-
export function be(ctx, val_) {
|
|
9
|
-
return be_(val_)(ctx)
|
|
9
|
+
export function be(ctx, val_, config) {
|
|
10
|
+
return be_(val_, config)(ctx)
|
|
10
11
|
}
|
|
11
12
|
export { be as b, }
|
package/all/btoa/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="../btoa/index.d.ts" />
|
|
2
|
+
import { process_release_name } from '../process_release_name'
|
|
2
3
|
/**
|
|
3
4
|
* @param {string}str
|
|
4
5
|
* @returns {string}
|
|
5
6
|
*/
|
|
6
7
|
export function btoa(str) {
|
|
7
8
|
return (
|
|
8
|
-
|
|
9
|
-
?
|
|
10
|
-
:
|
|
9
|
+
process_release_name
|
|
10
|
+
? new Buffer(str).toString('base64')
|
|
11
|
+
: window.btoa(str)
|
|
11
12
|
)
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { test } from 'uvu'
|
|
2
|
+
import { equal } from 'uvu/assert'
|
|
3
|
+
import { hex__base64_ } from './index.js'
|
|
4
|
+
test('hex__base64_', ()=>{
|
|
5
|
+
const uuid = '8a88c23d4a6946acb9751ab4590a470c'
|
|
6
|
+
const expected_b64 = 'iojCPUppRqy5dRq0WQpHDA=='
|
|
7
|
+
equal(hex__base64_(uuid), expected_b64)
|
|
8
|
+
// verify the isomorphic solution is the same as nodejs
|
|
9
|
+
equal(
|
|
10
|
+
Buffer
|
|
11
|
+
.from(uuid.replaceAll('-', ''), 'hex')
|
|
12
|
+
.toString('base64'),
|
|
13
|
+
expected_b64)
|
|
14
|
+
})
|
|
15
|
+
test.run()
|
package/all/index.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ export * from './has_multiple/index.js'
|
|
|
170
170
|
export * from './has_some_key/index.js'
|
|
171
171
|
export * from './head_arg_a/index.js'
|
|
172
172
|
export * from './headers/index.js'
|
|
173
|
+
export * from './hex__base64/index.js'
|
|
173
174
|
export * from './hex__digest/index.js'
|
|
174
175
|
export * from './hex_int/index.js'
|
|
175
176
|
export * from './hmac/index.js'
|
|
@@ -225,6 +226,7 @@ export * from './isPrimitive/index.js'
|
|
|
225
226
|
export * from './isPromiseLike/index.js'
|
|
226
227
|
export * from './is_browser/index.js'
|
|
227
228
|
export * from './is_development/index.js'
|
|
229
|
+
export * from './is_entry_file/index.js'
|
|
228
230
|
export * from './is_production/index.js'
|
|
229
231
|
export * from './is_server/index.js'
|
|
230
232
|
export * from './is_staging/index.js'
|
package/all/index.js
CHANGED
|
@@ -170,6 +170,7 @@ export * from './has_multiple/index.js'
|
|
|
170
170
|
export * from './has_some_key/index.js'
|
|
171
171
|
export * from './head_arg_a/index.js'
|
|
172
172
|
export * from './headers/index.js'
|
|
173
|
+
export * from './hex__base64/index.js'
|
|
173
174
|
export * from './hex__digest/index.js'
|
|
174
175
|
export * from './hex_int/index.js'
|
|
175
176
|
export * from './hmac/index.js'
|
|
@@ -225,6 +226,7 @@ export * from './isPrimitive/index.js'
|
|
|
225
226
|
export * from './isPromiseLike/index.js'
|
|
226
227
|
export * from './is_browser/index.js'
|
|
227
228
|
export * from './is_development/index.js'
|
|
229
|
+
export * from './is_entry_file/index.js'
|
|
228
230
|
export * from './is_production/index.js'
|
|
229
231
|
export * from './is_server/index.js'
|
|
230
232
|
export * from './is_staging/index.js'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { process_release_name } from '../process_release_name/index.js'
|
|
2
|
+
export function is_entry_file_(url, entry_path) {
|
|
3
|
+
if (!process_release_name) return false
|
|
4
|
+
return (
|
|
5
|
+
import('node:path').then(({ resolve })=>
|
|
6
|
+
new URL(url).pathname === resolve(entry_path ?? process.argv[1]))
|
|
7
|
+
)
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import esmock from 'esmock'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import { test } from 'uvu'
|
|
4
|
+
import { equal } from 'uvu/assert'
|
|
5
|
+
import { is_entry_file_ } from './index.js'
|
|
6
|
+
test('is_entry_file_|node', async ()=>{
|
|
7
|
+
equal(
|
|
8
|
+
await is_entry_file_(import.meta.url, new URL(import.meta.url).pathname),
|
|
9
|
+
true)
|
|
10
|
+
equal(
|
|
11
|
+
await is_entry_file_(
|
|
12
|
+
import.meta.url,
|
|
13
|
+
new URL(import.meta.url).pathname.replace(
|
|
14
|
+
resolve(process.cwd()) + '/', '')),
|
|
15
|
+
true)
|
|
16
|
+
equal(
|
|
17
|
+
await is_entry_file_(import.meta.url, '/not/url'),
|
|
18
|
+
false)
|
|
19
|
+
})
|
|
20
|
+
test('is_entry_file_|browser', async ()=>{
|
|
21
|
+
const { is_entry_file_ } = await esmock('./index.js', {
|
|
22
|
+
'../process_release_name/index.js': {
|
|
23
|
+
process_release_name: undefined
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
equal(
|
|
27
|
+
is_entry_file_(import.meta.url, new URL(import.meta.url).pathname),
|
|
28
|
+
false)
|
|
29
|
+
})
|
|
30
|
+
test.run()
|
package/all/ms/index.js
CHANGED
package/all/queue/index.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { tick } from '../tick/index.js'
|
|
|
7
7
|
test('queue_(1).add|queue length of 1 at a time', async ()=>{
|
|
8
8
|
const queue = queue_(1)
|
|
9
9
|
const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
|
|
10
|
-
const ret_a:
|
|
10
|
+
const ret_a:unknown[] = [null, null, null]
|
|
11
11
|
queue.add(()=>promise_o_a[0].promise).then(ret=>ret_a[0] = ret)
|
|
12
12
|
queue.add(()=>promise_o_a[1].promise).then(ret=>ret_a[1] = ret)
|
|
13
13
|
queue.add(()=>promise_o_a[2].promise).then(ret=>ret_a[2] = ret)
|
|
@@ -23,17 +23,17 @@ test('queue_(1).add|queue length of 1 at a time', async ()=>{
|
|
|
23
23
|
promise_o_a[2].resolve('val2')
|
|
24
24
|
await tick()
|
|
25
25
|
equal(ret_a, ['val0', 'val1', 'val2'])
|
|
26
|
-
const close__promise__arg_aa:
|
|
26
|
+
const close__promise__arg_aa:unknown[][] = []
|
|
27
27
|
queue.close()
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
.then((...arg_a)=>
|
|
29
|
+
close__promise__arg_aa.push(arg_a))
|
|
30
30
|
await tick()
|
|
31
31
|
equal(close__promise__arg_aa, [[3]])
|
|
32
32
|
})
|
|
33
33
|
test('queue_(2).add|queue length of 2 at a time', async ()=>{
|
|
34
34
|
const queue = queue_(2)
|
|
35
35
|
const promise_o_a = [promise_o_(), promise_o_(), promise_o_(), promise_o_()]
|
|
36
|
-
const ret_a:
|
|
36
|
+
const ret_a:unknown[] = [null, null, null, null]
|
|
37
37
|
queue.add(()=>promise_o_a[0].promise).then(ret=>ret_a[0] = ret)
|
|
38
38
|
queue.add(()=>promise_o_a[1].promise).then(ret=>ret_a[1] = ret)
|
|
39
39
|
queue.add(()=>promise_o_a[2].promise).then(ret=>ret_a[2] = ret)
|
|
@@ -55,17 +55,17 @@ test('queue_(2).add|queue length of 2 at a time', async ()=>{
|
|
|
55
55
|
promise_o_a[1].resolve('val1')
|
|
56
56
|
await tick()
|
|
57
57
|
equal(ret_a, ['val0', 'val1', 'val2', 'val3'])
|
|
58
|
-
const close__promise__arg_aa:
|
|
58
|
+
const close__promise__arg_aa:unknown[][] = []
|
|
59
59
|
queue.close()
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
.then((...arg_a)=>
|
|
61
|
+
close__promise__arg_aa.push(arg_a))
|
|
62
62
|
await tick()
|
|
63
63
|
equal(close__promise__arg_aa, [[4]])
|
|
64
64
|
})
|
|
65
65
|
test('queue_(1).add_sync|queue length of 1 at a time', async ()=>{
|
|
66
66
|
const queue = queue_(1)
|
|
67
67
|
const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
|
|
68
|
-
const ret_a:
|
|
68
|
+
const ret_a:unknown[] = [null, null, null]
|
|
69
69
|
ret_a[0] = queue.add_sync(()=>promise_o_a[0].promise)
|
|
70
70
|
equal(ret_a, [1, null, null])
|
|
71
71
|
ret_a[1] = queue.add_sync(()=>promise_o_a[1].promise)
|
|
@@ -76,7 +76,7 @@ test('queue_(1).add_sync|queue length of 1 at a time', async ()=>{
|
|
|
76
76
|
test('queue_(2).add_sync|queue length of 2 at a time', async ()=>{
|
|
77
77
|
const queue = queue_(2)
|
|
78
78
|
const promise_o_a = [promise_o_(), promise_o_(), promise_o_(), promise_o_()]
|
|
79
|
-
const ret_a:
|
|
79
|
+
const ret_a:unknown[] = [null, null, null, null]
|
|
80
80
|
ret_a[0] = queue.add_sync(()=>promise_o_a[0].promise)
|
|
81
81
|
equal(ret_a, [1, null, null, null])
|
|
82
82
|
ret_a[1] = queue.add_sync(()=>promise_o_a[1].promise)
|
|
@@ -102,15 +102,15 @@ test('queue_(2).cancel|immediately stops queue discarding pending jobs|returns p
|
|
|
102
102
|
promise_o_(),
|
|
103
103
|
promise_o_()
|
|
104
104
|
]
|
|
105
|
-
const ret_a:
|
|
105
|
+
const ret_a:unknown[] = [null, null, null, null]
|
|
106
106
|
queue.add(()=>promise_o_a[0].promise).then(ret=>ret_a[0] = ret)
|
|
107
107
|
queue.add(()=>promise_o_a[1].promise).then(ret=>ret_a[1] = ret)
|
|
108
108
|
queue.add(()=>promise_o_a[2].promise).then(ret=>ret_a[2] = ret)
|
|
109
109
|
queue.add(()=>promise_o_a[3].promise).then(ret=>ret_a[3] = ret)
|
|
110
|
-
const close__promise__arg_aa:
|
|
110
|
+
const close__promise__arg_aa:unknown[][] = []
|
|
111
111
|
queue.close()
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
.then((...arg_a)=>
|
|
113
|
+
close__promise__arg_aa.push(arg_a))
|
|
114
114
|
equal(ret_a, [null, null, null, null])
|
|
115
115
|
equal(pending, undefined)
|
|
116
116
|
equal(close__promise__arg_aa, [])
|
|
@@ -134,16 +134,16 @@ test('throttle|number', async ()=>{
|
|
|
134
134
|
const queue = queue_(2)
|
|
135
135
|
const promise_o_a = [promise_o_(), promise_o_(), promise_o_(), promise_o_(), promise_o_()]
|
|
136
136
|
promise_o_a.map(pending_o=>queue.add(()=>pending_o.promise))
|
|
137
|
-
const pending__wait__arg_aa:
|
|
138
|
-
const throttle__then = (...arg_a:
|
|
137
|
+
const pending__wait__arg_aa:unknown[][] = []
|
|
138
|
+
const throttle__then = (...arg_a:unknown[])=>{
|
|
139
139
|
pending__wait__arg_aa.push(arg_a)
|
|
140
140
|
}
|
|
141
141
|
queue.throttle(5)
|
|
142
|
-
|
|
142
|
+
.then(throttle__then)
|
|
143
143
|
await tick()
|
|
144
144
|
equal(pending__wait__arg_aa, [[5]])
|
|
145
145
|
queue.throttle(3)
|
|
146
|
-
|
|
146
|
+
.then(throttle__then)
|
|
147
147
|
await tick()
|
|
148
148
|
equal(pending__wait__arg_aa, [[5]])
|
|
149
149
|
promise_o_a[0].resolve(true)
|
|
@@ -159,8 +159,8 @@ test('throttle|fn', async ()=>{
|
|
|
159
159
|
const queue = queue_(2)
|
|
160
160
|
const promise_o_a = [promise_o_(), promise_o_(), promise_o_(), promise_o_(), promise_o_()]
|
|
161
161
|
promise_o_a.map(pending_o=>queue.add(()=>pending_o.promise))
|
|
162
|
-
const pending__wait__arg_aa:
|
|
163
|
-
const throttle__then = (...arg_a:
|
|
162
|
+
const pending__wait__arg_aa:unknown[][] = []
|
|
163
|
+
const throttle__then = (...arg_a:unknown[])=>{
|
|
164
164
|
pending__wait__arg_aa.push(arg_a)
|
|
165
165
|
}
|
|
166
166
|
queue.throttle(item_count=>
|
package/all/rmemo/index.js
CHANGED
|
@@ -4,8 +4,8 @@ let cur_memo
|
|
|
4
4
|
/** @type {Set<()=>unknown>} */
|
|
5
5
|
let queue = new Set
|
|
6
6
|
/**
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {memo_def_T}memo_def
|
|
8
|
+
* @param {memo_subscriber_T<unknown>[]}subscriber_a
|
|
9
9
|
* @returns {memo_T}
|
|
10
10
|
* @private
|
|
11
11
|
*/
|
|
@@ -80,8 +80,8 @@ export function memo_(memo_def, ...subscriber_a) {
|
|
|
80
80
|
}
|
|
81
81
|
export { memo_ as memosig_ }
|
|
82
82
|
/**
|
|
83
|
-
* @param {
|
|
84
|
-
* @param {
|
|
83
|
+
* @param {memo_def_T}memo_def
|
|
84
|
+
* @param {memo_subscriber_T<unknown>[]}subscriber_a
|
|
85
85
|
* @returns {sig_T}
|
|
86
86
|
* @private
|
|
87
87
|
*/
|
|
@@ -102,7 +102,7 @@ export function lock_memosig_(memo_def, ...subscriber_a) {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* @param {unknown}init_val
|
|
105
|
-
* @param {
|
|
105
|
+
* @param {memo_subscriber_T[]}subscriber_a
|
|
106
106
|
* @returns {sig_T}
|
|
107
107
|
* @private
|
|
108
108
|
*/
|
package/all/run/index.d.ts
CHANGED
package/all/run/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { nullish__none_ } from '../nullish__none/index.js'
|
|
2
1
|
/**
|
|
3
|
-
* @param
|
|
2
|
+
* @param {(...arg_a:unknown)=>unknown}fn
|
|
4
3
|
* @param {unknown}arg_a
|
|
5
4
|
* @returns {unknown}
|
|
6
5
|
*/
|
|
7
|
-
export function run(
|
|
8
|
-
return
|
|
6
|
+
export function run(...arg_a) {
|
|
7
|
+
return (
|
|
8
|
+
typeof arg_a[0] === 'function'
|
|
9
|
+
? arg_a[0](...arg_a.slice(1))
|
|
10
|
+
: arg_a[1](...arg_a[0])
|
|
11
|
+
)
|
|
9
12
|
}
|
|
10
13
|
export { run as _ }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { test } from 'uvu'
|
|
2
|
+
import { equal } from 'uvu/assert'
|
|
3
|
+
import { run } from './index.js'
|
|
4
|
+
test('run|fn first', ()=>{
|
|
5
|
+
equal(run(()=>1), 1)
|
|
6
|
+
equal(
|
|
7
|
+
run((a, b, c)=>[a, b, c],
|
|
8
|
+
0, 1, 2),
|
|
9
|
+
[0, 1, 2])
|
|
10
|
+
})
|
|
11
|
+
test('run|arg_a first', ()=>{
|
|
12
|
+
equal(run([], ()=>1), 1)
|
|
13
|
+
equal(
|
|
14
|
+
run(
|
|
15
|
+
[0, 1, 2],
|
|
16
|
+
(a, b, c)=>[a, b, c]),
|
|
17
|
+
[0, 1, 2])
|
|
18
|
+
})
|
|
19
|
+
test.run()
|
package/all/tick/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { run } from '../run/index.js'
|
|
2
1
|
/**
|
|
3
2
|
* Calls setTimeout
|
|
4
3
|
* @param {()=>unknown}[fn]
|
|
@@ -6,16 +5,16 @@ import { run } from '../run/index.js'
|
|
|
6
5
|
* @returns {Promise<unknown>}
|
|
7
6
|
*/
|
|
8
7
|
export function tick(fn, timeout = 0) {
|
|
9
|
-
return new Promise((
|
|
8
|
+
return new Promise((resolve, reject)=>{
|
|
10
9
|
if (!timeout) {
|
|
11
10
|
queueMicrotask(()=>
|
|
12
|
-
|
|
11
|
+
resolve(fn?.()))
|
|
13
12
|
} else {
|
|
14
13
|
setTimeout(()=>{
|
|
15
14
|
try {
|
|
16
|
-
|
|
15
|
+
resolve(fn?.())
|
|
17
16
|
} catch (e) {
|
|
18
|
-
|
|
17
|
+
reject(e)
|
|
19
18
|
}
|
|
20
19
|
}, timeout)
|
|
21
20
|
}
|
package/all/uuid/index.d.ts
CHANGED
package/all/uuid/index.js
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
|
-
//https://gist.github.com/LeverOne/1308368
|
|
2
1
|
export function uuid_() {
|
|
2
|
+
return crypto.randomUUID()
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
uuid_ as _uuid,
|
|
6
|
+
uuid_ as uuid,
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @param {string}[uuid]
|
|
10
|
+
* @returns {string}
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
export function short_uuid_(uuid) {
|
|
14
|
+
uuid = (uuid ?? crypto.randomUUID()).replaceAll('-', '')
|
|
15
|
+
let str = ''
|
|
16
|
+
for (let i = 0; i < uuid.length; i += 2)
|
|
17
|
+
str += String.fromCharCode(parseInt(uuid.slice(i, i + 2), 16))
|
|
18
|
+
return btoa(str).replace('==', '')
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @returns {string}
|
|
22
|
+
* @see {@link https://gist.github.com/LeverOne/1308368}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
export function polyfill_uuid_() {
|
|
3
26
|
let a = 0, b = ''
|
|
4
27
|
for (
|
|
5
28
|
;
|
|
6
29
|
a++ < 36;
|
|
7
|
-
b += a * 51 & 52
|
|
8
|
-
? (a ^ 15
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
).toString(16)
|
|
12
|
-
|
|
13
|
-
}
|
|
30
|
+
b += a * 51 & 52 /*if "a" is not 9 or 14 or 19 or 24*/
|
|
31
|
+
? (a ^ 15 /*if "a" is not 15*/
|
|
32
|
+
? 8 ^ Math.random() * (a ^ 20 ? 16 : 4 /*unless "a" is 20, in which case a random number from 8 to 11*/)
|
|
33
|
+
: 4 /*otherwise 4*/
|
|
34
|
+
).toString(16)
|
|
35
|
+
: '-' /*in other cases (if "a" is 9,14,19,24) insert "-"*/
|
|
36
|
+
) { /* empty */ }
|
|
14
37
|
return b
|
|
15
38
|
}
|
|
16
|
-
export {
|
|
17
|
-
uuid_ as _uuid,
|
|
18
|
-
uuid_ as uuid,
|
|
19
|
-
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { test } from 'uvu'
|
|
2
|
+
import { equal } from 'uvu/assert'
|
|
3
|
+
import { polyfill_uuid_, short_uuid_, uuid_ } from './index.js'
|
|
4
|
+
test('uuid_', ()=>{
|
|
5
|
+
equal(
|
|
6
|
+
uuid_().split('-').map(seg=>seg.length),
|
|
7
|
+
[8, 4, 4, 4, 12])
|
|
8
|
+
})
|
|
9
|
+
test('short_uuid_', ()=>{
|
|
10
|
+
equal(short_uuid_().length, 22)
|
|
11
|
+
const uuid = '8a88c23d-4a69-46ac-b975-1ab4590a470c'
|
|
12
|
+
const expected_short_uuid = 'iojCPUppRqy5dRq0WQpHDA'
|
|
13
|
+
equal(short_uuid_(uuid), expected_short_uuid)
|
|
14
|
+
// verify the isomorphic solution is the same as nodejs
|
|
15
|
+
equal(
|
|
16
|
+
Buffer
|
|
17
|
+
.from(uuid.replaceAll('-', ''), 'hex')
|
|
18
|
+
.toString('base64')
|
|
19
|
+
.replace(/==$/, ''),
|
|
20
|
+
expected_short_uuid)
|
|
21
|
+
})
|
|
22
|
+
test('polyfill_uuid_', ()=>{
|
|
23
|
+
equal(
|
|
24
|
+
polyfill_uuid_().split('-').map(seg=>seg.length),
|
|
25
|
+
[8, 4, 4, 4, 12])
|
|
26
|
+
})
|
|
27
|
+
test.run()
|
package/crypto/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from '../all/buffer__hex/index.js'
|
|
|
2
2
|
export * from '../all/crypto/index.js'
|
|
3
3
|
export * from '../all/crypto__sign/index.js'
|
|
4
4
|
export * from '../all/digest__algorithm/index.js'
|
|
5
|
+
export * from '../all/hex__base64/index.js'
|
|
5
6
|
export * from '../all/hex__digest/index.js'
|
|
6
7
|
export * from '../all/hmac/index.js'
|
|
7
8
|
export * from '../all/hmac_key/index.js'
|
|
9
|
+
export * from '../all/uuid/index.js'
|
package/crypto/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export * from '../all/buffer__hex/index.js'
|
|
|
2
2
|
export * from '../all/crypto/index.js'
|
|
3
3
|
export * from '../all/crypto__sign/index.js'
|
|
4
4
|
export * from '../all/digest__algorithm/index.js'
|
|
5
|
+
export * from '../all/hex__base64/index.js'
|
|
5
6
|
export * from '../all/hex__digest/index.js'
|
|
6
7
|
export * from '../all/hmac/index.js'
|
|
7
8
|
export * from '../all/hmac_key/index.js'
|
|
9
|
+
export * from '../all/uuid/index.js'
|
package/fs/index.d.ts
CHANGED
package/fs/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,226 +1,241 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
2
|
+
"name": "ctx-core",
|
|
3
|
+
"version": "5.6.1",
|
|
4
|
+
"description": "ctx-core core library",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ctx-core",
|
|
7
|
+
"array",
|
|
8
|
+
"combinators",
|
|
9
|
+
"function",
|
|
10
|
+
"object",
|
|
11
|
+
"set"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/ctx-core/ctx-core#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ctx-core/ctx-core/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/ctx-core/ctx-core.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"author": "Brian Takita",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"files": [
|
|
25
|
+
"*.d.ts",
|
|
26
|
+
"*.js",
|
|
27
|
+
"*.json",
|
|
28
|
+
"all",
|
|
29
|
+
"array",
|
|
30
|
+
"atob",
|
|
31
|
+
"base16",
|
|
32
|
+
"be",
|
|
33
|
+
"btoa",
|
|
34
|
+
"buffer",
|
|
35
|
+
"chain",
|
|
36
|
+
"class",
|
|
37
|
+
"cli-args",
|
|
38
|
+
"color",
|
|
39
|
+
"combinators",
|
|
40
|
+
"crypto",
|
|
41
|
+
"currency",
|
|
42
|
+
"data",
|
|
43
|
+
"date",
|
|
44
|
+
"debounce",
|
|
45
|
+
"deep_equal",
|
|
46
|
+
"env",
|
|
47
|
+
"error",
|
|
48
|
+
"fetch",
|
|
49
|
+
"fibonacci",
|
|
50
|
+
"fs",
|
|
51
|
+
"function",
|
|
52
|
+
"functional",
|
|
53
|
+
"html",
|
|
54
|
+
"http",
|
|
55
|
+
"math",
|
|
56
|
+
"matrix",
|
|
57
|
+
"number",
|
|
58
|
+
"object",
|
|
59
|
+
"queue",
|
|
60
|
+
"random",
|
|
61
|
+
"regex",
|
|
62
|
+
"rmemo",
|
|
63
|
+
"set",
|
|
64
|
+
"sleep",
|
|
65
|
+
"string",
|
|
66
|
+
"tempfile",
|
|
67
|
+
"test",
|
|
68
|
+
"time",
|
|
69
|
+
"types",
|
|
70
|
+
"uri",
|
|
71
|
+
"uuid",
|
|
72
|
+
"package.json"
|
|
73
|
+
],
|
|
74
|
+
"types": "./src/index.d.ts",
|
|
75
|
+
"exports": {
|
|
76
|
+
".": "./index.js",
|
|
77
|
+
"./all": "./all/index.js",
|
|
78
|
+
"./array": "./array/index.js",
|
|
79
|
+
"./atob": "./atob/index.js",
|
|
80
|
+
"./base16": "./base16/index.js",
|
|
81
|
+
"./be": "./be/index.js",
|
|
82
|
+
"./btoa": "./btoa/index.js",
|
|
83
|
+
"./buffer": "./buffer/index.js",
|
|
84
|
+
"./chain": "./chain/index.js",
|
|
85
|
+
"./class": "./class/index.js",
|
|
86
|
+
"./cli-args": "./cli-args/index.js",
|
|
87
|
+
"./color": "./color/index.js",
|
|
88
|
+
"./combinators": "./combinators/index.js",
|
|
89
|
+
"./crypto": "./crypto/index.js",
|
|
90
|
+
"./currency": "./currency/index.js",
|
|
91
|
+
"./data": "./data/index.js",
|
|
92
|
+
"./date": "./date/index.js",
|
|
93
|
+
"./debounce": "./debounce/index.js",
|
|
94
|
+
"./deep_equal": "./deep_equal/index.js",
|
|
95
|
+
"./env": "./env/index.js",
|
|
96
|
+
"./error": "./error/index.js",
|
|
97
|
+
"./fetch": "./fetch/index.js",
|
|
98
|
+
"./fibonacci": "./fibonacci/index.js",
|
|
99
|
+
"./fs": "./fs/index.js",
|
|
100
|
+
"./function": "./function/index.js",
|
|
101
|
+
"./functional": "./functional/index.js",
|
|
102
|
+
"./html": "./html/index.js",
|
|
103
|
+
"./http": "./http/index.js",
|
|
104
|
+
"./math": "./math/index.js",
|
|
105
|
+
"./matrix": "./matrix/index.js",
|
|
106
|
+
"./number": "./number/index.js",
|
|
107
|
+
"./object": "./object/index.js",
|
|
108
|
+
"./queue": "./queue/index.js",
|
|
109
|
+
"./random": "./random/index.js",
|
|
110
|
+
"./regex": "./regex/index.js",
|
|
111
|
+
"./rmemo": "./rmemo/index.js",
|
|
112
|
+
"./set": "./set/index.js",
|
|
113
|
+
"./sleep": "./sleep/index.js",
|
|
114
|
+
"./string": "./string/index.js",
|
|
115
|
+
"./tempfile": "./tempfile/index.js",
|
|
116
|
+
"./test": "./test/index.js",
|
|
117
|
+
"./time": "./time/index.js",
|
|
118
|
+
"./types": "./types/index.js",
|
|
119
|
+
"./uri": "./uri/index.js",
|
|
120
|
+
"./uuid": "./uuid/index.js",
|
|
121
|
+
"./package.json": "./package.json"
|
|
122
|
+
},
|
|
123
|
+
"scripts": {
|
|
124
|
+
"build": ":",
|
|
125
|
+
"clean": ":",
|
|
126
|
+
"exec": "$@",
|
|
127
|
+
"prepublishOnly": "pnpm clean && pnpm build && pnpm test",
|
|
128
|
+
"test": "pnpm run /^test:/",
|
|
129
|
+
"test:size": "size-limit",
|
|
130
|
+
"test:type": "check-dts",
|
|
131
|
+
"test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
|
|
132
|
+
"disable:test:coverage": "c8 pnpm test:unit"
|
|
133
|
+
},
|
|
134
|
+
"devDependencies": {
|
|
135
|
+
"@arethetypeswrong/cli": "^0.13.5",
|
|
136
|
+
"@ctx-core/preprocess": "^0.1.0",
|
|
137
|
+
"@size-limit/preset-small-lib": "^11.0.1",
|
|
138
|
+
"@types/node": "^20.10.6",
|
|
139
|
+
"@types/sinon": "^17.0.2",
|
|
140
|
+
"c8": "^8.0.1",
|
|
141
|
+
"check-dts": "^0.7.2",
|
|
142
|
+
"esbuild": "^0.19.11",
|
|
143
|
+
"esmock": "^2.6.0",
|
|
144
|
+
"sinon": "^17.0.1",
|
|
145
|
+
"size-limit": "^11.0.1",
|
|
146
|
+
"tsx": "^4.7.0",
|
|
147
|
+
"typescript": "next",
|
|
148
|
+
"uvu": "^0.5.6"
|
|
149
|
+
},
|
|
150
|
+
"publishConfig": {
|
|
151
|
+
"access": "public",
|
|
152
|
+
"cache": "~/.npm"
|
|
153
|
+
},
|
|
154
|
+
"sideEffects": false,
|
|
155
|
+
"size-limit": [
|
|
156
|
+
{
|
|
157
|
+
"name": "ctx_",
|
|
158
|
+
"import": {
|
|
159
|
+
"./be": "{ ctx_ }"
|
|
160
|
+
},
|
|
161
|
+
"limit": "33 B"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "ns_ctx_",
|
|
165
|
+
"import": {
|
|
166
|
+
"./be": "{ ns_ctx_ }"
|
|
167
|
+
},
|
|
168
|
+
"limit": "85 B"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "be_",
|
|
172
|
+
"import": {
|
|
173
|
+
"./be": "{ be_ }"
|
|
174
|
+
},
|
|
175
|
+
"limit": "99 B"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "be_ ctx_",
|
|
179
|
+
"import": {
|
|
180
|
+
"./be": "{ be_, ctx_ }"
|
|
181
|
+
},
|
|
182
|
+
"limit": "131 B"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "be_ ns_ctx_",
|
|
186
|
+
"import": {
|
|
187
|
+
"./be": "{ be_, ctx_, ns_ctx_ }"
|
|
188
|
+
},
|
|
189
|
+
"limit": "190 B"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "be_ ctx_ ns_ctx_",
|
|
193
|
+
"import": {
|
|
194
|
+
"./be": "{ be_, ctx_, ns_ctx_ }"
|
|
195
|
+
},
|
|
196
|
+
"limit": "190 B"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "memo_",
|
|
200
|
+
"import": {
|
|
201
|
+
"./rmemo": "{ memo_ }"
|
|
202
|
+
},
|
|
203
|
+
"limit": "336 B"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "memo_ sig_",
|
|
207
|
+
"import": {
|
|
208
|
+
"./rmemo": "{ sig_, memo_ }"
|
|
209
|
+
},
|
|
210
|
+
"limit": "352 B"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "memo_ sig_ be_ ctx_",
|
|
214
|
+
"import": {
|
|
215
|
+
"./rmemo": "{ sig_, memo_, be_, ctx_ }"
|
|
216
|
+
},
|
|
217
|
+
"limit": "458 B"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"name": "memo_ sig_ be_ ctx_ be_memo_pair_ be_sig_triple_",
|
|
221
|
+
"import": {
|
|
222
|
+
"./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
|
|
223
|
+
},
|
|
224
|
+
"limit": "552 B"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "uuid",
|
|
228
|
+
"import": {
|
|
229
|
+
"./uuid": "{ uuid_ }"
|
|
230
|
+
},
|
|
231
|
+
"limit": "39 B"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"name": "short uuid",
|
|
235
|
+
"import": {
|
|
236
|
+
"./uuid": "{ short_uuid_ }"
|
|
237
|
+
},
|
|
238
|
+
"limit": "116 B"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
226
241
|
}
|
package/rmemo/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rmemo__subscribe } from '../rmemo/index.js'
|
|
2
2
|
export { rmemo__subscribe as subscribe }
|
|
3
|
+
export * from '../all/be/index.js'
|
|
3
4
|
export * from '../all/be_/index.js'
|
|
4
5
|
export * from '../all/be_lock_memosig_triple/index.js'
|
|
5
6
|
export * from '../all/be_memo_pair/index.js'
|
package/rmemo/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rmemo__subscribe } from '../rmemo/index.js'
|
|
2
2
|
export { rmemo__subscribe as subscribe }
|
|
3
|
+
export * from '../all/be/index.js'
|
|
3
4
|
export * from '../all/be_/index.js'
|
|
4
5
|
export * from '../all/be_lock_memosig_triple/index.js'
|
|
5
6
|
export * from '../all/be_memo_pair/index.js'
|
package/uuid/index.d.ts
CHANGED
package/uuid/index.js
CHANGED