ctx-core 5.4.1 → 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 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
- >(ctx:ctx_T, val_:be__val__new_T<Out, ns_T, ctx_T>):Out
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
- globalThis['window']
9
- ? window.btoa(str)
10
- : new Buffer(str).toString('base64')
9
+ process_release_name
10
+ ? new Buffer(str).toString('base64')
11
+ : window.btoa(str)
11
12
  )
12
13
  }
13
14
  /**
@@ -8,11 +8,10 @@ import { waitfor } from '../waitfor/index.js'
8
8
  export async function file_exists_(path) {
9
9
  return (
10
10
  (process_release_name ?? false)
11
- && import('node:fs/promises').then(({ access, constants })=>{
12
- return access(path, constants.F_OK)
11
+ && import('node:fs/promises').then(({ access, constants })=>
12
+ access(path, constants.F_OK)
13
13
  .then(()=>true)
14
- .catch(()=>false)
15
- }))
14
+ .catch(()=>false)))
16
15
  }
17
16
  export {
18
17
  file_exists_ as path__exists_
@@ -0,0 +1,2 @@
1
+ export declare function hex__base64_(hex:string):string
2
+
@@ -0,0 +1,6 @@
1
+ export function hex__base64_(hex) {
2
+ let str = ''
3
+ for (let i = 0; i < hex.length; i += 2)
4
+ str += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16))
5
+ return btoa(str)
6
+ }
@@ -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,4 @@
1
+ export declare function is_entry_file_(
2
+ url:string,
3
+ entry_file?:string
4
+ ):Promise<boolean>
@@ -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
@@ -3,8 +3,8 @@
3
3
  * @returns {number}
4
4
  * @private
5
5
  */
6
- export function ms_(date = new Date()) {
7
- return date.getTime()
6
+ export function ms_(date) {
7
+ return (date ?? new Date).getTime()
8
8
  }
9
9
  export {
10
10
  ms_ as milliseconds_,
@@ -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:any[] = [null, null, null]
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:any[][] = []
26
+ const close__promise__arg_aa:unknown[][] = []
27
27
  queue.close()
28
- .then((...arg_a)=>
29
- close__promise__arg_aa.push(arg_a))
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:any[] = [null, null, null, null]
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:any[][] = []
58
+ const close__promise__arg_aa:unknown[][] = []
59
59
  queue.close()
60
- .then((...arg_a)=>
61
- close__promise__arg_aa.push(arg_a))
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:any[] = [null, null, null]
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:any[] = [null, null, null, null]
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:any[] = [null, null, null, null]
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:any[][] = []
110
+ const close__promise__arg_aa:unknown[][] = []
111
111
  queue.close()
112
- .then((...arg_a)=>
113
- close__promise__arg_aa.push(arg_a))
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:any[][] = []
138
- const throttle__then = (...arg_a:any[])=>{
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
- .then(throttle__then)
142
+ .then(throttle__then)
143
143
  await tick()
144
144
  equal(pending__wait__arg_aa, [[5]])
145
145
  queue.throttle(3)
146
- .then(throttle__then)
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:any[][] = []
163
- const throttle__then = (...arg_a:any[])=>{
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=>
@@ -17,6 +17,7 @@ export declare function lock_memosig_<val_T>(
17
17
  ):sig_T<val_T>
18
18
  export declare function on(rmemo:rmemo_T<unknown>):void
19
19
  export declare function off(rmemo:rmemo_T<unknown>):void
20
+ export declare function rmemo__subscribe(rmemo:rmemo_T<unknown>, listener:()=>unknown):()=>void
20
21
  export type rmemo_T<val_T> = memo_T<val_T>|sig_T<val_T>|lock_memosig_T<val_T>
21
22
  export type memo_T<val_T> = (()=>val_T)&{
22
23
  readonly _:val_T
@@ -4,8 +4,8 @@ let cur_memo
4
4
  /** @type {Set<()=>unknown>} */
5
5
  let queue = new Set
6
6
  /**
7
- * @param {rmemo_def_T}memo_def
8
- * @param {rmemo_subscriber_T<unknown>[]}subscriber_a
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 {rmemo_def_T}memo_def
84
- * @param {rmemo_subscriber_T<unknown>[]}subscriber_a
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 {rmemo_subscriber_T[]}subscriber_a
105
+ * @param {memo_subscriber_T[]}subscriber_a
106
106
  * @returns {sig_T}
107
107
  * @private
108
108
  */
@@ -135,3 +135,21 @@ export function off(rmemo) {
135
135
  }
136
136
  }
137
137
  }
138
+ /**
139
+ * Bind reactive listener onto the given memo to prevent GC.
140
+ * The listener can autosubscribe to any rmemo.
141
+ * Returns an "off" function which deactivates the reactive listener & removes the GC binding from the given memo.
142
+ * @param {rmemo_T}memo
143
+ * @param {()=>unknown}listener
144
+ * @returns {()=>void}
145
+ */
146
+ export function rmemo__subscribe(memo, listener) {
147
+ let listener_memo = memo_(()=>listener())
148
+ listener_memo()
149
+ memo.b ??= []
150
+ memo.b.push(listener_memo)
151
+ return ()=>{
152
+ off(listener_memo)
153
+ memo.b.splice(memo.b.indexOf(listener_memo), 1)
154
+ }
155
+ }
@@ -4,7 +4,7 @@ import { deepStrictEqual } from 'node:assert'
4
4
  import { test } from 'uvu'
5
5
  import { equal } from 'uvu/assert'
6
6
  import { sleep } from '../sleep/index.js'
7
- import { lock_memosig_, memo_, type memo_T, memosig_, off, on, sig_ } from './index.js'
7
+ import { lock_memosig_, memo_, type memo_T, memosig_, off, on, rmemo__subscribe, sig_ } from './index.js'
8
8
  test('memo_|static value', ()=>{
9
9
  let count = 0
10
10
  const memo = memo_(()=>{
@@ -454,4 +454,22 @@ test('.on + .off', ()=>{
454
454
  equal(memo$(), 14)
455
455
  equal(count, 5)
456
456
  })
457
+ test('rmemo__subscribe', ()=>{
458
+ const base$ = sig_(1)
459
+ let count = 0
460
+ const subscriber_base_a:number[] = []
461
+ const off = rmemo__subscribe(base$, ()=>{
462
+ count++
463
+ subscriber_base_a.push(base$())
464
+ })
465
+ equal(subscriber_base_a, [1])
466
+ equal(count, 1)
467
+ base$._ = 2
468
+ equal(subscriber_base_a, [1, 2])
469
+ equal(count, 2)
470
+ off()
471
+ base$._ = 3
472
+ equal(subscriber_base_a, [1, 2])
473
+ equal(count, 2)
474
+ })
457
475
  test.run()
@@ -2,4 +2,8 @@ export declare function run<O, A extends unknown[] = unknown[]>(
2
2
  fn:(...arg_a:A)=>O,
3
3
  ...arg_a:A
4
4
  ):O
5
+ export declare function run<O, A extends unknown[] = unknown[]>(
6
+ arg_a:A,
7
+ fn:(...arg_a:A)=>O
8
+ ):O
5
9
  export { run as _ }
package/all/run/index.js CHANGED
@@ -1,10 +1,13 @@
1
- import { nullish__none_ } from '../nullish__none/index.js'
2
1
  /**
3
- * @param fn{(...arg_a:unknown)=>unknown}
2
+ * @param {(...arg_a:unknown)=>unknown}fn
4
3
  * @param {unknown}arg_a
5
4
  * @returns {unknown}
6
5
  */
7
- export function run(fn, ...arg_a) {
8
- return nullish__none_([fn], ()=>fn(...arg_a))
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((res, rej)=>{
8
+ return new Promise((resolve, reject)=>{
10
9
  if (!timeout) {
11
10
  queueMicrotask(()=>
12
- res(run(fn)))
11
+ resolve(fn?.()))
13
12
  } else {
14
13
  setTimeout(()=>{
15
14
  try {
16
- res(run(fn))
15
+ resolve(fn?.())
17
16
  } catch (e) {
18
- rej(e)
17
+ reject(e)
19
18
  }
20
19
  }, timeout)
21
20
  }
@@ -3,3 +3,5 @@ export {
3
3
  uuid_ as _uuid,
4
4
  uuid_ as uuid,
5
5
  }
6
+ export declare function short_uuid_(uuid?:string):string
7
+ export declare function polyfill_uuid_(uuid?:string):string
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 // if "a" is not 9 or 14 or 19 or 24
8
- ? (a ^ 15 // if "a" is not 15
9
- ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4 // unless "a" is 20, in which case a random number from 8 to 11
10
- ) : 4 // otherwise 4
11
- ).toString(16) : '-' // in other cases (if "a" is 9,14,19,24) insert "-"
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
@@ -1 +1,2 @@
1
1
  export * from '../all/file_exists/index.js'
2
+ export * from '../all/is_entry_file/index.js'
package/fs/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export * from '../all/file_exists/index.js'
2
+ export * from '../all/is_entry_file/index.js'
package/package.json CHANGED
@@ -1,226 +1,241 @@
1
1
  {
2
- "name": "ctx-core",
3
- "version": "5.4.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
- "devDependencies": {
124
- "@arethetypeswrong/cli": "^0.13.5",
125
- "@ctx-core/preprocess": "^0.1.0",
126
- "@size-limit/preset-small-lib": "^11.0.1",
127
- "@types/node": "^20.10.5",
128
- "@types/sinon": "^17.0.2",
129
- "c8": "^8.0.1",
130
- "check-dts": "^0.7.2",
131
- "esbuild": "^0.19.10",
132
- "esmock": "^2.6.0",
133
- "sinon": "^17.0.1",
134
- "size-limit": "^11.0.1",
135
- "tsx": "^4.7.0",
136
- "typescript": "next",
137
- "uvu": "^0.5.6"
138
- },
139
- "publishConfig": {
140
- "access": "public",
141
- "cache": "~/.npm"
142
- },
143
- "sideEffects": false,
144
- "size-limit": [
145
- {
146
- "name": "ctx_",
147
- "import": {
148
- "./be": "{ ctx_ }"
149
- },
150
- "limit": "33 B"
151
- },
152
- {
153
- "name": "ns_ctx_",
154
- "import": {
155
- "./be": "{ ns_ctx_ }"
156
- },
157
- "limit": "85 B"
158
- },
159
- {
160
- "name": "be_",
161
- "import": {
162
- "./be": "{ be_ }"
163
- },
164
- "limit": "99 B"
165
- },
166
- {
167
- "name": "be_ ctx_",
168
- "import": {
169
- "./be": "{ be_, ctx_ }"
170
- },
171
- "limit": "131 B"
172
- },
173
- {
174
- "name": "be_ ns_ctx_",
175
- "import": {
176
- "./be": "{ be_, ctx_, ns_ctx_ }"
177
- },
178
- "limit": "190 B"
179
- },
180
- {
181
- "name": "be_ ctx_ ns_ctx_",
182
- "import": {
183
- "./be": "{ be_, ctx_, ns_ctx_ }"
184
- },
185
- "limit": "190 B"
186
- },
187
- {
188
- "name": "memo_",
189
- "import": {
190
- "./rmemo": "{ memo_ }"
191
- },
192
- "limit": "336 B"
193
- },
194
- {
195
- "name": "memo_ sig_",
196
- "import": {
197
- "./rmemo": "{ sig_, memo_ }"
198
- },
199
- "limit": "351 B"
200
- },
201
- {
202
- "name": "memo_ sig_ be_ ctx_",
203
- "import": {
204
- "./rmemo": "{ sig_, memo_, be_, ctx_ }"
205
- },
206
- "limit": "456 B"
207
- },
208
- {
209
- "name": "memo_ sig_ be_ ctx_ be_memo_pair_ be_sig_triple_",
210
- "import": {
211
- "./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
212
- },
213
- "limit": "549 B"
214
- }
215
- ],
216
- "scripts": {
217
- "build": ":",
218
- "clean": ":",
219
- "exec": "$@",
220
- "test": "pnpm run /^test:/",
221
- "test:size": "size-limit",
222
- "test:type": "check-dts",
223
- "test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
224
- "disable:test:coverage": "c8 pnpm test-unit"
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,3 +1,6 @@
1
+ import { rmemo__subscribe } from '../rmemo/index.js'
2
+ export { rmemo__subscribe as subscribe }
3
+ export * from '../all/be/index.js'
1
4
  export * from '../all/be_/index.js'
2
5
  export * from '../all/be_lock_memosig_triple/index.js'
3
6
  export * from '../all/be_memo_pair/index.js'
package/rmemo/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { rmemo__subscribe } from '../rmemo/index.js'
2
+ export { rmemo__subscribe as subscribe }
3
+ export * from '../all/be/index.js'
1
4
  export * from '../all/be_/index.js'
2
5
  export * from '../all/be_lock_memosig_triple/index.js'
3
6
  export * from '../all/be_memo_pair/index.js'
package/tsconfig.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "moduleResolution": "nodenext",
6
6
  "target": "ESNext",
7
7
  "strict": true,
8
- "skipLibCheck": true,
9
8
  "lib": ["ESNext"],
10
9
  "types": [
11
10
  "node"
package/uuid/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from '../all/hex__base64/index.js'
1
2
  export * from '../all/uuid/index.js'
package/uuid/index.js CHANGED
@@ -1 +1,2 @@
1
+ export * from '../all/hex__base64/index.js'
1
2
  export * from '../all/uuid/index.js'