functionalscript 0.3.7 → 0.3.8

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 (109) hide show
  1. package/com/cpp/module.f.js +0 -1
  2. package/com/cs/module.f.js +5 -6
  3. package/com/rust/module.f.d.ts +3 -3
  4. package/com/rust/module.f.js +24 -29
  5. package/com/test/build.f.js +2 -2
  6. package/com/types/module.f.d.ts +1 -1
  7. package/com/types/module.f.js +1 -2
  8. package/com/types/testlib.f.js +0 -1
  9. package/commonjs/build/module.f.d.ts +2 -2
  10. package/commonjs/build/module.f.js +3 -6
  11. package/commonjs/build/test.f.js +0 -4
  12. package/commonjs/module/function/module.f.d.ts +1 -1
  13. package/commonjs/module/function/module.f.js +1 -1
  14. package/commonjs/module/module.f.d.ts +1 -1
  15. package/commonjs/module/module.f.js +2 -3
  16. package/commonjs/path/module.f.d.ts +5 -5
  17. package/commonjs/path/module.f.js +6 -8
  18. package/commonjs/path/test.f.js +1 -2
  19. package/crypto/prime_field/module.f.d.ts +1 -1
  20. package/crypto/prime_field/module.f.js +1 -1
  21. package/crypto/secp/module.f.d.ts +1 -1
  22. package/crypto/secp/module.f.js +2 -2
  23. package/crypto/sha2/module.f.d.ts +75 -12
  24. package/crypto/sha2/module.f.js +246 -139
  25. package/crypto/sha2/test.f.d.ts +22 -3
  26. package/crypto/sha2/test.f.js +120 -67
  27. package/dev/test/module.f.d.ts +1 -1
  28. package/dev/test/module.f.js +4 -5
  29. package/dev/test.f.js +0 -4
  30. package/djs/module.f.d.ts +1 -1
  31. package/djs/module.f.js +0 -1
  32. package/djs/parser/module.f.d.ts +1 -1
  33. package/djs/parser/module.f.js +0 -2
  34. package/djs/serializer/module.f.d.ts +2 -2
  35. package/djs/serializer/module.f.js +0 -2
  36. package/djs/tokenizer/module.f.js +0 -1
  37. package/fsc/test.f.js +0 -1
  38. package/js/tokenizer/module.f.d.ts +1 -1
  39. package/js/tokenizer/module.f.js +1 -1
  40. package/json/parser/module.f.d.ts +2 -2
  41. package/json/parser/module.f.js +0 -3
  42. package/json/serializer/module.f.js +0 -2
  43. package/json/tokenizer/module.f.js +0 -1
  44. package/package.json +1 -1
  45. package/text/ascii/module.f.d.ts +1 -1
  46. package/text/ascii/module.f.js +2 -3
  47. package/text/ascii/test.f.js +2 -4
  48. package/text/module.f.d.ts +18 -3
  49. package/text/module.f.js +22 -6
  50. package/text/sgr/module.f.js +1 -1
  51. package/text/test.f.d.ts +4 -1
  52. package/text/test.f.js +24 -16
  53. package/text/utf16/module.f.d.ts +5 -6
  54. package/text/utf16/module.f.js +9 -10
  55. package/text/utf16/test.f.js +29 -30
  56. package/text/utf8/module.f.d.ts +8 -5
  57. package/text/utf8/module.f.js +3 -5
  58. package/text/utf8/test.f.js +34 -35
  59. package/types/bigfloat/module.f.js +1 -1
  60. package/types/bigint/module.f.d.ts +17 -5
  61. package/types/bigint/module.f.js +19 -4
  62. package/types/bigint/test.f.d.ts +1 -0
  63. package/types/bigint/test.f.js +7 -2
  64. package/types/bit_vec/module.f.d.ts +103 -83
  65. package/types/bit_vec/module.f.js +68 -110
  66. package/types/bit_vec/test.f.d.ts +20 -8
  67. package/types/bit_vec/test.f.js +110 -117
  68. package/types/btree/find/test.f.js +3 -4
  69. package/types/btree/module.f.d.ts +3 -3
  70. package/types/btree/module.f.js +2 -5
  71. package/types/btree/remove/test.f.js +2 -3
  72. package/types/btree/set/test.f.js +3 -6
  73. package/types/btree/test.f.js +0 -1
  74. package/types/btree/types/module.f.d.ts +3 -3
  75. package/types/byte_set/module.f.d.ts +2 -2
  76. package/types/byte_set/module.f.js +0 -2
  77. package/types/function/compare/module.f.d.ts +1 -1
  78. package/types/function/compare/module.f.js +0 -1
  79. package/types/function/compare/test.f.js +1 -2
  80. package/types/function/module.f.d.ts +1 -1
  81. package/types/function/module.f.js +1 -1
  82. package/types/function/operator/module.f.d.ts +2 -3
  83. package/types/function/operator/module.f.js +5 -5
  84. package/types/function/test.f.js +1 -2
  85. package/types/list/module.f.d.ts +1 -1
  86. package/types/list/module.f.js +9 -9
  87. package/types/list/test.f.js +2 -4
  88. package/types/map/module.f.d.ts +6 -6
  89. package/types/map/module.f.js +6 -15
  90. package/types/map/test.f.js +1 -2
  91. package/types/nibble_set/module.f.d.ts +2 -3
  92. package/types/nibble_set/test.f.js +1 -2
  93. package/types/number/test.f.js +1 -2
  94. package/types/object/module.f.d.ts +5 -5
  95. package/types/object/module.f.js +2 -4
  96. package/types/range_map/module.f.d.ts +4 -4
  97. package/types/range_map/module.f.js +3 -9
  98. package/types/result/module.f.d.ts +2 -3
  99. package/types/sorted_list/module.f.d.ts +6 -6
  100. package/types/sorted_list/module.f.js +2 -6
  101. package/types/sorted_list/test.f.js +4 -9
  102. package/types/sorted_set/module.f.d.ts +1 -1
  103. package/types/sorted_set/module.f.js +2 -5
  104. package/types/sorted_set/test.f.js +4 -9
  105. package/types/string/module.f.d.ts +3 -3
  106. package/types/string/module.f.js +1 -2
  107. package/types/string/test.f.js +2 -4
  108. package/types/string_set/module.f.d.ts +1 -1
  109. package/types/string_set/module.f.js +5 -11
@@ -1,5 +1,6 @@
1
- import { log2 } from "../bigint/module.f.js";
1
+ import { log2, mask } from "../bigint/module.f.js";
2
2
  import { flip } from "../function/module.f.js";
3
+ import { fold } from "../list/module.f.js";
3
4
  /**
4
5
  * An empty vector of bits.
5
6
  */
@@ -27,7 +28,10 @@ export const vec = (len) => {
27
28
  const mask = stop - 1n;
28
29
  return data => stop | (data & mask);
29
30
  };
30
- const mask = (len) => (1n << len) - 1n;
31
+ /**
32
+ * Creates an 8 bit vector from an unsigned integer.
33
+ */
34
+ export const vec8 = vec(8n);
31
35
  /**
32
36
  * Returns the unsigned integer of the given vector by removing a stop bit.
33
37
  *
@@ -40,128 +44,82 @@ const mask = (len) => (1n << len) - 1n;
40
44
  */
41
45
  export const uint = (v) => v ^ (1n << length(v));
42
46
  /**
43
- * Extract the least significant unsigned integer from the given vector.
47
+ * Implements operations for handling vectors in a least-significant-bit (LSb) first order.
44
48
  *
45
- * @example
49
+ * https://en.wikipedia.org/wiki/Bit_numbering#LSb_0_bit_numbering
46
50
  *
47
- * ```js
48
- * const vector = vec(8n)(0xF5n) // 0x1F5n
49
- * const result = uintLsb(4n)(vector); // result is 5n
50
- * const result2 = uintLsb(16n)(vector); // result2 is 0xF5n
51
- * ```
51
+ * Usually associated with Little-Endian (LE) byte order.
52
52
  */
53
- export const uintLsb = (len) => {
54
- const m = mask(len);
55
- return v => {
56
- const result = v & m;
57
- return result === v ? uint(v) : result;
58
- };
59
- };
60
- /**
61
- * Removes the first `len` least significant bits from the given vector.
62
- *
63
- * @example
64
- *
65
- * ```js
66
- * const v = vec(16n)(0x3456n) // 0x13456n
67
- * const r = removeLsb(4n)(v) // 0x1345n
68
- * const r2 = removeLsb(24n)(v) // 0x1n
69
- * ```
70
- */
71
- export const removeLsb = (len) => (v) => {
72
- const r = v >> len;
73
- return r === 0n ? empty : r;
74
- };
75
- /**
76
- * Extracts the least significant unsigned integer and removes it from the vector.
77
- *
78
- * @example
79
- *
80
- * ```js
81
- * const vector = vec(8n)(0xF5n) // 0x1F5n
82
- * const [result, rest] = popUintLsb(4n)(vector); // result is 5n, rest is 0x1Fn
83
- * const [result2, rest2] = popUintLsb(16n)(vector); // result2 is 0xF5n, rest2 is 1n
84
- * ```
85
- */
86
- export const popUintLsb = (len) => {
87
- const m = mask(len);
88
- return v => {
89
- const result = v & m;
90
- return result === v ? [uint(v), empty] : [result, v >> len];
91
- };
53
+ export const lsb = {
54
+ front: len => {
55
+ const m = mask(len);
56
+ return v => {
57
+ const result = v & m;
58
+ return result === v ? uint(v) : result;
59
+ };
60
+ },
61
+ removeFront: len => v => {
62
+ const r = v >> len;
63
+ return r === 0n ? empty : r;
64
+ },
65
+ popFront: len => {
66
+ const m = mask(len);
67
+ return v => {
68
+ const result = v & m;
69
+ return result === v ? [uint(v), empty] : [result, v >> len];
70
+ };
71
+ },
72
+ concat: a => {
73
+ const aLen = length(a);
74
+ const m = mask(aLen);
75
+ return b => (b << aLen) | (a & m);
76
+ }
92
77
  };
93
78
  /**
94
- * Extract the most significant unsigned integer of the given `len` from the given vector.
79
+ * Implements operations for handling vectors in a most-significant-bit (MSb) first order.
95
80
  *
96
- * @example
81
+ * https://en.wikipedia.org/wiki/Bit_numbering#MSb_0_bit_numbering
97
82
  *
98
- * ```js
99
- * const vector = vec(8n)(0xF5n) // 0x1F5n
100
- * const result = uintMsb(4n)(vector); // result is 0xFn
101
- * const result2 = uintMsb(16n)(vector); // result2 is 0xF500n
102
- * ```
83
+ * Usually associated with Big-Endian (BE) byte order.
103
84
  */
104
- export const uintMsb = (len) => {
105
- const m = mask(len);
106
- return v => (v >> (length(v) - len)) & m;
85
+ export const msb = {
86
+ front: len => {
87
+ const m = mask(len);
88
+ return v => (v >> (length(v) - len)) & m;
89
+ },
90
+ removeFront: len => v => vec(length(v) - len)(v),
91
+ popFront: len => {
92
+ const m = mask(len);
93
+ return v => {
94
+ const d = length(v) - len;
95
+ return [(v >> d) & m, vec(d)(v)];
96
+ };
97
+ },
98
+ concat: flip(lsb.concat)
107
99
  };
100
+ const appendU8 = ({ concat }) => (u8) => (a) => concat(a)(vec8(BigInt(u8)));
108
101
  /**
109
- * Removes the first `len` most significant bits from the given vector.
110
- *
111
- * @example
102
+ * Converts a list of unsigned 8-bit integers to a bit vector.
112
103
  *
113
- * ```js
114
- * const v = vec(16n)(0x3456n) // 0x13456n
115
- * const r = removeMsb(4n)(v) // 0x1456n
116
- * const r2 = removeMsb(24n)(v) // 0x1n
117
- * ```
104
+ * @param bo The bit order for the conversion
105
+ * @param list The list of unsigned 8-bit integers to be converted.
106
+ * @returns The resulting vector based on the provided bit order.
118
107
  */
119
- export const removeMsb = (len) => (v) => vec(length(v) - len)(v);
108
+ export const u8ListToVec = (bo) => fold(appendU8(bo))(empty);
120
109
  /**
121
- * Extracts the most significant unsigned integer and removes it from the vector.
110
+ * Converts a bit vector to a list of unsigned 8-bit integers based on the provided bit order.
122
111
  *
123
- * @example
124
- *
125
- * ```js
126
- * const vector = vec(8n)(0xF5n) // 0x1F5n
127
- * const [result, rest] = popUintMsb(4n)(vector); // [0xFn, 0x15n]
128
- * const [result2, rest2] = popUintMsb(16n)(vector); // [0xF500n, 1n]
129
- * ```
112
+ * @param bitOrder The bit order for the conversion.
113
+ * @param v The vector to be converted.
114
+ * @returns A thunk that produces a list of unsigned 8-bit integers.
130
115
  */
131
- export const popUintMsb = (len) => {
132
- const m = mask(len);
133
- return v => {
134
- const d = length(v) - len;
135
- return [(v >> d) & m, vec(d)(v)];
116
+ export const u8List = ({ popFront }) => {
117
+ const f = (v) => () => {
118
+ if (v === empty) {
119
+ return null;
120
+ }
121
+ const [first, tail] = popFront(8n)(v);
122
+ return { first: Number(first), tail: f(tail) };
136
123
  };
124
+ return f;
137
125
  };
138
- /**
139
- * Concat the given vectors of bits. The first vector is the least significant.
140
- *
141
- * @example
142
- *
143
- * ```js
144
- * const u8 = vec(8n)
145
- * const a = u8(0x45n) // 0x145n
146
- * const b = u8(0x89n) // 0x189n
147
- * const ab = concatLsb(a)(b) // 0x18945n
148
- * ```
149
- */
150
- export const concatLsb = (a) => {
151
- const aLen = length(a);
152
- const m = mask(aLen);
153
- return b => (b << aLen) | (a & m);
154
- };
155
- /**
156
- * Concat the given vectors of bits. The first vector is the most significant.
157
- *
158
- * @example
159
- *
160
- * ```js
161
- * const u8 = vec(8n)
162
- * const a = u8(0x45n) // 0x145n
163
- * const b = u8(0x89n) // 0x189n
164
- * const ab = concatMsb(a)(b) // 0x14589n
165
- * ```
166
- */
167
- export const concatMsb = flip(concatLsb);
@@ -2,14 +2,26 @@ declare const _default: {
2
2
  examples: {
3
3
  vec: () => void;
4
4
  uint: () => void;
5
- uintLsb: () => void;
6
- uintMsb: () => void;
7
- popUintLsb: () => void;
8
- popUintMsb: () => void;
9
- concatLsb: () => void;
10
- concatMsb: () => void;
11
- removeLsb: () => void;
12
- removeMsb: () => void;
5
+ front: () => void;
6
+ removeFront: () => void;
7
+ popFront: () => void;
8
+ concat: () => void;
9
+ };
10
+ front: {
11
+ lsbf: () => void;
12
+ msbf: () => void;
13
+ };
14
+ popFront: {
15
+ lsbm: () => void;
16
+ msbm: () => void;
17
+ };
18
+ removeFront: {
19
+ lsbm: () => void;
20
+ msbm: () => void;
21
+ };
22
+ concat: {
23
+ lsbm: () => void;
24
+ msbm: () => void;
13
25
  };
14
26
  uintLsb: () => void;
15
27
  uintSmall: () => void;
@@ -1,4 +1,73 @@
1
- import { empty, vec, length, concatLsb, uintLsb, uintMsb, removeLsb, concatMsb, removeMsb, uint, popUintLsb, popUintMsb } from "./module.f.js";
1
+ import { empty, vec, length, uint, lsb, msb } from "./module.f.js";
2
+ const frontTest = (e) => (r0) => (r1) => () => {
3
+ const vector = vec(8n)(0xf5n); // 0x1F5n
4
+ if (vector !== 0x1f5n) {
5
+ throw vector;
6
+ }
7
+ const result = e.front(4n)(vector);
8
+ if (result !== r0) {
9
+ throw result;
10
+ }
11
+ const result2 = e.front(16n)(vector);
12
+ if (result2 !== r1) {
13
+ throw result2;
14
+ }
15
+ };
16
+ const popFront = (e) => ([r00, r01]) => ([r10, r11]) => () => {
17
+ const vector = vec(8n)(0xf5n); // 0x1F5n
18
+ const [result, rest] = e.popFront(4n)(vector);
19
+ if (result !== r00) {
20
+ throw result;
21
+ }
22
+ if (rest !== r01) {
23
+ throw rest;
24
+ }
25
+ const [result2, rest2] = e.popFront(16n)(vector);
26
+ if (result2 !== r10) {
27
+ throw result2;
28
+ }
29
+ if (rest2 !== r11) {
30
+ throw rest2;
31
+ }
32
+ };
33
+ const removeFront = (e) => (r0) => (r1) => () => {
34
+ const v = vec(16n)(0x3456n); // 0x13456n
35
+ if (v !== 0x13456n) {
36
+ throw v;
37
+ }
38
+ const r = e.removeFront(4n)(v);
39
+ if (r !== r0) {
40
+ throw r;
41
+ }
42
+ const r2 = e.removeFront(24n)(v);
43
+ if (r2 !== r1) {
44
+ throw r2;
45
+ }
46
+ };
47
+ const concat = (e) => (r) => () => {
48
+ const u8 = vec(8n);
49
+ const a = u8(0x45n); // 0x145n
50
+ if (a !== 0x145n) {
51
+ throw a;
52
+ }
53
+ const b = u8(0x89n); // 0x189n
54
+ if (b !== 0x189n) {
55
+ throw b;
56
+ }
57
+ const ab = e.concat(a)(b); // 0x18945n
58
+ if (ab !== r) {
59
+ throw ab;
60
+ }
61
+ };
62
+ const assertEq = (a, b) => {
63
+ if (a !== b) {
64
+ throw [a, b];
65
+ }
66
+ };
67
+ const assertEq2 = ([a0, a1], [b0, b1]) => {
68
+ assertEq(a0, b0);
69
+ assertEq(a1, b1);
70
+ };
2
71
  export default {
3
72
  examples: {
4
73
  vec: () => {
@@ -22,130 +91,54 @@ export default {
22
91
  throw result;
23
92
  }
24
93
  },
25
- uintLsb: () => {
94
+ front: () => {
26
95
  const vector = vec(8n)(0xf5n); // 0x1F5n
27
- if (vector !== 0x1f5n) {
28
- throw vector;
29
- }
30
- const result = uintLsb(4n)(vector); // result is 5n
31
- if (result !== 5n) {
32
- throw result;
33
- }
34
- const result2 = uintLsb(16n)(vector); // result2 is 0xF5n
35
- if (result2 !== 0xf5n) {
36
- throw result2;
37
- }
96
+ assertEq(lsb.front(4n)(vector), 5n);
97
+ assertEq(lsb.front(16n)(vector), 0xf5n);
98
+ assertEq(msb.front(4n)(vector), 0xfn);
99
+ assertEq(msb.front(16n)(vector), 0xf500n);
38
100
  },
39
- uintMsb: () => {
40
- const vector = vec(8n)(0xf5n); // 0x1F5n
41
- if (vector !== 0x1f5n) {
42
- throw vector;
43
- }
44
- const result = uintMsb(4n)(vector); // result is 0xFn
45
- if (result !== 0xfn) {
46
- throw result;
47
- }
48
- const result2 = uintMsb(16n)(vector); // result2 is 0xF500n
49
- if (result2 !== 0xf500n) {
50
- throw result2;
51
- }
52
- },
53
- popUintLsb: () => {
54
- const vector = vec(8n)(0xf5n); // 0x1F5n
55
- const [result, rest] = popUintLsb(4n)(vector); // result is 5n, rest is 0x1Fn
56
- if (result !== 5n) {
57
- throw result;
58
- }
59
- if (rest !== 0x1fn) {
60
- throw rest;
61
- }
62
- const [result2, rest2] = popUintLsb(16n)(vector); // result2 is 0xF5n, rest2 is 1n
63
- if (result2 !== 0xf5n) {
64
- throw result2;
65
- }
66
- if (rest2 !== 1n) {
67
- throw rest2;
68
- }
101
+ removeFront: () => {
102
+ const v = vec(16n)(0x3456n); // 0x13456n
103
+ assertEq(lsb.removeFront(4n)(v), 0x1345n);
104
+ assertEq(lsb.removeFront(24n)(v), 0x1n);
105
+ assertEq(msb.removeFront(4n)(v), 0x1456n);
106
+ assertEq(msb.removeFront(24n)(v), 0x1n);
69
107
  },
70
- popUintMsb: () => {
108
+ popFront: () => {
71
109
  const vector = vec(8n)(0xf5n); // 0x1F5n
72
- const [result, rest] = popUintMsb(4n)(vector); // [0xFn, 0x15n]
73
- if (result !== 0xfn) {
74
- throw result;
75
- }
76
- if (rest !== 0x15n) {
77
- throw rest;
78
- }
79
- const [result2, rest2] = popUintMsb(16n)(vector); // [0xF500n, 1n]
80
- if (result2 !== 0xf500n) {
81
- throw result2;
82
- }
83
- if (rest2 !== 1n) {
84
- throw rest2;
85
- }
86
- },
87
- concatLsb: () => {
88
- const u8 = vec(8n);
89
- const a = u8(0x45n); // 0x145n
90
- if (a !== 0x145n) {
91
- throw a;
92
- }
93
- const b = u8(0x89n); // 0x189n
94
- if (b !== 0x189n) {
95
- throw b;
96
- }
97
- const ab = concatLsb(a)(b); // 0x18945n
98
- if (ab !== 0x18945n) {
99
- throw ab;
100
- }
110
+ assertEq2(lsb.popFront(4n)(vector), [5n, 0x1fn]);
111
+ assertEq2(lsb.popFront(16n)(vector), [0xf5n, 1n]);
112
+ assertEq2(msb.popFront(4n)(vector), [0xfn, 0x15n]);
113
+ assertEq2(msb.popFront(16n)(vector), [0xf500n, 1n]);
101
114
  },
102
- concatMsb: () => {
115
+ concat: () => {
103
116
  const u8 = vec(8n);
104
117
  const a = u8(0x45n); // 0x145n
105
- if (a !== 0x145n) {
106
- throw a;
107
- }
108
118
  const b = u8(0x89n); // 0x189n
109
- if (b !== 0x189n) {
110
- throw b;
111
- }
112
- const ab = concatMsb(a)(b); // 0x14589n
113
- if (ab !== 0x14589n) {
114
- throw ab;
115
- }
116
- },
117
- removeLsb: () => {
118
- const v = vec(16n)(0x3456n); // 0x13456n
119
- if (v !== 0x13456n) {
120
- throw v;
121
- }
122
- const r = removeLsb(4n)(v); // 0x1345n
123
- if (r !== 0x1345n) {
124
- throw r;
125
- }
126
- const r2 = removeLsb(24n)(v); // 0x1n
127
- if (r2 !== 0x1n) {
128
- throw r2;
129
- }
130
- },
131
- removeMsb: () => {
132
- const v = vec(16n)(0x3456n); // 0x13456n
133
- if (v !== 0x13456n) {
134
- throw v;
135
- }
136
- const r = removeMsb(4n)(v); // 0x1456n
137
- if (r !== 0x1456n) {
138
- throw r;
139
- }
140
- const r2 = removeMsb(24n)(v); // 0x1n
141
- if (r2 !== 0x1n) {
142
- throw r2;
143
- }
119
+ assertEq(lsb.concat(a)(b), 0x18945n);
120
+ assertEq(msb.concat(a)(b), 0x14589n);
144
121
  }
145
122
  },
123
+ front: {
124
+ lsbf: frontTest(lsb)(5n)(0xf5n),
125
+ msbf: frontTest(msb)(0xfn)(0xf500n),
126
+ },
127
+ popFront: {
128
+ lsbm: popFront(lsb)([5n, 0x1fn])([0xf5n, 1n]),
129
+ msbm: popFront(msb)([0xfn, 0x15n])([0xf500n, 1n]),
130
+ },
131
+ removeFront: {
132
+ lsbm: removeFront(lsb)(0x1345n)(0x1n),
133
+ msbm: removeFront(msb)(0x1456n)(0x1n),
134
+ },
135
+ concat: {
136
+ lsbm: concat(lsb)(0x18945n),
137
+ msbm: concat(msb)(0x14589n),
138
+ },
146
139
  uintLsb: () => {
147
140
  const vector = 117n;
148
- const extract3Bits = uintLsb(3n);
141
+ const extract3Bits = lsb.front(3n);
149
142
  const result = extract3Bits(vector); // result is 0b101n (5n)
150
143
  if (result !== 5n) {
151
144
  throw result;
@@ -153,7 +146,7 @@ export default {
153
146
  },
154
147
  uintSmall: () => {
155
148
  const vector = 3n;
156
- const extract3Bits = uintLsb(3n)(vector);
149
+ const extract3Bits = lsb.front(3n)(vector);
157
150
  if (extract3Bits !== 1n) {
158
151
  throw extract3Bits;
159
152
  }
@@ -179,7 +172,7 @@ export default {
179
172
  if (length(v) !== 8n) {
180
173
  throw 'len';
181
174
  }
182
- const u = uintLsb(8n)(v);
175
+ const u = lsb.front(8n)(v);
183
176
  if (u !== 0xfen) {
184
177
  throw v;
185
178
  }
@@ -188,7 +181,7 @@ export default {
188
181
  const vec8 = vec(8n);
189
182
  const a = vec8(0x345n);
190
183
  const b = vec8(0x789n);
191
- const ab = concatLsb(a)(b);
184
+ const ab = lsb.concat(a)(b);
192
185
  if (ab !== 0x18945n) {
193
186
  throw ab;
194
187
  }
@@ -202,7 +195,7 @@ export default {
202
195
  if (v !== 0x32345n) {
203
196
  throw v.toString(16);
204
197
  }
205
- const r = removeLsb(9n)(v);
198
+ const r = lsb.removeFront(9n)(v);
206
199
  if (r !== 0x191n) {
207
200
  throw r.toString(16);
208
201
  }
@@ -1,9 +1,7 @@
1
1
  import * as _ from "./module.f.js";
2
2
  import * as list from "../../list/module.f.js";
3
3
  import * as json from "../../../json/module.f.js";
4
- import * as o from "../../object/module.f.js";
5
- const { sort } = o;
6
- import * as btree from "../types/module.f.js";
4
+ import { sort } from "../../object/module.f.js";
7
5
  import * as string from "../../string/module.f.js";
8
6
  const { cmp } = string;
9
7
  import * as s from "../set/module.f.js";
@@ -13,8 +11,9 @@ const str = r => jsonStr(list.toArray(list.map((x) => x[0])(r)));
13
11
  const find = i => m => str(_.find(cmp(i))(m));
14
12
  const test = () => {
15
13
  let _map = ['1'];
16
- for (let i = 2; i <= 10; i++)
14
+ for (let i = 2; i <= 10; i++) {
17
15
  _map = set(_map)((i * i).toString());
16
+ }
18
17
  {
19
18
  const s = jsonStr(_map);
20
19
  if (s !== '[[["1","100"],"16",["25","36"]],"4",[["49"],"64",["81","9"]]]') {
@@ -1,4 +1,4 @@
1
- import * as list from '../list/module.f.ts';
2
- import * as _ from './types/module.f.ts';
1
+ import { type List } from '../list/module.f.ts';
2
+ import type * as _ from './types/module.f.ts';
3
3
  export declare const empty: null;
4
- export declare const values: <T>(tree: _.Tree<T>) => list.List<T>;
4
+ export declare const values: <T>(tree: _.Tree<T>) => List<T>;
@@ -1,8 +1,5 @@
1
- import * as list from "../list/module.f.js";
2
- const { flat } = list;
3
- import * as n from "../nullable/module.f.js";
4
- const { map } = n;
5
- import * as _ from "./types/module.f.js";
1
+ import { flat } from "../list/module.f.js";
2
+ import { map } from "../nullable/module.f.js";
6
3
  const nodeValues = node => () => {
7
4
  switch (node.length) {
8
5
  case 1:
@@ -1,13 +1,12 @@
1
1
  import * as _ from "./module.f.js";
2
- import * as BTree from "../types/module.f.js";
3
2
  import * as s from "../set/module.f.js";
4
3
  import * as str from "../../string/module.f.js";
5
4
  const { cmp } = str;
6
5
  import * as json from "../../../json/module.f.js";
7
6
  import * as o from "../../object/module.f.js";
8
7
  const { sort } = o;
9
- const set = node => value => s.set(cmp(value))(() => value)(node);
10
- const remove = node => value => _.nodeRemove(cmp(value))(node);
8
+ const set = (node) => (value) => s.set(cmp(value))(() => value)(node);
9
+ const remove = (node) => (value) => _.nodeRemove(cmp(value))(node);
11
10
  const jsonStr = json.stringify(sort);
12
11
  const test = () => {
13
12
  let _map = ['1'];
@@ -1,11 +1,8 @@
1
1
  import * as _ from "./module.f.js";
2
- import * as BTree from "../types/module.f.js";
3
- import * as s from "../../string/module.f.js";
4
- const { cmp } = s;
2
+ import { cmp } from "../../string/module.f.js";
5
3
  import * as json from "../../../json/module.f.js";
6
- import * as o from "../../object/module.f.js";
7
- const { sort } = o;
8
- const set = node => value => _.set(cmp(value))(() => value)(node);
4
+ import { sort } from "../../object/module.f.js";
5
+ const set = (node) => (value) => _.set(cmp(value))(() => value)(node);
9
6
  const jsonStr = json.stringify(sort);
10
7
  const test = [
11
8
  () => {
@@ -1,4 +1,3 @@
1
- import * as BTree from "./types/module.f.js";
2
1
  import * as _ from "./module.f.js";
3
2
  const { values } = _;
4
3
  import * as json from "../../json/module.f.js";
@@ -1,5 +1,6 @@
1
- type Array1<T> = readonly [T];
2
- type Array2<T> = readonly [T, T];
1
+ export type Array1<T> = readonly [T];
2
+ export type Array2<T> = readonly [T, T];
3
+ export type Array3<T> = readonly [T, T, T];
3
4
  export type Leaf1<T> = Array1<T>;
4
5
  export type Leaf2<T> = Array2<T>;
5
6
  export type Branch3<T> = readonly [TNode<T>, T, TNode<T>];
@@ -8,4 +9,3 @@ export type TNode<T> = Leaf1<T> | Leaf2<T> | Branch3<T> | Branch5<T>;
8
9
  export type Tree<T> = TNode<T> | null;
9
10
  export type Branch1<T> = readonly [TNode<T>];
10
11
  export type Branch7<T> = readonly [...Branch5<T>, T, TNode<T>];
11
- export {};
@@ -1,5 +1,5 @@
1
- import * as RangeMap from '../range_map/module.f.ts';
2
- import * as SortedSet from '../sorted_set/module.f.ts';
1
+ import type * as RangeMap from '../range_map/module.f.ts';
2
+ import type * as SortedSet from '../sorted_set/module.f.ts';
3
3
  export type ByteSet = bigint;
4
4
  type Byte = number;
5
5
  export declare const has: (n: Byte) => (s: ByteSet) => boolean;
@@ -1,6 +1,4 @@
1
1
  import { compose } from "../function/module.f.js";
2
- import * as RangeMap from "../range_map/module.f.js";
3
- import * as SortedSet from "../sorted_set/module.f.js";
4
2
  import * as list from "../list/module.f.js";
5
3
  const { reverse, countdown, flat, map } = list;
6
4
  export const has = n => s => ((s >> BigInt(n)) & 1n) === 1n;
@@ -1,4 +1,4 @@
1
- import * as Array from '../../array/module.f.ts';
1
+ import type * as Array from '../../array/module.f.ts';
2
2
  export type Index3 = Array.Index3;
3
3
  export type Index5 = Array.Index5;
4
4
  type Array2<T> = Array.Array2<T>;
@@ -1,4 +1,3 @@
1
- import * as Array from "../../array/module.f.js";
2
1
  export const index3 = cmp => value => (cmp(value) + 1);
3
2
  export const index5 = cmp => ([v0, v1]) => {
4
3
  const _0 = cmp(v0);
@@ -1,5 +1,4 @@
1
- import * as _ from "./module.f.js";
2
- const { unsafeCmp } = _;
1
+ import { unsafeCmp } from "./module.f.js";
3
2
  export default () => {
4
3
  const result = unsafeCmp(true)(false);
5
4
  if (result !== 1) {
@@ -24,5 +24,5 @@ type Fn<I, O> = {
24
24
  /**
25
25
  * Creates an `Fn` instance from a function, enabling chaining of transformations.
26
26
  */
27
- export declare const fn: <I, O>(f: (i: I) => O) => Fn<I, O>;
27
+ export declare const fn: <I, O>(result: Func<I, O>) => Fn<I, O>;
28
28
  export {};