functionalscript 0.1.608 → 0.2.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.
Files changed (222) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/Cargo.lock +4 -0
  3. package/Cargo.toml +4 -2
  4. package/README.md +1 -1
  5. package/com/cpp/module.f.d.mts +4 -8
  6. package/com/cpp/module.f.mjs +20 -25
  7. package/com/cpp/testlib.f.mjs +3 -4
  8. package/com/cs/module.f.d.mts +4 -8
  9. package/com/cs/module.f.mjs +18 -23
  10. package/com/cs/testlib.f.mjs +3 -5
  11. package/com/rust/module.f.d.mts +3 -7
  12. package/com/rust/module.f.mjs +25 -30
  13. package/com/rust/nanocom/src/cobject.rs +1 -1
  14. package/com/rust/testlib.f.mjs +3 -5
  15. package/com/test/build.f.d.mts +2 -2
  16. package/com/test/build.f.mjs +2 -2
  17. package/com/test/build.mjs +4 -4
  18. package/com/test/rust/src/lib.rs +4 -4
  19. package/com/types/module.f.d.mts +5 -10
  20. package/com/types/module.f.mjs +5 -12
  21. package/commonjs/build/module.f.d.mts +13 -17
  22. package/commonjs/build/module.f.mjs +23 -28
  23. package/commonjs/build/test.f.mjs +4 -4
  24. package/commonjs/module/function/module.f.d.mts +0 -2
  25. package/commonjs/module/function/module.f.mjs +0 -2
  26. package/commonjs/module/module.f.d.mts +16 -21
  27. package/commonjs/module/module.f.mjs +2 -9
  28. package/commonjs/module.d.mts +1 -5
  29. package/commonjs/module.f.d.mts +0 -2
  30. package/commonjs/module.f.mjs +0 -2
  31. package/commonjs/module.mjs +2 -7
  32. package/commonjs/package/dependencies/module.f.d.mts +3 -7
  33. package/commonjs/package/dependencies/module.f.mjs +5 -10
  34. package/commonjs/package/dependencies/test.f.mjs +1 -1
  35. package/commonjs/package/module.f.d.mts +12 -18
  36. package/commonjs/package/module.f.mjs +6 -13
  37. package/commonjs/package/test.f.mjs +1 -1
  38. package/commonjs/path/module.f.d.mts +25 -32
  39. package/commonjs/path/module.f.mjs +12 -23
  40. package/commonjs/path/test.f.mjs +11 -11
  41. package/commonjs/test.mjs +1 -1
  42. package/dev/module.f.d.mts +1 -4
  43. package/dev/module.f.mjs +1 -4
  44. package/dev/module.mjs +1 -1
  45. package/dev/test/module.f.d.mts +2 -3
  46. package/dev/test/module.f.mjs +5 -7
  47. package/djs/module.f.d.mts +13 -18
  48. package/djs/module.f.mjs +12 -19
  49. package/djs/parser/module.f.d.mts +53 -37
  50. package/djs/parser/module.f.mjs +278 -131
  51. package/djs/parser/test.f.d.mts +4 -0
  52. package/djs/parser/test.f.mjs +186 -70
  53. package/djs/test.f.mjs +4 -4
  54. package/djs/tokenizer/module.f.d.mts +6 -10
  55. package/djs/tokenizer/module.f.mjs +19 -22
  56. package/djs/tokenizer/test.f.mjs +7 -7
  57. package/doc/LANGUAGE.md +17 -16
  58. package/doc/README.md +14 -50
  59. package/fsc/README.md +0 -3
  60. package/fsc/module.f.d.mts +4 -9
  61. package/fsc/module.f.mjs +17 -24
  62. package/fsc/test.f.mjs +3 -3
  63. package/fsm/README.md +1 -1
  64. package/fsm/module.f.d.mts +13 -20
  65. package/fsm/module.f.mjs +27 -38
  66. package/fsm/test.f.mjs +8 -8
  67. package/html/README.md +24 -0
  68. package/html/module.f.d.mts +7 -12
  69. package/html/module.f.mjs +14 -23
  70. package/html/test.f.mjs +4 -4
  71. package/issues/01-test-debug.md +3 -0
  72. package/issues/{publish.md → 05-publish.md} +8 -8
  73. package/issues/17-djs-extension.md +6 -0
  74. package/issues/README.md +20 -13
  75. package/issues/lang/1000-json.md +38 -0
  76. package/issues/lang/2110-default-export.md +2 -2
  77. package/issues/lang/2310-undefined.md +1 -1
  78. package/issues/lang/2330-property-accessor.md +225 -0
  79. package/issues/lang/2360-built-in.md +54 -47
  80. package/issues/lang/3240-export.md +44 -0
  81. package/issues/lang/README.md +64 -22
  82. package/issues/test.f.d.mts +16 -0
  83. package/issues/test.f.mjs +57 -0
  84. package/js/tokenizer/module.f.d.mts +18 -17
  85. package/js/tokenizer/module.f.mjs +80 -61
  86. package/js/tokenizer/test.f.mjs +15 -12
  87. package/json/module.f.d.mts +18 -26
  88. package/json/module.f.mjs +18 -31
  89. package/json/parser/module.f.d.mts +9 -13
  90. package/json/parser/module.f.mjs +9 -14
  91. package/json/parser/test.f.mjs +7 -7
  92. package/json/serializer/module.f.d.mts +11 -20
  93. package/json/serializer/module.f.mjs +14 -29
  94. package/json/serializer/test.f.mjs +2 -2
  95. package/json/test.f.mjs +3 -3
  96. package/json/tokenizer/module.f.d.mts +6 -10
  97. package/json/tokenizer/module.f.mjs +16 -20
  98. package/json/tokenizer/test.f.mjs +6 -6
  99. package/jsr.json +1 -1
  100. package/nanvm-lib/Cargo.toml +6 -0
  101. package/nanvm-lib/src/extension.rs +119 -0
  102. package/nanvm-lib/src/interface.rs +136 -0
  103. package/nanvm-lib/src/lib.rs +7 -0
  104. package/nanvm-lib/src/naive.rs +229 -0
  105. package/nanvm-lib/src/nanenum.rs +230 -0
  106. package/nanvm-lib/src/nullish.rs +7 -0
  107. package/nanvm-lib/src/sign.rs +5 -0
  108. package/nanvm-lib/src/simple.rs +32 -0
  109. package/nanvm-lib/tests/test.f.d.mts +36 -0
  110. package/nanvm-lib/tests/test.f.mjs +79 -0
  111. package/nanvm-lib/tests/test.rs +108 -0
  112. package/nodejs/version/main.mjs +1 -1
  113. package/nodejs/version/module.f.d.mts +4 -9
  114. package/nodejs/version/module.f.mjs +2 -7
  115. package/nodejs/version/test.f.mjs +3 -3
  116. package/package.json +1 -1
  117. package/prime_field/module.f.d.mts +20 -23
  118. package/prime_field/module.f.mjs +9 -12
  119. package/prime_field/test.f.mjs +1 -1
  120. package/secp/module.f.d.mts +27 -28
  121. package/secp/module.f.mjs +38 -39
  122. package/secp/test.f.mjs +4 -4
  123. package/sha2/module.f.d.mts +8 -16
  124. package/sha2/module.f.mjs +7 -20
  125. package/sha2/test.f.mjs +4 -4
  126. package/text/README.md +2 -2
  127. package/text/ascii/module.f.d.mts +69 -72
  128. package/text/ascii/module.f.mjs +5 -10
  129. package/text/ascii/test.f.mjs +3 -3
  130. package/text/module.f.d.mts +9 -14
  131. package/text/module.f.mjs +7 -14
  132. package/text/sgr/module.f.d.mts +7 -9
  133. package/text/sgr/module.f.mjs +2 -4
  134. package/text/test.f.mjs +3 -3
  135. package/text/utf16/module.f.d.mts +8 -15
  136. package/text/utf16/module.f.mjs +17 -28
  137. package/text/utf16/test.f.mjs +5 -5
  138. package/text/utf8/module.f.d.mts +4 -9
  139. package/text/utf8/module.f.mjs +9 -16
  140. package/text/utf8/test.f.mjs +4 -4
  141. package/types/array/module.f.d.mts +14 -24
  142. package/types/array/module.f.mjs +8 -25
  143. package/types/array/test.f.mjs +3 -3
  144. package/types/bigfloat/module.f.d.mts +4 -9
  145. package/types/bigfloat/module.f.mjs +3 -10
  146. package/types/bigfloat/test.f.mjs +1 -1
  147. package/types/bigint/module.f.d.mts +16 -64
  148. package/types/bigint/module.f.mjs +11 -30
  149. package/types/bigint/test.f.mjs +1 -1
  150. package/types/btree/find/module.f.d.mts +20 -26
  151. package/types/btree/find/module.f.mjs +8 -17
  152. package/types/btree/find/test.f.mjs +7 -7
  153. package/types/btree/module.f.d.mts +4 -8
  154. package/types/btree/module.f.mjs +6 -11
  155. package/types/btree/remove/module.f.d.mts +7 -12
  156. package/types/btree/remove/module.f.mjs +10 -17
  157. package/types/btree/remove/test.f.mjs +5 -5
  158. package/types/btree/set/module.f.d.mts +3 -7
  159. package/types/btree/set/module.f.mjs +4 -9
  160. package/types/btree/set/test.f.mjs +4 -4
  161. package/types/btree/test.f.mjs +9 -9
  162. package/types/btree/types/module.f.d.mts +0 -2
  163. package/types/btree/types/module.f.mjs +0 -2
  164. package/types/byte_set/module.f.d.mts +16 -29
  165. package/types/byte_set/module.f.mjs +14 -39
  166. package/types/byte_set/test.f.mjs +5 -5
  167. package/types/function/compare/module.f.d.mts +9 -15
  168. package/types/function/compare/module.f.mjs +3 -12
  169. package/types/function/compare/test.f.mjs +1 -1
  170. package/types/function/module.f.d.mts +20 -27
  171. package/types/function/module.f.mjs +4 -15
  172. package/types/function/operator/module.f.d.mts +28 -43
  173. package/types/function/operator/module.f.mjs +14 -41
  174. package/types/function/test.f.mjs +1 -1
  175. package/types/list/module.f.d.mts +56 -91
  176. package/types/list/module.f.mjs +45 -114
  177. package/types/list/test.f.mjs +10 -10
  178. package/types/map/module.f.d.mts +15 -24
  179. package/types/map/module.f.mjs +15 -30
  180. package/types/map/test.f.mjs +2 -2
  181. package/types/nibble_set/module.f.d.mts +10 -20
  182. package/types/nibble_set/module.f.mjs +7 -24
  183. package/types/nibble_set/test.f.mjs +2 -2
  184. package/types/nullable/module.f.d.mts +3 -8
  185. package/types/nullable/module.f.mjs +2 -9
  186. package/types/nullable/test.f.mjs +1 -1
  187. package/types/number/module.f.d.mts +7 -13
  188. package/types/number/module.f.mjs +8 -19
  189. package/types/number/test.f.mjs +1 -1
  190. package/types/object/module.f.d.mts +11 -18
  191. package/types/object/module.f.mjs +9 -20
  192. package/types/object/test.f.mjs +1 -1
  193. package/types/range/module.f.d.mts +3 -8
  194. package/types/range/module.f.mjs +2 -9
  195. package/types/range/test.f.mjs +1 -1
  196. package/types/range_map/module.f.d.mts +9 -15
  197. package/types/range_map/module.f.mjs +9 -18
  198. package/types/range_map/test.f.mjs +32 -32
  199. package/types/result/module.d.mts +3 -3
  200. package/types/result/module.f.d.mts +6 -12
  201. package/types/result/module.f.mjs +3 -12
  202. package/types/result/module.mjs +2 -2
  203. package/types/sorted_list/module.f.d.mts +22 -28
  204. package/types/sorted_list/module.f.mjs +10 -19
  205. package/types/sorted_list/test.f.mjs +7 -7
  206. package/types/sorted_set/module.f.d.mts +6 -12
  207. package/types/sorted_set/module.f.mjs +7 -16
  208. package/types/sorted_set/test.f.mjs +7 -7
  209. package/types/string/module.f.d.mts +8 -14
  210. package/types/string/module.f.mjs +10 -21
  211. package/types/string/test.f.mjs +2 -2
  212. package/types/string_set/module.f.d.mts +8 -16
  213. package/types/string_set/module.f.mjs +12 -27
  214. package/types/string_set/test.f.mjs +1 -1
  215. package/issues/lang/2351-property-accessor.md +0 -44
  216. package/issues/lang/2352-property-call.md +0 -43
  217. package/issues/lang/2353-property-at.md +0 -19
  218. package/issues/test-debug.md +0 -12
  219. /package/issues/{esm.md → 02-esm.md} +0 -0
  220. /package/issues/{djs.md → 03-djs.md} +0 -0
  221. /package/issues/{fs-load.md → 11-fs-load.md} +0 -0
  222. /package/issues/lang/{2330-grouping.md → 2350-grouping.md} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import option from '../nullable/module.f.mjs'
2
+ import * as option from '../nullable/module.f.mjs'
3
3
  const { map } = option
4
4
 
5
5
  /**
@@ -86,22 +86,22 @@ const uncheckTail = a => a.slice(1)
86
86
  const uncheckHead = a => a.slice(0, -1)
87
87
 
88
88
  /** @type {(index: number) => <T>(a: readonly T[]) => T|null} */
89
- const at = i => a => {
89
+ export const at = i => a => {
90
90
  const r = a[i]
91
91
  return r === void 0 ? null : r
92
92
  }
93
93
 
94
94
  /** @type {<T>(_: readonly T[]) => T|null} */
95
- const first = at(0)
95
+ export const first = at(0)
96
96
 
97
97
  /** @type {<T>(_: readonly T[]) => T|null} */
98
- const last = a => at(a.length - 1)(a)
98
+ export const last = a => at(a.length - 1)(a)
99
99
 
100
100
  /** @type {<T>(_: readonly T[]) => readonly T[] | null} */
101
- const tail = a => a.length === 0 ? null : uncheckTail(a)
101
+ export const tail = a => a.length === 0 ? null : uncheckTail(a)
102
102
 
103
103
  /** @type {<T>(_: readonly T[]) => readonly[T, readonly T[]]|null} */
104
- const splitFirst = a => {
104
+ export const splitFirst = a => {
105
105
  /** @typedef {typeof a[0]} T*/
106
106
  /** @type {(_: T) => readonly[T, readonly T[]]} */
107
107
  const split = first => [first, uncheckTail(a)]
@@ -109,28 +109,11 @@ const splitFirst = a => {
109
109
  }
110
110
 
111
111
  /** @type {<T>(_: readonly T[]) => readonly T[]|null} */
112
- const head = a => a.length === 0 ? null : uncheckHead(a)
112
+ export const head = a => a.length === 0 ? null : uncheckHead(a)
113
113
 
114
114
  /** @type {<T>(_: readonly T[]) => readonly[readonly T[], T]|null} */
115
- const splitLast = a => {
115
+ export const splitLast = a => {
116
116
  const lastA = last(a)
117
117
  if (lastA === null) { return null }
118
118
  return [uncheckHead(a), lastA]
119
119
  }
120
-
121
- export default {
122
- /** @readonly */
123
- at,
124
- /** @readnly */
125
- first,
126
- /** @readonly */
127
- last,
128
- /** @readonly */
129
- head,
130
- /** @readonly */
131
- tail,
132
- /** @readonly */
133
- splitFirst,
134
- /** @readonly */
135
- splitLast,
136
- }
@@ -1,6 +1,6 @@
1
- import _ from './module.f.mjs'
2
- import json from '../../json/module.f.mjs'
3
- import o from '../object/module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
+ import * as json from '../../json/module.f.mjs'
3
+ import * as o from '../object/module.f.mjs'
4
4
  const { sort } = o
5
5
 
6
6
  const stringify = json.stringify(sort)
@@ -1,11 +1,6 @@
1
- declare namespace _default {
2
- export { decToBin };
3
- export { multiply };
4
- }
5
- export default _default;
1
+ /** @type {(b: BigFloat) => (mul: bigint) => BigFloat} */
2
+ export const multiply: (b: BigFloat) => (mul: bigint) => BigFloat;
3
+ /** @type {(dec: BigFloat) => BigFloat} */
4
+ export const decToBin: (dec: BigFloat) => BigFloat;
6
5
  export type BigFloat = readonly [bigint, number];
7
6
  export type BigFloatWithRemainder = readonly [BigFloat, bigint];
8
- /** @type {(dec: BigFloat) => BigFloat} */
9
- declare const decToBin: (dec: BigFloat) => BigFloat;
10
- /** @type {(b: BigFloat) => (mul: bigint) => BigFloat} */
11
- declare const multiply: (b: BigFloat) => (mul: bigint) => BigFloat;
@@ -1,5 +1,5 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import bi from '../bigint/module.f.mjs'
2
+ import * as bi from '../bigint/module.f.mjs'
3
3
  const { abs, sign } = bi
4
4
 
5
5
  /** @typedef {readonly[bigint,number]} BigFloat */
@@ -47,7 +47,7 @@ const pow = base => exp => base ** BigInt(exp)
47
47
  const pow5 = pow(5n)
48
48
 
49
49
  /** @type {(b: BigFloat) => (mul: bigint) => BigFloat} */
50
- const multiply = ([m, e]) => mul => [m * mul, e]
50
+ export const multiply = ([m, e]) => mul => [m * mul, e]
51
51
 
52
52
  /** @type {(b: BigFloat) => (div: bigint) => BigFloatWithRemainder} */
53
53
  const divide = ([m, e]) => div => [[m / div, e], m % div]
@@ -68,7 +68,7 @@ const round53 = ([[m, e], r]) => {
68
68
  }
69
69
 
70
70
  /** @type {(dec: BigFloat) => BigFloat} */
71
- const decToBin = dec => {
71
+ export const decToBin = dec => {
72
72
  if (dec[0] === 0n) {
73
73
  return [0n, 0]
74
74
  }
@@ -86,10 +86,3 @@ const decToBin = dec => {
86
86
  const r53 = round53(qr)
87
87
  return multiply(r53)(s)
88
88
  }
89
-
90
- export default {
91
- /** @readonly */
92
- decToBin,
93
- /** @readonly */
94
- multiply
95
- }
@@ -1,4 +1,4 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
  const { decToBin } = _
3
3
 
4
4
  export default {
@@ -1,29 +1,13 @@
1
- declare namespace _default {
2
- export { addition };
3
- export { sum };
4
- export { abs };
5
- export { sign };
6
- export { serialize };
7
- export { scalar_mul };
8
- export { log2 };
9
- export { bitLength };
10
- }
11
- export default _default;
12
- export type Unary = Operator.Unary<bigint, bigint>;
13
- export type Additive<T> = {
14
- readonly 0: T;
15
- readonly add: Operator.Reduce<T>;
16
- };
17
1
  /** @typedef {Operator.Unary<bigint, bigint>} Unary*/
18
2
  /** @type {(a: bigint) => (b: bigint) => bigint} */
19
- declare const addition: (a: bigint) => (b: bigint) => bigint;
20
- declare const sum: (input: import("../list/module.f.mjs").List<bigint>) => bigint;
3
+ export const addition: (a: bigint) => (b: bigint) => bigint;
4
+ export const sum: (input: list.List<bigint>) => bigint;
21
5
  /** @type {(a: bigint) => bigint} */
22
- declare const abs: (a: bigint) => bigint;
23
- /** @type {(a: bigint) => Compare.Sign} */
24
- declare const sign: (a: bigint) => Compare.Sign;
6
+ export const abs: (a: bigint) => bigint;
7
+ /** @type {(a: bigint) => compare.Sign} */
8
+ export const sign: (a: bigint) => compare.Sign;
25
9
  /** @type {(a: bigint) => string} */
26
- declare const serialize: (a: bigint) => string;
10
+ export const serialize: (a: bigint) => string;
27
11
  /**
28
12
  * @template T
29
13
  * @typedef {{
@@ -32,46 +16,14 @@ declare const serialize: (a: bigint) => string;
32
16
  * }} Additive
33
17
  */
34
18
  /** @type {<T>(a: Additive<T>) => (a: T) => (n: bigint) => T} */
35
- declare const scalar_mul: <T>(a: Additive<T>) => (a: T) => (n: bigint) => T;
36
- /**
37
- * Calculates the base-2 logarithm (floor).
38
- *
39
- * This function returns the integer part of the logarithm. For example:
40
- * - `log2(1n)` returns `0n`,
41
- * - `log2(2n)` returns `1n`,
42
- * - `log2(15n)` returns `3n`.
43
- *
44
- * @param {bigint} v - The input BigInt.
45
- * @returns {bigint} The base-2 logarithm (floor) of the input BigInt, or `-1n` if the input is less than or equal to 0.
46
- *
47
- * @remarks
48
- * The function operates in two phases:
49
- * 1. **Fast Doubling Phase:** Uses exponential steps to quickly narrow down the range
50
- * of the most significant bit.
51
- * 2. **Binary Search Phase:** Refines the result by halving the step size and incrementally
52
- * determining the exact value of the logarithm.
53
- */
54
- declare function log2(v: bigint): bigint;
55
- /**
56
- * Calculates the bit length of a given BigInt.
57
- *
58
- * The bit length of a number is the number of bits required to represent its absolute value in binary,
59
- * excluding leading zeros. For example:
60
- * - `0n` has a bit length of 0 (it has no bits).
61
- * - `1n` (binary `1`) has a bit length of 1.
62
- * - `255n` (binary `11111111`) has a bit length of 8.
63
- * - `-255n` (absolute value `255`, binary `11111111`) also has a bit length of 8.
64
- *
65
- * The function handles both positive and negative numbers. For negative inputs, the bit length is calculated
66
- * based on the absolute value of the number. Zero has a bit length of 0.
67
- *
68
- * @param {bigint} v - The input BigInt.
69
- * @returns {bigint} The bit length of the input BigInt.
70
- *
71
- * @remark
72
- * The function uses the `log2` function to calculate the position of the most significant bit(MSB)
73
- * and adds `1n` to account for the MSB itself.For negative numbers, the absolute value is used.
74
- */
75
- declare function bitLength(v: bigint): bigint;
19
+ export const scalar_mul: <T>(a: Additive<T>) => (a: T) => (n: bigint) => T;
20
+ export function log2(v: bigint): bigint;
21
+ export function bitLength(v: bigint): bigint;
22
+ export type Unary = Operator.Unary<bigint, bigint>;
23
+ export type Additive<T> = {
24
+ readonly 0: T;
25
+ readonly add: Operator.Reduce<T>;
26
+ };
27
+ import * as list from '../list/module.f.mjs';
28
+ import * as compare from '../function/compare/module.f.mjs';
76
29
  import * as Operator from '../function/operator/module.f.mjs';
77
- import * as Compare from '../function/compare/module.f.mjs';
@@ -1,25 +1,25 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import compare, * as Compare from '../function/compare/module.f.mjs'
2
+ import * as compare from '../function/compare/module.f.mjs'
3
3
  import * as Operator from '../function/operator/module.f.mjs'
4
4
  const { unsafeCmp } = compare
5
- import list from '../list/module.f.mjs'
5
+ import * as list from '../list/module.f.mjs'
6
6
  const { reduce } = list
7
7
 
8
8
  /** @typedef {Operator.Unary<bigint, bigint>} Unary*/
9
9
 
10
10
  /** @type {(a: bigint) => (b: bigint) => bigint} */
11
- const addition = a => b => a + b
11
+ export const addition = a => b => a + b
12
12
 
13
- const sum = reduce(addition)(0n)
13
+ export const sum = reduce(addition)(0n)
14
14
 
15
15
  /** @type {(a: bigint) => bigint} */
16
- const abs = a => a >= 0 ? a : -a
16
+ export const abs = a => a >= 0 ? a : -a
17
17
 
18
- /** @type {(a: bigint) => Compare.Sign} */
19
- const sign = a => unsafeCmp(a)(0n)
18
+ /** @type {(a: bigint) => compare.Sign} */
19
+ export const sign = a => unsafeCmp(a)(0n)
20
20
 
21
21
  /** @type {(a: bigint) => string} */
22
- const serialize = a => `${a}n`
22
+ export const serialize = a => `${a}n`
23
23
 
24
24
  /**
25
25
  * @template T
@@ -30,7 +30,7 @@ const serialize = a => `${a}n`
30
30
  */
31
31
 
32
32
  /** @type {<T>(a: Additive<T>) => (a: T) => (n: bigint) => T} */
33
- const scalar_mul = ({ 0: _0, add }) => a => n => {
33
+ export const scalar_mul = ({ 0: _0, add }) => a => n => {
34
34
  let ai = a
35
35
  let ni = n
36
36
  let result = _0
@@ -64,7 +64,7 @@ const scalar_mul = ({ 0: _0, add }) => a => n => {
64
64
  * 2. **Binary Search Phase:** Refines the result by halving the step size and incrementally
65
65
  * determining the exact value of the logarithm.
66
66
  */
67
- const log2 = v => {
67
+ export const log2 = v => {
68
68
  if (v <= 0n) { return -1n }
69
69
  let result = 0n
70
70
  let i = 1n
@@ -111,29 +111,10 @@ const log2 = v => {
111
111
  * The function uses the `log2` function to calculate the position of the most significant bit(MSB)
112
112
  * and adds `1n` to account for the MSB itself.For negative numbers, the absolute value is used.
113
113
  */
114
- const bitLength = v => {
114
+ export const bitLength = v => {
115
115
  if (v <= 0n) {
116
116
  if (v === 0n) { return 0n }
117
117
  v = -v
118
118
  }
119
119
  return log2(v) + 1n
120
120
  }
121
-
122
- export default {
123
- /** @readonly */
124
- addition,
125
- /** @readonly */
126
- sum,
127
- /** @readonly */
128
- abs,
129
- /** @readonly */
130
- sign,
131
- /** @readonly */
132
- serialize,
133
- /** @readonly */
134
- scalar_mul,
135
- /** @readonly */
136
- log2,
137
- /** @readonly */
138
- bitLength,
139
- }
@@ -1,4 +1,4 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
  const { sum, abs, serialize, log2, bitLength } = _
3
3
 
4
4
  export default {
@@ -1,12 +1,23 @@
1
- declare namespace _default {
2
- export { find };
3
- export { value };
4
- export { isFound };
5
- }
6
- export default _default;
7
- export type FirstLeaf1<T> = readonly [cmpT.Index3, _.Leaf1<T>];
1
+ /**
2
+ * @template T
3
+ * @typedef {List.List<PathItem<T>>} Path
4
+ */
5
+ /**
6
+ * @template T
7
+ * @typedef {{
8
+ * readonly first: First<T>,
9
+ * readonly tail: Path<T>
10
+ * }} Result<T>
11
+ */
12
+ /** @type {<T>(c: cmp.Compare<T>) => (node: _.Node<T>) => Result<T>} */
13
+ export const find: <T>(c: cmp.Compare<T>) => (node: _.Node<T>) => Result<T>;
14
+ /** @type {<T>(first: First<T>) => boolean} */
15
+ export const isFound: <T>(first: First<T>) => boolean;
16
+ /** @type {<T>(first: First<T>) => T | null} */
17
+ export const value: <T>(first: First<T>) => T | null;
18
+ export type FirstLeaf1<T> = readonly [cmp.Index3, _.Leaf1<T>];
8
19
  export type FirstBranch3<T> = readonly [1, _.Branch3<T>];
9
- export type FirstLeaf2<T> = readonly [cmpT.Index5, _.Leaf2<T>];
20
+ export type FirstLeaf2<T> = readonly [cmp.Index5, _.Leaf2<T>];
10
21
  export type FirstBranch5<T> = readonly [1 | 3, _.Branch5<T>];
11
22
  export type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T>;
12
23
  export type PathItem3<T> = readonly [0 | 2, _.Branch3<T>];
@@ -20,23 +31,6 @@ export type Result<T> = {
20
31
  readonly first: First<T>;
21
32
  readonly tail: Path<T>;
22
33
  };
23
- /**
24
- * @template T
25
- * @typedef {List.List<PathItem<T>>} Path
26
- */
27
- /**
28
- * @template T
29
- * @typedef {{
30
- * readonly first: First<T>,
31
- * readonly tail: Path<T>
32
- * }} Result<T>
33
- */
34
- /** @type {<T>(c: cmpT.Compare<T>) => (node: _.Node<T>) => Result<T>} */
35
- declare const find: <T>(c: cmpT.Compare<T>) => (node: _.Node<T>) => Result<T>;
36
- /** @type {<T>(first: First<T>) => T | null} */
37
- declare const value: <T>(first: First<T>) => T | null;
38
- /** @type {<T>(first: First<T>) => boolean} */
39
- declare const isFound: <T>(first: First<T>) => boolean;
40
- import * as cmpT from '../../function/compare/module.f.mjs';
34
+ import * as cmp from '../../function/compare/module.f.mjs';
41
35
  import * as _ from '../types/module.f.mjs';
42
36
  import * as List from '../../list/module.f.mjs';
@@ -1,13 +1,13 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
2
  import * as _ from '../types/module.f.mjs'
3
3
  import * as List from '../../list/module.f.mjs'
4
- import cmp, * as cmpT from '../../function/compare/module.f.mjs'
4
+ import * as cmp from '../../function/compare/module.f.mjs'
5
5
  const { index3, index5 } = cmp
6
6
  import * as Array from '../../array/module.f.mjs'
7
7
 
8
8
  /**
9
9
  * @template T
10
- * @typedef {readonly[cmpT.Index3, _.Leaf1<T>]} FirstLeaf1
10
+ * @typedef {readonly[cmp.Index3, _.Leaf1<T>]} FirstLeaf1
11
11
  */
12
12
 
13
13
  /**
@@ -17,7 +17,7 @@ import * as Array from '../../array/module.f.mjs'
17
17
 
18
18
  /**
19
19
  * @template T
20
- * @typedef {readonly[cmpT.Index5, _.Leaf2<T>]} FirstLeaf2
20
+ * @typedef {readonly[cmp.Index5, _.Leaf2<T>]} FirstLeaf2
21
21
  */
22
22
 
23
23
  /**
@@ -62,11 +62,11 @@ const child = item =>
62
62
  * }} Result<T>
63
63
  */
64
64
 
65
- /** @type {<T>(c: cmpT.Compare<T>) => (node: _.Node<T>) => Result<T>} */
66
- const find = c => {
65
+ /** @type {<T>(c: cmp.Compare<T>) => (node: _.Node<T>) => Result<T>} */
66
+ export const find = c => {
67
67
  const i3 = index3(c)
68
68
  const i5 = index5(c)
69
- /** @typedef {typeof c extends cmpT.Compare<infer T> ? T : never} T */
69
+ /** @typedef {typeof c extends cmp.Compare<infer T> ? T : never} T */
70
70
  /** @type {(prior: Path<T>) => (node: _.Node<T>) => Result<T>} */
71
71
  const f = tail => node => {
72
72
  /** @type {(index: Array.KeyOf<typeof node>) => Result<T>} */
@@ -99,7 +99,7 @@ const find = c => {
99
99
  }
100
100
 
101
101
  /** @type {<T>(first: First<T>) => boolean} */
102
- const isFound = ([i]) => {
102
+ export const isFound = ([i]) => {
103
103
  switch (i) {
104
104
  case 1: case 3: { return true }
105
105
  default: { return false }
@@ -107,7 +107,7 @@ const isFound = ([i]) => {
107
107
  }
108
108
 
109
109
  /** @type {<T>(first: First<T>) => T | null} */
110
- const value = ([i, r]) => {
110
+ export const value = ([i, r]) => {
111
111
  switch (i) {
112
112
  case 1: {
113
113
  switch (r.length) {
@@ -123,12 +123,3 @@ const value = ([i, r]) => {
123
123
  }
124
124
  }
125
125
  }
126
-
127
- export default {
128
- /** @readonly */
129
- find,
130
- /** @readonly */
131
- value,
132
- /** @readonly */
133
- isFound,
134
- }
@@ -1,19 +1,19 @@
1
- import _, * as T from './module.f.mjs'
2
- import list from '../../list/module.f.mjs'
3
- import json, * as Json from '../../../json/module.f.mjs'
4
- import o from '../../object/module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
+ import * as list from '../../list/module.f.mjs'
3
+ import * as json from '../../../json/module.f.mjs'
4
+ import * as o from '../../object/module.f.mjs'
5
5
  const { sort } = o
6
6
  import * as btree from '../types/module.f.mjs'
7
- import string from '../../string/module.f.mjs'
7
+ import * as string from '../../string/module.f.mjs'
8
8
  const { cmp } = string
9
- import s from '../set/module.f.mjs'
9
+ import * as s from '../set/module.f.mjs'
10
10
 
11
11
  const jsonStr = json.stringify(sort)
12
12
 
13
13
  /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
14
14
  const set = node => value => s.set(cmp(value))(() => value)(node)
15
15
 
16
- /** @type {(r: T.Result<Json.Unknown>) => string} */
16
+ /** @type {(r: _.Result<json.Unknown>) => string} */
17
17
  const str = r => jsonStr(list.toArray(list.map(x => x[0])(r)))
18
18
 
19
19
  /** @type {(i: string) => (m: btree.Node<string>) => string} */
@@ -1,9 +1,5 @@
1
- declare namespace _default {
2
- export let empty: null;
3
- export { values };
4
- }
5
- export default _default;
6
- /** @type {<T>(tree: _.Tree<T>) => List.List<T>} */
7
- declare const values: <T>(tree: _.Tree<T>) => List.List<T>;
1
+ export const empty: null;
2
+ /** @type {<T>(tree: _.Tree<T>) => list.List<T>} */
3
+ export const values: <T>(tree: _.Tree<T>) => list.List<T>;
8
4
  import * as _ from './types/module.f.mjs';
9
- import * as List from '../list/module.f.mjs';
5
+ import * as list from '../list/module.f.mjs';
@@ -1,12 +1,12 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
2
 
3
- import list, * as List from '../list/module.f.mjs'
3
+ import * as list from '../list/module.f.mjs'
4
4
  const { flat } = list
5
- import n from '../nullable/module.f.mjs'
5
+ import * as n from '../nullable/module.f.mjs'
6
6
  const { map } = n
7
7
  import * as _ from './types/module.f.mjs'
8
8
 
9
- /** @type {<T>(node: _.Node<T>) => List.Thunk<T>} */
9
+ /** @type {<T>(node: _.Node<T>) => list.Thunk<T>} */
10
10
  const nodeValues = node => () => {
11
11
  switch (node.length) {
12
12
  case 1: case 2: { return node }
@@ -29,12 +29,7 @@ const nodeValues = node => () => {
29
29
  }
30
30
  }
31
31
 
32
- /** @type {<T>(tree: _.Tree<T>) => List.List<T>} */
33
- const values = map(nodeValues)
32
+ export const empty = null
34
33
 
35
- export default {
36
- /** @readonly */
37
- empty: null,
38
- /** @readonly */
39
- values,
40
- }
34
+ /** @type {<T>(tree: _.Tree<T>) => list.List<T>} */
35
+ export const values = map(nodeValues)
@@ -1,19 +1,14 @@
1
- declare namespace _default {
2
- export { nodeRemove };
3
- export { remove };
4
- }
5
- export default _default;
1
+ /** @type {<T>(c: Cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>} */
2
+ export const nodeRemove: <T>(c: Cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>;
3
+ /** @type {<T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>} */
4
+ export const remove: <T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>;
6
5
  export type Leaf01<T> = null | _.Leaf1<T>;
7
6
  export type RemovePath<T> = {
8
7
  readonly first: Leaf01<T>;
9
- readonly tail: Find.Path<T>;
8
+ readonly tail: find.Path<T>;
10
9
  };
11
10
  export type Branch<T> = _.Branch1<T> | _.Branch3<T> | _.Branch5<T>;
12
11
  export type Merge<A, T> = (a: A) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>;
13
- /** @type {<T>(c: Cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>} */
14
- declare const nodeRemove: <T>(c: Cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>;
15
- /** @type {<T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>} */
16
- declare const remove: <T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>;
17
- import * as _ from '../types/module.f.mjs';
18
- import * as Find from '../find/module.f.mjs';
19
12
  import * as Cmp from '../../function/compare/module.f.mjs';
13
+ import * as _ from '../types/module.f.mjs';
14
+ import * as find from '../find/module.f.mjs';
@@ -1,11 +1,11 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
2
  import * as _ from '../types/module.f.mjs'
3
3
  import * as Cmp from '../../function/compare/module.f.mjs'
4
- import find, * as Find from '../find/module.f.mjs'
5
- import list from '../../list/module.f.mjs'
4
+ import * as find from '../find/module.f.mjs'
5
+ import * as list from '../../list/module.f.mjs'
6
6
  const { fold, concat, next } = list
7
7
  import * as Array from '../../array/module.f.mjs'
8
- import n from '../../nullable/module.f.mjs'
8
+ import * as n from '../../nullable/module.f.mjs'
9
9
  const { map } = n
10
10
 
11
11
  /**
@@ -17,11 +17,11 @@ const { map } = n
17
17
  * @template T
18
18
  * @typedef {{
19
19
  * readonly first: Leaf01<T>,
20
- * readonly tail: Find.Path<T>
20
+ * readonly tail: find.Path<T>
21
21
  * }} RemovePath
22
22
  */
23
23
 
24
- /** @type {<T>(tail: Find.Path<T>) => (n: _.Node<T>) => readonly[T, RemovePath<T>]} */
24
+ /** @type {<T>(tail: find.Path<T>) => (n: _.Node<T>) => readonly[T, RemovePath<T>]} */
25
25
  const path = tail => n => {
26
26
  switch (n.length) {
27
27
  case 1: { return [n[0], { first: null, tail }] }
@@ -95,7 +95,7 @@ const initValue1 = a => n => {
95
95
  * @typedef {(a: A) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} Merge
96
96
  */
97
97
 
98
- /** @type {<A, T>(ms: Array.Array2<Merge<A, T>>) => (i: Find.PathItem<T>) => (a: A) => Branch<T>} */
98
+ /** @type {<A, T>(ms: Array.Array2<Merge<A, T>>) => (i: find.PathItem<T>) => (a: A) => Branch<T>} */
99
99
  const reduceX = ms => ([i, n]) => a => {
100
100
  const [m0, m2] = ms
101
101
  /** @typedef {typeof ms extends Array.Array2<Merge<infer A, infer T>> ? [A,T] : never} AT */
@@ -118,14 +118,14 @@ const reduce = fold(reduceX([reduceValue0, reduceValue2]))
118
118
  const initReduce = reduceX([initValue0, initValue1])
119
119
 
120
120
  /** @type {<T>(c: Cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>} */
121
- const nodeRemove = c => node => {
121
+ export const nodeRemove = c => node => {
122
122
  /** @typedef {typeof c extends Cmp.Compare<infer T> ? T : never} T */
123
123
  /** @type {() => null | RemovePath<T>} */
124
124
  const f = () => {
125
125
  const { first, tail } = find.find(c)(node)
126
- /** @type {(n: _.Node<T>) => (f: (v: T) => Find.PathItem<T>) => RemovePath<T>} */
126
+ /** @type {(n: _.Node<T>) => (f: (v: T) => find.PathItem<T>) => RemovePath<T>} */
127
127
  const branch = n => f => {
128
- const [v, p] = path(/** @type {Find.Path<T>} */(null))(n)
128
+ const [v, p] = path(/** @type {find.Path<T>} */(null))(n)
129
129
  return { first: p.first, tail: concat(p.tail)({ first: f(v), tail }) }
130
130
  }
131
131
  const [i, n] = first
@@ -158,11 +158,4 @@ const nodeRemove = c => node => {
158
158
  }
159
159
 
160
160
  /** @type {<T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>} */
161
- const remove = c => map(nodeRemove(c))
162
-
163
- export default {
164
- /** @readonly */
165
- nodeRemove,
166
- /** @readonly */
167
- remove,
168
- }
161
+ export const remove = c => map(nodeRemove(c))
@@ -1,10 +1,10 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
  import * as BTree from '../types/module.f.mjs'
3
- import s from '../set/module.f.mjs'
4
- import str from '../../string/module.f.mjs'
3
+ import * as s from '../set/module.f.mjs'
4
+ import * as str from '../../string/module.f.mjs'
5
5
  const { cmp } = str
6
- import json from '../../../json/module.f.mjs'
7
- import o from '../../object/module.f.mjs'
6
+ import * as json from '../../../json/module.f.mjs'
7
+ import * as o from '../../object/module.f.mjs'
8
8
  const { sort } = o
9
9
 
10
10
  /** @type {(node: BTree.Node<string>) => (value: string) => BTree.Node<string>} */
@@ -1,9 +1,5 @@
1
- declare namespace _default {
2
- export { set };
3
- }
4
- export default _default;
5
- export type Branch1To3<T> = _.Branch1<T> | _.Branch3<T>;
6
1
  /** @type {<T>(c: Cmp.Compare<T>) => (f: (value: T|null) => T) => (tree: _.Tree<T>) => _.Node<T>} */
7
- declare const set: <T>(c: Cmp.Compare<T>) => (f: (value: T | null) => T) => (tree: _.Tree<T>) => _.Node<T>;
8
- import * as _ from '../types/module.f.mjs';
2
+ export const set: <T>(c: Cmp.Compare<T>) => (f: (value: T | null) => T) => (tree: _.Tree<T>) => _.Node<T>;
3
+ export type Branch1To3<T> = _.Branch1<T> | _.Branch3<T>;
9
4
  import * as Cmp from '../../function/compare/module.f.mjs';
5
+ import * as _ from '../types/module.f.mjs';