functionalscript 0.1.609 → 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.
- package/com/cpp/module.f.d.mts +4 -8
- package/com/cpp/module.f.mjs +20 -25
- package/com/cpp/testlib.f.mjs +3 -4
- package/com/cs/module.f.d.mts +4 -8
- package/com/cs/module.f.mjs +18 -23
- package/com/cs/testlib.f.mjs +3 -5
- package/com/rust/module.f.d.mts +3 -7
- package/com/rust/module.f.mjs +25 -30
- package/com/rust/testlib.f.mjs +3 -5
- package/com/test/build.f.d.mts +2 -2
- package/com/test/build.f.mjs +2 -2
- package/com/test/build.mjs +4 -4
- package/com/types/module.f.d.mts +5 -10
- package/com/types/module.f.mjs +5 -12
- package/commonjs/build/module.f.d.mts +13 -17
- package/commonjs/build/module.f.mjs +23 -28
- package/commonjs/build/test.f.mjs +4 -4
- package/commonjs/module/function/module.f.d.mts +0 -2
- package/commonjs/module/function/module.f.mjs +0 -2
- package/commonjs/module/module.f.d.mts +16 -21
- package/commonjs/module/module.f.mjs +2 -9
- package/commonjs/module.d.mts +1 -5
- package/commonjs/module.f.d.mts +0 -2
- package/commonjs/module.f.mjs +0 -2
- package/commonjs/module.mjs +2 -7
- package/commonjs/package/dependencies/module.f.d.mts +3 -7
- package/commonjs/package/dependencies/module.f.mjs +5 -10
- package/commonjs/package/dependencies/test.f.mjs +1 -1
- package/commonjs/package/module.f.d.mts +12 -18
- package/commonjs/package/module.f.mjs +6 -13
- package/commonjs/package/test.f.mjs +1 -1
- package/commonjs/path/module.f.d.mts +25 -32
- package/commonjs/path/module.f.mjs +12 -23
- package/commonjs/path/test.f.mjs +11 -11
- package/commonjs/test.mjs +1 -1
- package/dev/module.f.d.mts +1 -4
- package/dev/module.f.mjs +1 -4
- package/dev/test/module.f.d.mts +2 -3
- package/dev/test/module.f.mjs +4 -6
- package/djs/module.f.d.mts +13 -18
- package/djs/module.f.mjs +12 -19
- package/djs/parser/module.f.d.mts +11 -15
- package/djs/parser/module.f.mjs +18 -24
- package/djs/parser/test.f.mjs +9 -9
- package/djs/test.f.mjs +4 -4
- package/djs/tokenizer/module.f.d.mts +6 -10
- package/djs/tokenizer/module.f.mjs +18 -23
- package/djs/tokenizer/test.f.mjs +6 -6
- package/fsc/module.f.d.mts +4 -9
- package/fsc/module.f.mjs +17 -24
- package/fsc/test.f.mjs +3 -3
- package/fsm/module.f.d.mts +13 -20
- package/fsm/module.f.mjs +27 -38
- package/fsm/test.f.mjs +8 -8
- package/html/module.f.d.mts +7 -12
- package/html/module.f.mjs +14 -23
- package/html/test.f.mjs +4 -4
- package/js/tokenizer/module.f.d.mts +10 -15
- package/js/tokenizer/module.f.mjs +55 -62
- package/js/tokenizer/test.f.mjs +6 -6
- package/json/module.f.d.mts +18 -26
- package/json/module.f.mjs +18 -31
- package/json/parser/module.f.d.mts +9 -13
- package/json/parser/module.f.mjs +9 -14
- package/json/parser/test.f.mjs +7 -7
- package/json/serializer/module.f.d.mts +11 -20
- package/json/serializer/module.f.mjs +14 -29
- package/json/serializer/test.f.mjs +2 -2
- package/json/test.f.mjs +3 -3
- package/json/tokenizer/module.f.d.mts +6 -10
- package/json/tokenizer/module.f.mjs +14 -19
- package/json/tokenizer/test.f.mjs +6 -6
- package/jsr.json +1 -1
- package/nodejs/version/main.mjs +1 -1
- package/nodejs/version/module.f.d.mts +4 -9
- package/nodejs/version/module.f.mjs +2 -7
- package/nodejs/version/test.f.mjs +3 -3
- package/package.json +1 -1
- package/prime_field/module.f.d.mts +20 -23
- package/prime_field/module.f.mjs +9 -12
- package/prime_field/test.f.mjs +1 -1
- package/secp/module.f.d.mts +27 -28
- package/secp/module.f.mjs +38 -39
- package/secp/test.f.mjs +4 -4
- package/sha2/module.f.d.mts +8 -16
- package/sha2/module.f.mjs +7 -20
- package/sha2/test.f.mjs +4 -4
- package/text/ascii/module.f.d.mts +69 -72
- package/text/ascii/module.f.mjs +5 -10
- package/text/ascii/test.f.mjs +3 -3
- package/text/module.f.d.mts +9 -14
- package/text/module.f.mjs +7 -14
- package/text/sgr/module.f.d.mts +7 -9
- package/text/sgr/module.f.mjs +2 -4
- package/text/test.f.mjs +3 -3
- package/text/utf16/module.f.d.mts +8 -15
- package/text/utf16/module.f.mjs +17 -28
- package/text/utf16/test.f.mjs +5 -5
- package/text/utf8/module.f.d.mts +4 -9
- package/text/utf8/module.f.mjs +9 -16
- package/text/utf8/test.f.mjs +4 -4
- package/types/array/module.f.d.mts +14 -24
- package/types/array/module.f.mjs +8 -25
- package/types/array/test.f.mjs +3 -3
- package/types/bigfloat/module.f.d.mts +4 -9
- package/types/bigfloat/module.f.mjs +3 -10
- package/types/bigfloat/test.f.mjs +1 -1
- package/types/bigint/module.f.d.mts +16 -64
- package/types/bigint/module.f.mjs +11 -30
- package/types/bigint/test.f.mjs +1 -1
- package/types/btree/find/module.f.d.mts +20 -26
- package/types/btree/find/module.f.mjs +8 -17
- package/types/btree/find/test.f.mjs +7 -7
- package/types/btree/module.f.d.mts +4 -8
- package/types/btree/module.f.mjs +6 -11
- package/types/btree/remove/module.f.d.mts +7 -12
- package/types/btree/remove/module.f.mjs +10 -17
- package/types/btree/remove/test.f.mjs +5 -5
- package/types/btree/set/module.f.d.mts +3 -7
- package/types/btree/set/module.f.mjs +4 -9
- package/types/btree/set/test.f.mjs +4 -4
- package/types/btree/test.f.mjs +9 -9
- package/types/btree/types/module.f.d.mts +0 -2
- package/types/btree/types/module.f.mjs +0 -2
- package/types/byte_set/module.f.d.mts +16 -29
- package/types/byte_set/module.f.mjs +14 -39
- package/types/byte_set/test.f.mjs +5 -5
- package/types/function/compare/module.f.d.mts +9 -15
- package/types/function/compare/module.f.mjs +3 -12
- package/types/function/compare/test.f.mjs +1 -1
- package/types/function/module.f.d.mts +20 -27
- package/types/function/module.f.mjs +4 -15
- package/types/function/operator/module.f.d.mts +28 -43
- package/types/function/operator/module.f.mjs +14 -41
- package/types/function/test.f.mjs +1 -1
- package/types/list/module.f.d.mts +56 -91
- package/types/list/module.f.mjs +45 -114
- package/types/list/test.f.mjs +10 -10
- package/types/map/module.f.d.mts +15 -24
- package/types/map/module.f.mjs +15 -30
- package/types/map/test.f.mjs +2 -2
- package/types/nibble_set/module.f.d.mts +10 -20
- package/types/nibble_set/module.f.mjs +7 -24
- package/types/nibble_set/test.f.mjs +2 -2
- package/types/nullable/module.f.d.mts +3 -8
- package/types/nullable/module.f.mjs +2 -9
- package/types/nullable/test.f.mjs +1 -1
- package/types/number/module.f.d.mts +7 -13
- package/types/number/module.f.mjs +8 -19
- package/types/number/test.f.mjs +1 -1
- package/types/object/module.f.d.mts +11 -18
- package/types/object/module.f.mjs +9 -20
- package/types/object/test.f.mjs +1 -1
- package/types/range/module.f.d.mts +3 -8
- package/types/range/module.f.mjs +2 -9
- package/types/range/test.f.mjs +1 -1
- package/types/range_map/module.f.d.mts +9 -15
- package/types/range_map/module.f.mjs +9 -18
- package/types/range_map/test.f.mjs +32 -32
- package/types/result/module.d.mts +3 -3
- package/types/result/module.f.d.mts +6 -12
- package/types/result/module.f.mjs +3 -12
- package/types/result/module.mjs +2 -2
- package/types/sorted_list/module.f.d.mts +22 -28
- package/types/sorted_list/module.f.mjs +10 -19
- package/types/sorted_list/test.f.mjs +7 -7
- package/types/sorted_set/module.f.d.mts +6 -12
- package/types/sorted_set/module.f.mjs +7 -16
- package/types/sorted_set/test.f.mjs +7 -7
- package/types/string/module.f.d.mts +8 -14
- package/types/string/module.f.mjs +10 -21
- package/types/string/test.f.mjs +2 -2
- package/types/string_set/module.f.d.mts +8 -16
- package/types/string_set/module.f.mjs +12 -27
- package/types/string_set/test.f.mjs +1 -1
package/secp/module.f.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
2
|
import * as Operator from '../types/function/operator/module.f.mjs'
|
|
3
|
-
import
|
|
4
|
-
import bi from '../types/bigint/module.f.mjs'
|
|
3
|
+
import * as pf from '../prime_field/module.f.mjs'
|
|
4
|
+
import * as bi from '../types/bigint/module.f.mjs'
|
|
5
5
|
const { scalar_mul } = bi
|
|
6
6
|
const { prime_field, sqrt } = pf
|
|
7
7
|
|
|
@@ -20,8 +20,8 @@ const { prime_field, sqrt } = pf
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @typedef {{
|
|
23
|
-
* readonly pf:
|
|
24
|
-
* readonly nf:
|
|
23
|
+
* readonly pf: pf.PrimeField
|
|
24
|
+
* readonly nf: pf.PrimeField
|
|
25
25
|
* readonly y2: (x: bigint) => bigint
|
|
26
26
|
* readonly y: (x: bigint) => bigint|null
|
|
27
27
|
* readonly neg: (a: Point) => Point
|
|
@@ -31,7 +31,7 @@ const { prime_field, sqrt } = pf
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
/** @type {(i: Init) => Curve} */
|
|
34
|
-
const curve = ({ p, a: [a0, a1], n }) => {
|
|
34
|
+
export const curve = ({ p, a: [a0, a1], n }) => {
|
|
35
35
|
const pf = prime_field(p)
|
|
36
36
|
const { pow2, pow3, sub, add, mul, neg, div } = pf
|
|
37
37
|
const mul3 = mul(3n)
|
|
@@ -85,38 +85,37 @@ const curve = ({ p, a: [a0, a1], n }) => {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
},
|
|
88
|
+
/** @type {(a: Point) => (b: Point) => boolean} */
|
|
89
|
+
export const eq = a => b => {
|
|
90
|
+
if (a === null || b === null) {
|
|
91
|
+
return a === b
|
|
92
|
+
}
|
|
93
|
+
const [ax, ay] = a
|
|
94
|
+
const [bx, by] = b
|
|
95
|
+
return ax === bx && ay === by
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** @type {Init} */
|
|
99
|
+
export const secp256k1 = {
|
|
100
|
+
p: 0xffffffff_ffffffff_ffffffff_ffffffff_ffffffff_ffffffff_fffffffe_fffffc2fn,
|
|
101
|
+
a: [7n, 0n],
|
|
102
|
+
g: [
|
|
103
|
+
0x79be667e_f9dcbbac_55a06295_ce870b07_029bfcdb_2dce28d9_59f2815b_16f81798n,
|
|
104
|
+
0x483ada77_26a3c465_5da4fbfc_0e1108a8_fd17b448_a6855419_9c47d08f_fb10d4b8n
|
|
105
|
+
],
|
|
106
|
+
n: 0xffffffff_ffffffff_ffffffff_fffffffe_baaedce6_af48a03b_bfd25e8c_d0364141n,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @type {Init} */
|
|
110
|
+
export const secp192r1 = {
|
|
111
|
+
p: 0xffffffff_ffffffff_ffffffff_fffffffe_ffffffff_ffffffffn,
|
|
112
|
+
a: [
|
|
113
|
+
0x64210519_e59c80e7_0fa7e9ab_72243049_feb8deec_c146b9b1n,
|
|
114
|
+
0xffffffff_ffffffff_ffffffff_fffffffe_ffffffff_fffffffcn
|
|
115
|
+
],
|
|
116
|
+
g: [
|
|
117
|
+
0x188da80e_b03090f6_7cbf20eb_43a18800_f4ff0afd_82ff1012n,
|
|
118
|
+
0x07192b95_ffc8da78_631011ed_6b24cdd5_73f977a1_1e794811n
|
|
119
|
+
],
|
|
120
|
+
n: 0xffffffff_ffffffff_ffffffff_99def836_146bc9b1_b4d22831n,
|
|
122
121
|
}
|
package/secp/test.f.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
2
|
const { curve, secp256k1, secp192r1, eq } = _
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
test: () => {
|
|
6
|
-
/** @type {(c:
|
|
6
|
+
/** @type {(c: _.Init) => void} */
|
|
7
7
|
const test_curve = c => {
|
|
8
8
|
const { g } = c
|
|
9
9
|
const { mul, neg, pf: { abs }, y: yf, nf: { p: n } } = curve(c)
|
|
10
|
-
/** @type {(p:
|
|
10
|
+
/** @type {(p: _.Point) => void} */
|
|
11
11
|
const point_check = p => {
|
|
12
12
|
if (p === null) { throw 'null' }
|
|
13
13
|
const [x, y] = p
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
}
|
|
18
18
|
point_check(g)
|
|
19
19
|
point_check(neg(g))
|
|
20
|
-
/** @type {(p:
|
|
20
|
+
/** @type {(p: _.Point) => void} */
|
|
21
21
|
const test_mul = p => {
|
|
22
22
|
if (mul(p)(0n) !== null) { throw 'O' }
|
|
23
23
|
if (mul(p)(1n) !== p) { throw 'p' }
|
package/sha2/module.f.d.mts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
1
|
+
/** @type {(input: readonly number[]) => (bits: number) => HashInput} */
|
|
2
|
+
export const padding: (input: readonly number[]) => (bits: number) => HashInput;
|
|
3
|
+
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
4
|
+
export const computeSha256: (input: readonly number[]) => (bitsCount: number) => Hash8;
|
|
5
|
+
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
6
|
+
export const computeSha224: (input: readonly number[]) => (bitsCount: number) => Hash8;
|
|
7
|
+
export const compress256: (data: Array16) => Hash8;
|
|
8
|
+
export const compress224: (data: Array16) => Hash8;
|
|
9
9
|
export type HashInput = {
|
|
10
10
|
readonly f: (i: number) => number;
|
|
11
11
|
readonly length: number;
|
|
12
12
|
};
|
|
13
13
|
export type Hash8 = arrayT.Array8<number>;
|
|
14
14
|
export type Array16 = arrayT.Array16<number>;
|
|
15
|
-
/** @type {(input: readonly number[]) => (bits: number) => HashInput} */
|
|
16
|
-
declare const padding: (input: readonly number[]) => (bits: number) => HashInput;
|
|
17
|
-
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
18
|
-
declare const computeSha256: (input: readonly number[]) => (bitsCount: number) => Hash8;
|
|
19
|
-
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
20
|
-
declare const computeSha224: (input: readonly number[]) => (bitsCount: number) => Hash8;
|
|
21
|
-
declare const compress256: (data: Array16) => Hash8;
|
|
22
|
-
declare const compress224: (data: Array16) => Hash8;
|
|
23
15
|
import * as arrayT from '../types/array/module.f.mjs';
|
package/sha2/module.f.mjs
CHANGED
|
@@ -19,7 +19,7 @@ const appendOneWithZeros = input => pos => (input >> pos << pos) | (1 << pos)
|
|
|
19
19
|
const mod = a => b => (a % b + b) % b
|
|
20
20
|
|
|
21
21
|
/** @type {(input: readonly number[]) => (bits: number) => HashInput} */
|
|
22
|
-
const padding = input => bitsCount => {
|
|
22
|
+
export const padding = input => bitsCount => {
|
|
23
23
|
const appendBlockIndex = (bitsCount / 32) | 0
|
|
24
24
|
const length = (bitsCount + mod(447 - bitsCount)(512) + 65) / 32
|
|
25
25
|
/** @type {(i: number) => number} */
|
|
@@ -183,27 +183,14 @@ const compute = init => input => bitsCount => {
|
|
|
183
183
|
const init256 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]
|
|
184
184
|
|
|
185
185
|
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
186
|
-
const computeSha256 = compute(init256)
|
|
186
|
+
export const computeSha256 = compute(init256)
|
|
187
187
|
|
|
188
188
|
/** @type {Hash8} */
|
|
189
189
|
const init224 = [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4]
|
|
190
190
|
|
|
191
191
|
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
192
|
-
const computeSha224 = compute(init224)
|
|
193
|
-
|
|
194
|
-
const compress256 = compress(init256)
|
|
195
|
-
|
|
196
|
-
const compress224 = compress(init224)
|
|
197
|
-
|
|
198
|
-
export default {
|
|
199
|
-
/** @readonly */
|
|
200
|
-
padding,
|
|
201
|
-
/** @readonly */
|
|
202
|
-
computeSha256,
|
|
203
|
-
/** @readonly */
|
|
204
|
-
computeSha224,
|
|
205
|
-
/** @readonly */
|
|
206
|
-
compress256,
|
|
207
|
-
/** @readonly */
|
|
208
|
-
compress224
|
|
209
|
-
}
|
|
192
|
+
export const computeSha224 = compute(init224)
|
|
193
|
+
|
|
194
|
+
export const compress256 = compress(init256)
|
|
195
|
+
|
|
196
|
+
export const compress224 = compress(init224)
|
package/sha2/test.f.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _ from './module.f.mjs'
|
|
2
|
-
import
|
|
3
|
-
import o from '../types/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 '../types/object/module.f.mjs'
|
|
4
4
|
const { sort } = o
|
|
5
5
|
|
|
6
6
|
/** @type {(a: number) => number} */
|
|
@@ -9,7 +9,7 @@ const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
|
|
|
9
9
|
/** @type {(a: number) => string} */
|
|
10
10
|
const toHexString = x => toU32(x).toString(16).padStart(8, '0')
|
|
11
11
|
|
|
12
|
-
/** @type {(a: readonly
|
|
12
|
+
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
13
13
|
const stringify = a => json.stringify(sort)(a)
|
|
14
14
|
|
|
15
15
|
// {
|
|
@@ -1,73 +1,70 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { one };
|
|
3
|
-
export { range };
|
|
4
|
-
export let backspace: number;
|
|
5
|
-
export let ht: number;
|
|
6
|
-
export let lf: number;
|
|
7
|
-
export let ff: number;
|
|
8
|
-
export let cr: number;
|
|
9
|
-
export let space: number;
|
|
10
|
-
export let exclamationMark: number;
|
|
11
|
-
export let quotationMark: number;
|
|
12
|
-
export let numberSign: number;
|
|
13
|
-
export let dollarSign: number;
|
|
14
|
-
export let percentSign: number;
|
|
15
|
-
export let ampersand: number;
|
|
16
|
-
export let apostrophe: number;
|
|
17
|
-
export let leftParenthesis: number;
|
|
18
|
-
export let rightParenthesis: number;
|
|
19
|
-
export let asterisk: number;
|
|
20
|
-
export let plusSign: number;
|
|
21
|
-
export let comma: number;
|
|
22
|
-
export let hyphenMinus: number;
|
|
23
|
-
export let fullStop: number;
|
|
24
|
-
export let solidus: number;
|
|
25
|
-
export let digitRange: Range.Range;
|
|
26
|
-
export let digit0: number;
|
|
27
|
-
export let digit1: number;
|
|
28
|
-
export let digit2: number;
|
|
29
|
-
export let digit3: number;
|
|
30
|
-
export let digit4: number;
|
|
31
|
-
export let digit5: number;
|
|
32
|
-
export let digit6: number;
|
|
33
|
-
export let digit7: number;
|
|
34
|
-
export let digit8: number;
|
|
35
|
-
export let digit9: number;
|
|
36
|
-
export let colon: number;
|
|
37
|
-
export let semicolon: number;
|
|
38
|
-
export let lessThanSign: number;
|
|
39
|
-
export let equalsSign: number;
|
|
40
|
-
export let greaterThanSign: number;
|
|
41
|
-
export let questionMark: number;
|
|
42
|
-
export let commercialAt: number;
|
|
43
|
-
export let latinCapitalLetterRange: Range.Range;
|
|
44
|
-
export let latinCapitalLetterA: number;
|
|
45
|
-
export let latinCapitalLetterE: number;
|
|
46
|
-
export let latinCapitalLetterF: number;
|
|
47
|
-
export let leftSquareBracket: number;
|
|
48
|
-
export let reverseSolidus: number;
|
|
49
|
-
export let rightSquareBracket: number;
|
|
50
|
-
export let circumflexAccent: number;
|
|
51
|
-
export let lowLine: number;
|
|
52
|
-
export let graveAccent: number;
|
|
53
|
-
export let latinSmallLetterRange: Range.Range;
|
|
54
|
-
export let latinSmallLetterA: number;
|
|
55
|
-
export let latinSmallLetterB: number;
|
|
56
|
-
export let latinSmallLetterE: number;
|
|
57
|
-
export let latinSmallLetterF: number;
|
|
58
|
-
export let latinSmallLetterN: number;
|
|
59
|
-
export let latinSmallLetterR: number;
|
|
60
|
-
export let latinSmallLetterT: number;
|
|
61
|
-
export let latinSmallLetterU: number;
|
|
62
|
-
export let latinSmallLetterZ: number;
|
|
63
|
-
export let leftCurlyBracket: number;
|
|
64
|
-
export let verticalLine: number;
|
|
65
|
-
export let rightCurlyBracket: number;
|
|
66
|
-
export let tilde: number;
|
|
67
|
-
}
|
|
68
|
-
export default _default;
|
|
69
1
|
/** @type {(s: string) => number} */
|
|
70
|
-
|
|
71
|
-
/** @type {(s: string) =>
|
|
72
|
-
|
|
73
|
-
|
|
2
|
+
export const one: (s: string) => number;
|
|
3
|
+
/** @type {(s: string) => _range.Range} */
|
|
4
|
+
export const range: (s: string) => _range.Range;
|
|
5
|
+
export namespace ascii {
|
|
6
|
+
let backspace: number;
|
|
7
|
+
let ht: number;
|
|
8
|
+
let lf: number;
|
|
9
|
+
let ff: number;
|
|
10
|
+
let cr: number;
|
|
11
|
+
let space: number;
|
|
12
|
+
let exclamationMark: number;
|
|
13
|
+
let quotationMark: number;
|
|
14
|
+
let numberSign: number;
|
|
15
|
+
let dollarSign: number;
|
|
16
|
+
let percentSign: number;
|
|
17
|
+
let ampersand: number;
|
|
18
|
+
let apostrophe: number;
|
|
19
|
+
let leftParenthesis: number;
|
|
20
|
+
let rightParenthesis: number;
|
|
21
|
+
let asterisk: number;
|
|
22
|
+
let plusSign: number;
|
|
23
|
+
let comma: number;
|
|
24
|
+
let hyphenMinus: number;
|
|
25
|
+
let fullStop: number;
|
|
26
|
+
let solidus: number;
|
|
27
|
+
let digitRange: _range.Range;
|
|
28
|
+
let digit0: number;
|
|
29
|
+
let digit1: number;
|
|
30
|
+
let digit2: number;
|
|
31
|
+
let digit3: number;
|
|
32
|
+
let digit4: number;
|
|
33
|
+
let digit5: number;
|
|
34
|
+
let digit6: number;
|
|
35
|
+
let digit7: number;
|
|
36
|
+
let digit8: number;
|
|
37
|
+
let digit9: number;
|
|
38
|
+
let colon: number;
|
|
39
|
+
let semicolon: number;
|
|
40
|
+
let lessThanSign: number;
|
|
41
|
+
let equalsSign: number;
|
|
42
|
+
let greaterThanSign: number;
|
|
43
|
+
let questionMark: number;
|
|
44
|
+
let commercialAt: number;
|
|
45
|
+
let latinCapitalLetterRange: _range.Range;
|
|
46
|
+
let latinCapitalLetterA: number;
|
|
47
|
+
let latinCapitalLetterE: number;
|
|
48
|
+
let latinCapitalLetterF: number;
|
|
49
|
+
let leftSquareBracket: number;
|
|
50
|
+
let reverseSolidus: number;
|
|
51
|
+
let rightSquareBracket: number;
|
|
52
|
+
let circumflexAccent: number;
|
|
53
|
+
let lowLine: number;
|
|
54
|
+
let graveAccent: number;
|
|
55
|
+
let latinSmallLetterRange: _range.Range;
|
|
56
|
+
let latinSmallLetterA: number;
|
|
57
|
+
let latinSmallLetterB: number;
|
|
58
|
+
let latinSmallLetterE: number;
|
|
59
|
+
let latinSmallLetterF: number;
|
|
60
|
+
let latinSmallLetterN: number;
|
|
61
|
+
let latinSmallLetterR: number;
|
|
62
|
+
let latinSmallLetterT: number;
|
|
63
|
+
let latinSmallLetterU: number;
|
|
64
|
+
let latinSmallLetterZ: number;
|
|
65
|
+
let leftCurlyBracket: number;
|
|
66
|
+
let verticalLine: number;
|
|
67
|
+
let rightCurlyBracket: number;
|
|
68
|
+
let tilde: number;
|
|
69
|
+
}
|
|
70
|
+
import * as _range from '../../types/range/module.f.mjs';
|
package/text/ascii/module.f.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as _range from '../../types/range/module.f.mjs'
|
|
3
3
|
|
|
4
4
|
/** @type {(s: string) => (i: number) => number} */
|
|
5
5
|
const at = s => i => {
|
|
@@ -9,22 +9,17 @@ const at = s => i => {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/** @type {(s: string) => number} */
|
|
12
|
-
const one = s => at(s)(0)
|
|
12
|
+
export const one = s => at(s)(0)
|
|
13
13
|
|
|
14
|
-
/** @type {(s: string) =>
|
|
15
|
-
const range = s => {
|
|
14
|
+
/** @type {(s: string) => _range.Range} */
|
|
15
|
+
export const range = s => {
|
|
16
16
|
const f = at(s)
|
|
17
17
|
const f0 = f(0)
|
|
18
18
|
if (s.length === 1) { return [f0, f0] }
|
|
19
19
|
return [f0, f(1)]
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export
|
|
23
|
-
/** @readonly */
|
|
24
|
-
one,
|
|
25
|
-
/** @readonly */
|
|
26
|
-
range,
|
|
27
|
-
|
|
22
|
+
export const ascii = {
|
|
28
23
|
// 0x00..
|
|
29
24
|
|
|
30
25
|
/** @readonly 0x08 */
|
package/text/ascii/test.f.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _ from './module.f.mjs'
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
2
|
const { range } = _
|
|
3
|
-
import json from '../../json/module.f.mjs'
|
|
4
|
-
import o from '../../types/object/module.f.mjs'
|
|
3
|
+
import * as json from '../../json/module.f.mjs'
|
|
4
|
+
import * as o from '../../types/object/module.f.mjs'
|
|
5
5
|
const { sort } = o
|
|
6
6
|
|
|
7
7
|
const stringify = json.stringify(sort)
|
package/text/module.f.d.mts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { flat };
|
|
3
|
-
export { curly };
|
|
4
|
-
}
|
|
5
|
-
export default _default;
|
|
6
|
-
export type Block = ItemThunk | ItemArray;
|
|
7
|
-
export type ItemArray = readonly Item[];
|
|
8
|
-
export type ItemThunk = () => List.List<Item>;
|
|
9
|
-
export type Item = string | ItemArray | ItemThunk;
|
|
10
1
|
/** @typedef {ItemThunk|ItemArray} Block */
|
|
11
2
|
/** @typedef {readonly Item[]} ItemArray */
|
|
12
|
-
/** @typedef {() =>
|
|
3
|
+
/** @typedef {() => list.List<Item>} ItemThunk */
|
|
13
4
|
/** @typedef {string|ItemArray|ItemThunk} Item */
|
|
14
|
-
/** @type {(indent: string) => (text: Block) =>
|
|
15
|
-
|
|
5
|
+
/** @type {(indent: string) => (text: Block) => list.List<string>} */
|
|
6
|
+
export const flat: (indent: string) => (text: Block) => list.List<string>;
|
|
16
7
|
/** @type {(type: string) => (name: string) => (body: Block) => Block} */
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
export const curly: (type: string) => (name: string) => (body: Block) => Block;
|
|
9
|
+
export type Block = ItemThunk | ItemArray;
|
|
10
|
+
export type ItemArray = readonly Item[];
|
|
11
|
+
export type ItemThunk = () => list.List<Item>;
|
|
12
|
+
export type Item = string | ItemArray | ItemThunk;
|
|
13
|
+
import * as list from '../types/list/module.f.mjs';
|
package/text/module.f.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as list from '../types/list/module.f.mjs'
|
|
3
3
|
const { flatMap } = list
|
|
4
4
|
|
|
5
5
|
/** @typedef {ItemThunk|ItemArray} Block */
|
|
6
6
|
|
|
7
7
|
/** @typedef {readonly Item[]} ItemArray */
|
|
8
8
|
|
|
9
|
-
/** @typedef {() =>
|
|
9
|
+
/** @typedef {() => list.List<Item>} ItemThunk */
|
|
10
10
|
|
|
11
11
|
/** @typedef {string|ItemArray|ItemThunk} Item */
|
|
12
12
|
|
|
13
|
-
/** @type {(indent: string) => (text: Block) =>
|
|
14
|
-
const flat = indent => {
|
|
13
|
+
/** @type {(indent: string) => (text: Block) => list.List<string>} */
|
|
14
|
+
export const flat = indent => {
|
|
15
15
|
|
|
16
|
-
/** @type {(prefix: string) => (text: Block) =>
|
|
16
|
+
/** @type {(prefix: string) => (text: Block) => list.List<string>} */
|
|
17
17
|
const f = prefix => {
|
|
18
|
-
/** @type {(item: Item) =>
|
|
18
|
+
/** @type {(item: Item) => list.List<string>} */
|
|
19
19
|
const g = item => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item)
|
|
20
20
|
return flatMap(g)
|
|
21
21
|
}
|
|
@@ -24,11 +24,4 @@ const flat = indent => {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** @type {(type: string) => (name: string) => (body: Block) => Block} */
|
|
27
|
-
const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
/** @readonly */
|
|
31
|
-
flat,
|
|
32
|
-
/** @readonly */
|
|
33
|
-
curly,
|
|
34
|
-
}
|
|
27
|
+
export const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
|
package/text/sgr/module.f.d.mts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { sgr };
|
|
3
|
-
export let reset: string;
|
|
4
|
-
export let bold: string;
|
|
5
|
-
export let fgRed: string;
|
|
6
|
-
export let fgGreen: string;
|
|
7
|
-
}
|
|
8
|
-
export default _default;
|
|
9
1
|
/**
|
|
10
2
|
* https://en.wikipedia.org/wiki/ANSI_escape_code#SGR
|
|
11
3
|
*
|
|
12
4
|
* @type {(c: number) => string}
|
|
13
5
|
*/
|
|
14
|
-
|
|
6
|
+
export const sgr: (c: number) => string;
|
|
7
|
+
export namespace codes {
|
|
8
|
+
let reset: string;
|
|
9
|
+
let bold: string;
|
|
10
|
+
let fgRed: string;
|
|
11
|
+
let fgGreen: string;
|
|
12
|
+
}
|
package/text/sgr/module.f.mjs
CHANGED
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @type {(c: number) => string}
|
|
7
7
|
*/
|
|
8
|
-
const sgr = c => `\x1b[${c.toString()}m`
|
|
8
|
+
export const sgr = c => `\x1b[${c.toString()}m`
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
/** @readonly */
|
|
12
|
-
sgr,
|
|
10
|
+
export const codes = {
|
|
13
11
|
/** @readonly */
|
|
14
12
|
reset: sgr(0),
|
|
15
13
|
/** @readonly */
|
package/text/test.f.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import string from '../types/string/module.f.mjs'
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
|
+
import * as string from '../types/string/module.f.mjs'
|
|
3
3
|
const { join } = string
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
|
-
/** @type {
|
|
6
|
+
/** @type {_.Block} */
|
|
7
7
|
const text = [
|
|
8
8
|
'a',
|
|
9
9
|
'b',
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export
|
|
1
|
+
export const fromCodePointList: (input: list.List<number>) => list.Thunk<number>;
|
|
2
|
+
/** @type {(input: list.List<u16>) => list.List<i32>} */
|
|
3
|
+
export const toCodePointList: (input: list.List<u16>) => list.List<i32>;
|
|
4
|
+
/** @type {(s: string) => list.List<u16>} */
|
|
5
|
+
export const stringToList: (s: string) => list.List<u16>;
|
|
6
|
+
/** @type {(input: list.List<u16>) => string} */
|
|
7
|
+
export const listToString: (input: list.List<u16>) => string;
|
|
8
8
|
export type WordOrEof = u16 | null;
|
|
9
9
|
export type Utf16State = number | null;
|
|
10
10
|
export type u16 = number;
|
|
11
11
|
export type i32 = number;
|
|
12
|
-
|
|
13
|
-
/** @type {(input: List.List<u16>) => List.List<i32>} */
|
|
14
|
-
declare const toCodePointList: (input: List.List<u16>) => List.List<i32>;
|
|
15
|
-
/** @type {(s: string) => List.List<u16>} */
|
|
16
|
-
declare const stringToList: (s: string) => List.List<u16>;
|
|
17
|
-
/** @type {(input: List.List<u16>) => string} */
|
|
18
|
-
declare const listToString: (input: List.List<u16>) => string;
|
|
19
|
-
import * as List from '../../types/list/module.f.mjs';
|
|
12
|
+
import * as list from '../../types/list/module.f.mjs';
|
package/text/utf16/module.f.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import range from '../../types/range/module.f.mjs'
|
|
2
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
3
|
+
import * as operator from '../../types/function/operator/module.f.mjs'
|
|
4
|
+
import * as range from '../../types/range/module.f.mjs'
|
|
5
5
|
const { contains } = range
|
|
6
|
-
import f from '../../types/function/module.f.mjs'
|
|
6
|
+
import * as f from '../../types/function/module.f.mjs'
|
|
7
7
|
const { fn } = f
|
|
8
8
|
const { map, flat, stateScan, reduce, flatMap, empty } = list
|
|
9
9
|
|
|
@@ -32,7 +32,7 @@ const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
|
|
|
32
32
|
/** @type {(a: i32) => boolean} */
|
|
33
33
|
const isSupplementaryPlane = contains([0x01_0000, 0x10_ffff])
|
|
34
34
|
|
|
35
|
-
/** @type {(input: i32) =>
|
|
35
|
+
/** @type {(input: i32) => list.List<u16>} */
|
|
36
36
|
const codePointToUtf16 = codePoint => {
|
|
37
37
|
if (isBmpCodePoint(codePoint)) { return [codePoint] }
|
|
38
38
|
if (isSupplementaryPlane(codePoint)) {
|
|
@@ -44,11 +44,11 @@ const codePointToUtf16 = codePoint => {
|
|
|
44
44
|
return [codePoint & 0xffff]
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const fromCodePointList = flatMap(codePointToUtf16)
|
|
47
|
+
export const fromCodePointList = flatMap(codePointToUtf16)
|
|
48
48
|
|
|
49
49
|
const u16 = contains([0x0000, 0xFFFF])
|
|
50
50
|
|
|
51
|
-
/** @type {
|
|
51
|
+
/** @type {operator.StateScan<u16, Utf16State, list.List<i32>>} */
|
|
52
52
|
const utf16ByteToCodePointOp = state => word => {
|
|
53
53
|
if (!u16(word)) {
|
|
54
54
|
return [[0xffffffff], state]
|
|
@@ -68,21 +68,21 @@ const utf16ByteToCodePointOp = state => word => {
|
|
|
68
68
|
return [[state | errorMask, word | errorMask], null]
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/** @type {(state: Utf16State) => readonly[
|
|
71
|
+
/** @type {(state: Utf16State) => readonly[list.List<i32>, Utf16State]} */
|
|
72
72
|
const utf16EofToCodePointOp = state => [state === null ? empty : [state | errorMask], null]
|
|
73
73
|
|
|
74
|
-
/** @type {
|
|
74
|
+
/** @type {operator.StateScan<WordOrEof, Utf16State, list.List<i32>>} */
|
|
75
75
|
const utf16ByteOrEofToCodePointOp = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
|
|
76
76
|
|
|
77
|
-
/** @type {
|
|
77
|
+
/** @type {list.List<WordOrEof>} */
|
|
78
78
|
const eofList = [null]
|
|
79
79
|
|
|
80
|
-
/** @type {(input:
|
|
81
|
-
const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
|
|
80
|
+
/** @type {(input: list.List<u16>) => list.List<i32>} */
|
|
81
|
+
export const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
|
|
82
82
|
|
|
83
|
-
/** @type {(s: string) =>
|
|
84
|
-
const stringToList = s => {
|
|
85
|
-
/** @type {(i: number) =>
|
|
83
|
+
/** @type {(s: string) => list.List<u16>} */
|
|
84
|
+
export const stringToList = s => {
|
|
85
|
+
/** @type {(i: number) => list.Result<number>} */
|
|
86
86
|
const at = i => {
|
|
87
87
|
const first = s.charCodeAt(i)
|
|
88
88
|
return isNaN(first) ? empty : { first, tail: () => at(i + 1) }
|
|
@@ -90,18 +90,7 @@ const stringToList = s => {
|
|
|
90
90
|
return at(0)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
/** @type {(input:
|
|
94
|
-
const listToString = fn(map(String.fromCharCode))
|
|
93
|
+
/** @type {(input: list.List<u16>) => string} */
|
|
94
|
+
export const listToString = fn(map(String.fromCharCode))
|
|
95
95
|
.then(reduce(operator.concat)(''))
|
|
96
96
|
.result
|
|
97
|
-
|
|
98
|
-
export default {
|
|
99
|
-
/** @readonly */
|
|
100
|
-
fromCodePointList,
|
|
101
|
-
/** @readonly */
|
|
102
|
-
toCodePointList,
|
|
103
|
-
/** @readonly */
|
|
104
|
-
stringToList,
|
|
105
|
-
/** @readonly */
|
|
106
|
-
listToString
|
|
107
|
-
}
|