functionalscript 0.1.596 → 0.1.598
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/README.md +0 -2
- package/com/cpp/module.f.d.mts +4 -4
- package/com/cpp/module.f.mjs +18 -18
- package/com/cs/module.f.mjs +1 -1
- package/com/rust/module.f.d.mts +7 -7
- package/com/rust/module.f.mjs +30 -30
- package/com/test/build.mjs +2 -2
- package/com/types/module.f.mjs +1 -1
- package/commonjs/module/module.f.mjs +1 -1
- package/commonjs/package/dependencies/module.f.d.mts +3 -3
- package/commonjs/package/dependencies/module.f.mjs +3 -3
- package/commonjs/package/module.f.d.mts +6 -6
- package/commonjs/package/module.f.mjs +4 -4
- package/commonjs/path/module.f.d.mts +7 -7
- package/commonjs/path/module.f.mjs +5 -5
- package/commonjs/path/test.f.mjs +7 -7
- package/commonjs/test.mjs +2 -2
- package/djs/module.f.mjs +1 -1
- package/djs/tokenizer/module.f.mjs +1 -1
- package/djs/tokenizer/test.f.mjs +1 -1
- package/html/module.f.mjs +1 -1
- package/js/tokenizer/test.f.mjs +3 -3
- package/json/parser/module.f.d.mts +3 -3
- package/json/parser/module.f.mjs +12 -12
- package/json/parser/test.f.mjs +2 -2
- package/json/serializer/module.f.mjs +2 -2
- package/json/tokenizer/module.f.d.mts +3 -3
- package/json/tokenizer/module.f.mjs +7 -7
- package/json/tokenizer/test.f.mjs +3 -3
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/secp/module.f.d.mts +8 -8
- package/secp/module.f.mjs +6 -6
- package/secp/test.f.mjs +5 -5
- package/sha2/module.f.mjs +1 -1
- package/sha2/test.f.mjs +0 -1
- package/text/utf16/test.f.mjs +2 -2
- package/text/utf8/module.f.d.mts +2 -2
- package/text/utf8/module.f.mjs +2 -2
- package/types/bigint/module.f.d.mts +8 -8
- package/types/bigint/module.f.mjs +5 -5
- package/types/btree/find/module.f.mjs +4 -4
- package/types/btree/find/test.f.mjs +2 -2
- package/types/btree/remove/module.f.d.mts +7 -7
- package/types/btree/remove/module.f.mjs +12 -12
- package/types/btree/remove/test.f.mjs +5 -5
- package/types/btree/set/module.f.d.mts +3 -3
- package/types/btree/set/module.f.mjs +6 -6
- package/types/btree/set/test.f.mjs +32 -32
- package/types/btree/test.f.mjs +7 -11
- package/types/byte_set/module.f.mjs +2 -2
- package/types/byte_set/test.f.mjs +3 -3
- package/types/function/compare/module.f.d.mts +7 -7
- package/types/function/compare/module.f.mjs +4 -4
- package/types/map/module.f.d.mts +2 -2
- package/types/map/module.f.mjs +4 -4
- package/types/range_map/module.f.d.mts +2 -2
- package/types/range_map/module.f.mjs +5 -5
- package/types/range_map/test.f.mjs +2 -2
- package/types/sorted_list/test.f.mjs +2 -2
- package/types/sorted_set/test.f.mjs +1 -1
package/html/module.f.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import list, * as List from '../types/list/module.f.mjs'
|
|
|
2
2
|
const { map, flatMap, flat, concat: listConcat } = list
|
|
3
3
|
import s from '../types/string/module.f.mjs'
|
|
4
4
|
const { concat: stringConcat } = s
|
|
5
|
-
import
|
|
5
|
+
import * as O from '../types/object/module.f.mjs'
|
|
6
6
|
import f from '../types/function/module.f.mjs'
|
|
7
7
|
const { compose } = f
|
|
8
8
|
import utf16 from '../text/utf16/module.f.mjs'
|
package/js/tokenizer/test.f.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import tokenizer, * as
|
|
1
|
+
import tokenizer, * as Tokenizer from './module.f.mjs'
|
|
2
2
|
import list from '../../types/list/module.f.mjs'
|
|
3
|
-
const { toArray
|
|
3
|
+
const { toArray } = list
|
|
4
4
|
import djs from '../../djs/module.f.mjs'
|
|
5
5
|
import o from '../../types/object/module.f.mjs'
|
|
6
6
|
const { sort } = o
|
|
7
7
|
import encoding from '../../text/utf16/module.f.mjs'
|
|
8
8
|
|
|
9
|
-
/** @type {(s: string) => readonly
|
|
9
|
+
/** @type {(s: string) => readonly Tokenizer.JsToken[]} */
|
|
10
10
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
11
11
|
|
|
12
12
|
const stringify = djs.stringify(sort)
|
|
@@ -27,10 +27,10 @@ export type StateError = {
|
|
|
27
27
|
readonly message: string;
|
|
28
28
|
};
|
|
29
29
|
export type JsonState = StateParse | StateResult | StateError;
|
|
30
|
-
/** @type {(tokenList: List.List<
|
|
31
|
-
declare const parse: (tokenList: List.List<
|
|
30
|
+
/** @type {(tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>} */
|
|
31
|
+
declare const parse: (tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>;
|
|
32
32
|
import * as Map from '../../types/map/module.f.mjs';
|
|
33
33
|
import * as Json from '../module.f.mjs';
|
|
34
34
|
import * as List from '../../types/list/module.f.mjs';
|
|
35
|
-
import * as
|
|
35
|
+
import * as Tokenizer from '../tokenizer/module.f.mjs';
|
|
36
36
|
import * as Result from '../../types/result/module.f.mjs';
|
package/json/parser/module.f.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import result, * as Result from '../../types/result/module.f.mjs'
|
|
|
2
2
|
import list, * as List from '../../types/list/module.f.mjs'
|
|
3
3
|
const { fold, first, drop, toArray } = list
|
|
4
4
|
import * as Operator from '../../types/function/operator/module.f.mjs'
|
|
5
|
-
import * as
|
|
5
|
+
import * as Tokenizer from '../tokenizer/module.f.mjs'
|
|
6
6
|
import map, * as Map from '../../types/map/module.f.mjs'
|
|
7
7
|
const { setReplace } = map
|
|
8
8
|
import * as Json from '../module.f.mjs'
|
|
@@ -114,7 +114,7 @@ const endObject = state => {
|
|
|
114
114
|
return pushValue(newState)(obj)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/** @type {(token:
|
|
117
|
+
/** @type {(token: Tokenizer.JsonToken) => Json.Unknown} */
|
|
118
118
|
const tokenToValue = token => {
|
|
119
119
|
switch (token.kind) {
|
|
120
120
|
case 'null': return null
|
|
@@ -126,7 +126,7 @@ const tokenToValue = token => {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/** @type {(token:
|
|
129
|
+
/** @type {(token: Tokenizer.JsonToken) => boolean} */
|
|
130
130
|
const isValueToken = token => {
|
|
131
131
|
switch (token.kind) {
|
|
132
132
|
case 'null':
|
|
@@ -138,7 +138,7 @@ const isValueToken = token => {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/** @type {(token:
|
|
141
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
142
142
|
const parseValueOp = token => state => {
|
|
143
143
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
144
144
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -146,7 +146,7 @@ const parseValueOp = token => state => {
|
|
|
146
146
|
return { status: 'error', message: 'unexpected token' }
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
/** @type {(token:
|
|
149
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
150
150
|
const parseArrayStartOp = token => state => {
|
|
151
151
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
152
152
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -155,40 +155,40 @@ const parseArrayStartOp = token => state => {
|
|
|
155
155
|
return { status: 'error', message: 'unexpected token' }
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
/** @type {(token:
|
|
158
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
159
159
|
const parseArrayValueOp = token => state => {
|
|
160
160
|
if (token.kind === ']') { return endArray(state) }
|
|
161
161
|
if (token.kind === ',') { return { status: '[,', top: state.top, stack: state.stack } }
|
|
162
162
|
return { status: 'error', message: 'unexpected token' }
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
/** @type {(token:
|
|
165
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
166
166
|
const parseObjectStartOp = token => state => {
|
|
167
167
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
168
168
|
if (token.kind === '}') { return endObject(state) }
|
|
169
169
|
return { status: 'error', message: 'unexpected token' }
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
/** @type {(token:
|
|
172
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
173
173
|
const parseObjectKeyOp = token => state => {
|
|
174
174
|
if (token.kind === ':') { return { status: '{:', top: state.top, stack: state.stack } }
|
|
175
175
|
return { status: 'error', message: 'unexpected token' }
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/** @type {(token:
|
|
178
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
179
179
|
const parseObjectNextOp = token => state => {
|
|
180
180
|
if (token.kind === '}') { return endObject(state) }
|
|
181
181
|
if (token.kind === ',') { return { status: '{,', top: state.top, stack: state.stack } }
|
|
182
182
|
return { status: 'error', message: 'unexpected token' }
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
/** @type {(token:
|
|
185
|
+
/** @type {(token: Tokenizer.JsonToken) => (state: StateParse) => JsonState}} */
|
|
186
186
|
const parseObjectCommaOp = token => state => {
|
|
187
187
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
188
188
|
return { status: 'error', message: 'unexpected token' }
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
/** @type {Operator.Fold<
|
|
191
|
+
/** @type {Operator.Fold<Tokenizer.JsonToken, JsonState>} */
|
|
192
192
|
const foldOp = token => state => {
|
|
193
193
|
switch (state.status) {
|
|
194
194
|
case 'result': return { status: 'error', message: 'unexpected token' }
|
|
@@ -205,7 +205,7 @@ const foldOp = token => state => {
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
/** @type {(tokenList: List.List<
|
|
208
|
+
/** @type {(tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>} */
|
|
209
209
|
const parse = tokenList => {
|
|
210
210
|
const state = fold(foldOp)({ status: '', top: null, stack: null })(tokenList)
|
|
211
211
|
switch (state.status) {
|
package/json/parser/test.f.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parser from './module.f.mjs'
|
|
2
|
-
import tokenizer, * as
|
|
2
|
+
import tokenizer, * as Tokenizer from '../tokenizer/module.f.mjs'
|
|
3
3
|
import list from '../../types/list/module.f.mjs'
|
|
4
4
|
const { toArray } = list
|
|
5
5
|
import json from '../module.f.mjs'
|
|
@@ -7,7 +7,7 @@ import o from '../../types/object/module.f.mjs'
|
|
|
7
7
|
const { sort } = o
|
|
8
8
|
import encoding from '../../text/utf16/module.f.mjs'
|
|
9
9
|
|
|
10
|
-
/** @type {(s: string) => readonly
|
|
10
|
+
/** @type {(s: string) => readonly Tokenizer.JsonToken[]} */
|
|
11
11
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
12
12
|
|
|
13
13
|
const stringify = json.stringify(sort)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import list, * as List from '../../types/list/module.f.mjs'
|
|
2
2
|
const { flat, reduce, empty } = list
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import * as O from '../../types/object/module.f.mjs'
|
|
4
|
+
import * as Operator from '../../types/function/operator/module.f.mjs'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @template T
|
|
@@ -6,12 +6,12 @@ export type JsonToken = {
|
|
|
6
6
|
readonly kind: "true" | "false" | "null";
|
|
7
7
|
} | {
|
|
8
8
|
readonly kind: "{" | "}" | ":" | "," | "[" | "]";
|
|
9
|
-
} |
|
|
9
|
+
} | JsTokenizer.StringToken | JsTokenizer.NumberToken | JsTokenizer.ErrorToken;
|
|
10
10
|
export type ScanState = {
|
|
11
11
|
readonly kind: "def" | "-";
|
|
12
12
|
};
|
|
13
|
-
export type ScanInput =
|
|
13
|
+
export type ScanInput = JsTokenizer.JsToken | null;
|
|
14
14
|
/** @type {(input: List.List<number>) => List.List<JsonToken>} */
|
|
15
15
|
declare const tokenize: (input: List.List<number>) => List.List<JsonToken>;
|
|
16
|
-
import * as
|
|
16
|
+
import * as JsTokenizer from '../../js/tokenizer/module.f.mjs';
|
|
17
17
|
import * as List from '../../types/list/module.f.mjs';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Operator from '../../types/function/operator/module.f.mjs'
|
|
2
2
|
import list, * as List from '../../types/list/module.f.mjs'
|
|
3
3
|
const { empty, flat, stateScan } = list
|
|
4
4
|
import bf from '../../types/bigfloat/module.f.mjs'
|
|
5
5
|
const { multiply } = bf
|
|
6
|
-
import jsTokenizer, * as
|
|
6
|
+
import jsTokenizer, * as JsTokenizer from '../../js/tokenizer/module.f.mjs'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {|
|
|
10
10
|
* {readonly kind: 'true' | 'false' | 'null' } |
|
|
11
11
|
* {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' } |
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* JsTokenizer.StringToken |
|
|
13
|
+
* JsTokenizer.NumberToken |
|
|
14
|
+
* JsTokenizer.ErrorToken
|
|
15
15
|
* } JsonToken
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -23,11 +23,11 @@ import jsTokenizer, * as jsTokenizerT from '../../js/tokenizer/module.f.mjs'
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* @typedef {|
|
|
26
|
-
*
|
|
26
|
+
* JsTokenizer.JsToken | null
|
|
27
27
|
* } ScanInput
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
/** @type {(input:
|
|
30
|
+
/** @type {(input: JsTokenizer.JsToken) => List.List<JsonToken>} */
|
|
31
31
|
const mapToken = input =>
|
|
32
32
|
{
|
|
33
33
|
switch(input.kind)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import tokenizer, * as
|
|
1
|
+
import tokenizer, * as Tokenizer from './module.f.mjs'
|
|
2
2
|
import list from '../../types/list/module.f.mjs'
|
|
3
|
-
const { toArray
|
|
3
|
+
const { toArray } = list
|
|
4
4
|
import djs from '../../djs/module.f.mjs'
|
|
5
5
|
import o from '../../types/object/module.f.mjs'
|
|
6
6
|
const { sort } = o
|
|
7
7
|
import encoding from '../../text/utf16/module.f.mjs'
|
|
8
8
|
|
|
9
|
-
/** @type {(s: string) => readonly
|
|
9
|
+
/** @type {(s: string) => readonly Tokenizer.JsonToken[]} */
|
|
10
10
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
11
11
|
|
|
12
12
|
const stringify = djs.stringify(sort)
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/secp/module.f.d.mts
CHANGED
|
@@ -14,12 +14,12 @@ export type Init = {
|
|
|
14
14
|
readonly n: bigint;
|
|
15
15
|
};
|
|
16
16
|
export type Curve = {
|
|
17
|
-
readonly pf:
|
|
18
|
-
readonly nf:
|
|
17
|
+
readonly pf: Pf.PrimeField;
|
|
18
|
+
readonly nf: Pf.PrimeField;
|
|
19
19
|
readonly y2: (x: bigint) => bigint;
|
|
20
20
|
readonly y: (x: bigint) => bigint | null;
|
|
21
21
|
readonly neg: (a: Point) => Point;
|
|
22
|
-
readonly add:
|
|
22
|
+
readonly add: Operator.Reduce<Point>;
|
|
23
23
|
readonly mul: (a: Point) => (n: bigint) => Point;
|
|
24
24
|
};
|
|
25
25
|
/** @typedef {readonly[bigint, bigint]} Point2D */
|
|
@@ -34,16 +34,16 @@ export type Curve = {
|
|
|
34
34
|
*/
|
|
35
35
|
/**
|
|
36
36
|
* @typedef {{
|
|
37
|
-
* readonly pf:
|
|
38
|
-
* readonly nf:
|
|
37
|
+
* readonly pf: Pf.PrimeField
|
|
38
|
+
* readonly nf: Pf.PrimeField
|
|
39
39
|
* readonly y2: (x: bigint) => bigint
|
|
40
40
|
* readonly y: (x: bigint) => bigint|null
|
|
41
41
|
* readonly neg: (a: Point) => Point
|
|
42
|
-
* readonly add:
|
|
42
|
+
* readonly add: Operator.Reduce<Point>
|
|
43
43
|
* readonly mul: (a: Point) => (n: bigint) => Point
|
|
44
44
|
* }} Curve
|
|
45
45
|
*/
|
|
46
46
|
/** @type {(i: Init) => Curve} */
|
|
47
47
|
declare const curve: (i: Init) => Curve;
|
|
48
|
-
import * as
|
|
49
|
-
import * as
|
|
48
|
+
import * as Pf from '../prime_field/module.f.mjs';
|
|
49
|
+
import * as Operator from '../types/function/operator/module.f.mjs';
|
package/secp/module.f.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import pf, * as
|
|
1
|
+
import * as Operator from '../types/function/operator/module.f.mjs'
|
|
2
|
+
import pf, * as Pf from '../prime_field/module.f.mjs'
|
|
3
3
|
import bi from '../types/bigint/module.f.mjs'
|
|
4
4
|
const { scalar_mul } = bi
|
|
5
5
|
const { prime_field, sqrt } = pf
|
|
@@ -19,12 +19,12 @@ const { prime_field, sqrt } = pf
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @typedef {{
|
|
22
|
-
* readonly pf:
|
|
23
|
-
* readonly nf:
|
|
22
|
+
* readonly pf: Pf.PrimeField
|
|
23
|
+
* readonly nf: Pf.PrimeField
|
|
24
24
|
* readonly y2: (x: bigint) => bigint
|
|
25
25
|
* readonly y: (x: bigint) => bigint|null
|
|
26
26
|
* readonly neg: (a: Point) => Point
|
|
27
|
-
* readonly add:
|
|
27
|
+
* readonly add: Operator.Reduce<Point>
|
|
28
28
|
* readonly mul: (a: Point) => (n: bigint) => Point
|
|
29
29
|
* }} Curve
|
|
30
30
|
*/
|
|
@@ -41,7 +41,7 @@ const curve = ({ p, a: [a0, a1], n }) => {
|
|
|
41
41
|
// y**2 = a1*x**3 + a0
|
|
42
42
|
/** @type {(x: bigint) => bigint} */
|
|
43
43
|
const y2 = x => addA0(add(pow3(x))(mulA1(x)))
|
|
44
|
-
/** @type {
|
|
44
|
+
/** @type {Operator.Reduce<Point>} */
|
|
45
45
|
const addPoint = p => q => {
|
|
46
46
|
if (p === null) {
|
|
47
47
|
return q
|
package/secp/test.f.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { curve, secp256k1, secp192r1, eq } =
|
|
1
|
+
import _, * as T from './module.f.mjs'
|
|
2
|
+
const { curve, secp256k1, secp192r1, eq } = _
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
test: () => {
|
|
6
|
-
/** @type {(c:
|
|
6
|
+
/** @type {(c: T.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: T.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: T.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.mjs
CHANGED
package/sha2/test.f.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import _ from './module.f.mjs'
|
|
|
2
2
|
import json, * as jsonT from '../json/module.f.mjs'
|
|
3
3
|
import o from '../types/object/module.f.mjs'
|
|
4
4
|
const { sort } = o
|
|
5
|
-
import list from '../types/list/module.f.mjs'
|
|
6
5
|
|
|
7
6
|
/** @type {(a: number) => number} */
|
|
8
7
|
const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
|
package/text/utf16/test.f.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import encoding from './module.f.mjs'
|
|
2
|
-
import json, * as
|
|
2
|
+
import json, * as Json from '../../json/module.f.mjs'
|
|
3
3
|
import o from '../../types/object/module.f.mjs'
|
|
4
4
|
const { sort } = o
|
|
5
5
|
import list from '../../types/list/module.f.mjs'
|
|
6
6
|
|
|
7
|
-
/** @type {(a: readonly
|
|
7
|
+
/** @type {(a: readonly Json.Unknown[]) => string} */
|
|
8
8
|
const stringify = a => json.stringify(sort)(a)
|
|
9
9
|
|
|
10
10
|
export default {
|
package/text/utf8/module.f.d.mts
CHANGED
|
@@ -4,12 +4,12 @@ declare namespace _default {
|
|
|
4
4
|
}
|
|
5
5
|
export default _default;
|
|
6
6
|
export type ByteOrEof = u8 | null;
|
|
7
|
-
export type Utf8NonEmptyState =
|
|
7
|
+
export type Utf8NonEmptyState = Array.Array1<number> | Array.Array2<number> | Array.Array3<number>;
|
|
8
8
|
export type Utf8State = null | Utf8NonEmptyState;
|
|
9
9
|
export type u8 = number;
|
|
10
10
|
export type i32 = number;
|
|
11
11
|
declare const fromCodePointList: (input: List.List<number>) => List.Thunk<number>;
|
|
12
12
|
/** @type {(input: List.List<u8>) => List.List<i32>} */
|
|
13
13
|
declare const toCodePointList: (input: List.List<u8>) => List.List<i32>;
|
|
14
|
-
import * as
|
|
14
|
+
import * as Array from '../../types/array/module.f.mjs';
|
|
15
15
|
import * as List from '../../types/list/module.f.mjs';
|
package/text/utf8/module.f.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import list, * as List from '../../types/list/module.f.mjs'
|
|
2
2
|
import * as operator from '../../types/function/operator/module.f.mjs'
|
|
3
|
-
import * as
|
|
3
|
+
import * as Array from '../../types/array/module.f.mjs'
|
|
4
4
|
const { flatMap, flat, stateScan } = list
|
|
5
5
|
|
|
6
6
|
/** @typedef {u8|null} ByteOrEof */
|
|
7
7
|
|
|
8
|
-
/** @typedef {
|
|
8
|
+
/** @typedef {Array.Array1<number>|Array.Array2<number>|Array.Array3<number>} Utf8NonEmptyState */
|
|
9
9
|
|
|
10
10
|
/** @typedef {null|Utf8NonEmptyState} Utf8State */
|
|
11
11
|
|
|
@@ -9,26 +9,26 @@ declare namespace _default {
|
|
|
9
9
|
export { bitLength };
|
|
10
10
|
}
|
|
11
11
|
export default _default;
|
|
12
|
-
export type Unary =
|
|
12
|
+
export type Unary = Operator.Unary<bigint, bigint>;
|
|
13
13
|
export type Additive<T> = {
|
|
14
14
|
readonly 0: T;
|
|
15
|
-
readonly add:
|
|
15
|
+
readonly add: Operator.Reduce<T>;
|
|
16
16
|
};
|
|
17
|
-
/** @typedef {
|
|
17
|
+
/** @typedef {Operator.Unary<bigint, bigint>} Unary*/
|
|
18
18
|
/** @type {(a: bigint) => (b: bigint) => bigint} */
|
|
19
19
|
declare const addition: (a: bigint) => (b: bigint) => bigint;
|
|
20
20
|
declare const sum: (input: import("../list/module.f.mjs").List<bigint>) => bigint;
|
|
21
21
|
/** @type {(a: bigint) => bigint} */
|
|
22
22
|
declare const abs: (a: bigint) => bigint;
|
|
23
|
-
/** @type {(a: bigint) =>
|
|
24
|
-
declare const sign: (a: bigint) =>
|
|
23
|
+
/** @type {(a: bigint) => Compare.Sign} */
|
|
24
|
+
declare const sign: (a: bigint) => Compare.Sign;
|
|
25
25
|
/** @type {(a: bigint) => string} */
|
|
26
26
|
declare const serialize: (a: bigint) => string;
|
|
27
27
|
/**
|
|
28
28
|
* @template T
|
|
29
29
|
* @typedef {{
|
|
30
30
|
* readonly 0: T
|
|
31
|
-
* readonly add:
|
|
31
|
+
* readonly add: Operator.Reduce<T>
|
|
32
32
|
* }} Additive
|
|
33
33
|
*/
|
|
34
34
|
/** @type {<T>(a: Additive<T>) => (a: T) => (n: bigint) => T} */
|
|
@@ -73,5 +73,5 @@ declare function log2(v: bigint): bigint;
|
|
|
73
73
|
* and adds `1n` to account for the MSB itself.For negative numbers, the absolute value is used.
|
|
74
74
|
*/
|
|
75
75
|
declare function bitLength(v: bigint): bigint;
|
|
76
|
-
import * as
|
|
77
|
-
import * as
|
|
76
|
+
import * as Operator from '../function/operator/module.f.mjs';
|
|
77
|
+
import * as Compare from '../function/compare/module.f.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import compare, * as
|
|
2
|
-
import
|
|
1
|
+
import compare, * as Compare from '../function/compare/module.f.mjs'
|
|
2
|
+
import * as Operator from '../function/operator/module.f.mjs'
|
|
3
3
|
const { unsafeCmp } = compare
|
|
4
4
|
import list from '../list/module.f.mjs'
|
|
5
5
|
const { reduce } = list
|
|
6
6
|
|
|
7
|
-
/** @typedef {
|
|
7
|
+
/** @typedef {Operator.Unary<bigint, bigint>} Unary*/
|
|
8
8
|
|
|
9
9
|
/** @type {(a: bigint) => (b: bigint) => bigint} */
|
|
10
10
|
const addition = a => b => a + b
|
|
@@ -14,7 +14,7 @@ const sum = reduce(addition)(0n)
|
|
|
14
14
|
/** @type {(a: bigint) => bigint} */
|
|
15
15
|
const abs = a => a >= 0 ? a : -a
|
|
16
16
|
|
|
17
|
-
/** @type {(a: bigint) =>
|
|
17
|
+
/** @type {(a: bigint) => Compare.Sign} */
|
|
18
18
|
const sign = a => unsafeCmp(a)(0n)
|
|
19
19
|
|
|
20
20
|
/** @type {(a: bigint) => string} */
|
|
@@ -24,7 +24,7 @@ const serialize = a => `${a}n`
|
|
|
24
24
|
* @template T
|
|
25
25
|
* @typedef {{
|
|
26
26
|
* readonly 0: T
|
|
27
|
-
* readonly add:
|
|
27
|
+
* readonly add: Operator.Reduce<T>
|
|
28
28
|
* }} Additive
|
|
29
29
|
*/
|
|
30
30
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _ from '../types/module.f.mjs'
|
|
2
|
-
import
|
|
2
|
+
import * as List from '../../list/module.f.mjs'
|
|
3
3
|
import cmp, * as cmpT from '../../function/compare/module.f.mjs'
|
|
4
4
|
const { index3, index5 } = cmp
|
|
5
|
-
import
|
|
5
|
+
import * as Array from '../../array/module.f.mjs'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @template T
|
|
@@ -68,12 +68,12 @@ const find = c => {
|
|
|
68
68
|
/** @typedef {typeof c extends cmpT.Compare<infer T> ? T : never} T */
|
|
69
69
|
/** @type {(prior: Path<T>) => (node: _.Node<T>) => Result<T>} */
|
|
70
70
|
const f = tail => node => {
|
|
71
|
-
/** @type {(index:
|
|
71
|
+
/** @type {(index: Array.KeyOf<typeof node>) => Result<T>} */
|
|
72
72
|
const append = index => {
|
|
73
73
|
const first = /** @type {PathItem<T>} */([index, node])
|
|
74
74
|
return f({ first, tail })(child(first))
|
|
75
75
|
}
|
|
76
|
-
/** @type {(index:
|
|
76
|
+
/** @type {(index: Array.KeyOf<typeof node>) => Result<T>} */
|
|
77
77
|
const done = index => ({ first: /** @type {First<T>} */([index, node]), tail })
|
|
78
78
|
switch (node.length) {
|
|
79
79
|
case 1: { return done(i3(node[0])) }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _, * as T from './module.f.mjs'
|
|
2
2
|
import list from '../../list/module.f.mjs'
|
|
3
|
-
import json, * as
|
|
3
|
+
import json, * as Json from '../../../json/module.f.mjs'
|
|
4
4
|
import o from '../../object/module.f.mjs'
|
|
5
5
|
const { sort } = o
|
|
6
6
|
import * as btree from '../types/module.f.mjs'
|
|
@@ -13,7 +13,7 @@ const jsonStr = json.stringify(sort)
|
|
|
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<
|
|
16
|
+
/** @type {(r: T.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} */
|
|
@@ -6,14 +6,14 @@ export default _default;
|
|
|
6
6
|
export type Leaf01<T> = null | _.Leaf1<T>;
|
|
7
7
|
export type RemovePath<T> = {
|
|
8
8
|
readonly first: Leaf01<T>;
|
|
9
|
-
readonly tail:
|
|
9
|
+
readonly tail: Find.Path<T>;
|
|
10
10
|
};
|
|
11
11
|
export type Branch<T> = _.Branch1<T> | _.Branch3<T> | _.Branch5<T>;
|
|
12
12
|
export type Merge<A, T> = (a: A) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>;
|
|
13
|
-
/** @type {<T>(c:
|
|
14
|
-
declare const nodeRemove: <T>(c:
|
|
15
|
-
/** @type {<T>(c:
|
|
16
|
-
declare const remove: <T>(c:
|
|
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
17
|
import * as _ from '../types/module.f.mjs';
|
|
18
|
-
import * as
|
|
19
|
-
import * as
|
|
18
|
+
import * as Find from '../find/module.f.mjs';
|
|
19
|
+
import * as Cmp from '../../function/compare/module.f.mjs';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _ from '../types/module.f.mjs'
|
|
2
|
-
import
|
|
3
|
-
import find, * as
|
|
2
|
+
import * as Cmp from '../../function/compare/module.f.mjs'
|
|
3
|
+
import find, * as Find from '../find/module.f.mjs'
|
|
4
4
|
import list from '../../list/module.f.mjs'
|
|
5
5
|
const { fold, concat, next } = list
|
|
6
|
-
import
|
|
6
|
+
import * as Array from '../../array/module.f.mjs'
|
|
7
7
|
import n from '../../nullable/module.f.mjs'
|
|
8
8
|
const { map } = n
|
|
9
9
|
|
|
@@ -16,11 +16,11 @@ const { map } = n
|
|
|
16
16
|
* @template T
|
|
17
17
|
* @typedef {{
|
|
18
18
|
* readonly first: Leaf01<T>,
|
|
19
|
-
* readonly tail:
|
|
19
|
+
* readonly tail: Find.Path<T>
|
|
20
20
|
* }} RemovePath
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/** @type {<T>(tail:
|
|
23
|
+
/** @type {<T>(tail: Find.Path<T>) => (n: _.Node<T>) => readonly[T, RemovePath<T>]} */
|
|
24
24
|
const path = tail => n => {
|
|
25
25
|
switch (n.length) {
|
|
26
26
|
case 1: { return [n[0], { first: null, tail }] }
|
|
@@ -94,10 +94,10 @@ const initValue1 = a => n => {
|
|
|
94
94
|
* @typedef {(a: A) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} Merge
|
|
95
95
|
*/
|
|
96
96
|
|
|
97
|
-
/** @type {<A, T>(ms:
|
|
97
|
+
/** @type {<A, T>(ms: Array.Array2<Merge<A, T>>) => (i: Find.PathItem<T>) => (a: A) => Branch<T>} */
|
|
98
98
|
const reduceX = ms => ([i, n]) => a => {
|
|
99
99
|
const [m0, m2] = ms
|
|
100
|
-
/** @typedef {typeof ms extends
|
|
100
|
+
/** @typedef {typeof ms extends Array.Array2<Merge<infer A, infer T>> ? [A,T] : never} AT */
|
|
101
101
|
/** @typedef {AT[0]} A */
|
|
102
102
|
/** @typedef {AT[1]} T */
|
|
103
103
|
/** @type {(m: Merge<A, T>) => Branch<T>} */
|
|
@@ -116,15 +116,15 @@ const reduce = fold(reduceX([reduceValue0, reduceValue2]))
|
|
|
116
116
|
|
|
117
117
|
const initReduce = reduceX([initValue0, initValue1])
|
|
118
118
|
|
|
119
|
-
/** @type {<T>(c:
|
|
119
|
+
/** @type {<T>(c: Cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>} */
|
|
120
120
|
const nodeRemove = c => node => {
|
|
121
|
-
/** @typedef {typeof c extends
|
|
121
|
+
/** @typedef {typeof c extends Cmp.Compare<infer T> ? T : never} T */
|
|
122
122
|
/** @type {() => null | RemovePath<T>} */
|
|
123
123
|
const f = () => {
|
|
124
124
|
const { first, tail } = find.find(c)(node)
|
|
125
|
-
/** @type {(n: _.Node<T>) => (f: (v: T) =>
|
|
125
|
+
/** @type {(n: _.Node<T>) => (f: (v: T) => Find.PathItem<T>) => RemovePath<T>} */
|
|
126
126
|
const branch = n => f => {
|
|
127
|
-
const [v, p] = path(/** @type {
|
|
127
|
+
const [v, p] = path(/** @type {Find.Path<T>} */(null))(n)
|
|
128
128
|
return { first: p.first, tail: concat(p.tail)({ first: f(v), tail }) }
|
|
129
129
|
}
|
|
130
130
|
const [i, n] = first
|
|
@@ -156,7 +156,7 @@ const nodeRemove = c => node => {
|
|
|
156
156
|
return result.length === 1 ? result[0] : result
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
/** @type {<T>(c:
|
|
159
|
+
/** @type {<T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>} */
|
|
160
160
|
const remove = c => map(nodeRemove(c))
|
|
161
161
|
|
|
162
162
|
export default {
|