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/fsm/module.f.d.mts
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { toUnion };
|
|
6
|
-
}
|
|
7
|
-
export default _default;
|
|
8
|
-
export type Rule = readonly [string, byteSetT.ByteSet, string];
|
|
9
|
-
export type Grammar = List.List<Rule>;
|
|
10
|
-
export type Dfa = { readonly [state in string]: RM.RangeMapArray<string>; };
|
|
1
|
+
/** @type {(s: string) => byteSet.ByteSet} */
|
|
2
|
+
export const toRange: (s: string) => byteSet.ByteSet;
|
|
3
|
+
/** @type {(s: string) => byteSet.ByteSet} */
|
|
4
|
+
export const toUnion: (s: string) => byteSet.ByteSet;
|
|
11
5
|
/** @type {(grammar: Grammar) => Dfa} */
|
|
12
|
-
|
|
13
|
-
/** @type {(dfa: Dfa) => (input:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import * as RM from '../types/range_map/module.f.mjs';
|
|
6
|
+
export const dfa: (grammar: Grammar) => Dfa;
|
|
7
|
+
/** @type {(dfa: Dfa) => (input: list.List<number>) => list.List<string>} */
|
|
8
|
+
export const run: (dfa: Dfa) => (input: list.List<number>) => list.List<string>;
|
|
9
|
+
export type Rule = readonly [string, byteSet.ByteSet, string];
|
|
10
|
+
export type Grammar = list.List<Rule>;
|
|
11
|
+
export type Dfa = { readonly [state in string]: rangeMap.RangeMapArray<string>; };
|
|
12
|
+
import * as byteSet from '../types/byte_set/module.f.mjs';
|
|
13
|
+
import * as list from '../types/list/module.f.mjs';
|
|
14
|
+
import * as rangeMap from '../types/range_map/module.f.mjs';
|
package/fsm/module.f.mjs
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as list from '../types/list/module.f.mjs'
|
|
3
3
|
const { equal, isEmpty, fold, toArray, scan, foldScan, empty: emptyList } = list
|
|
4
|
-
import
|
|
4
|
+
import * as byteSet from '../types/byte_set/module.f.mjs'
|
|
5
5
|
const { toRangeMap, union: byteSetUnion, one, empty } = byteSet
|
|
6
|
-
import
|
|
6
|
+
import * as sortedSet from '../types/sorted_set/module.f.mjs'
|
|
7
7
|
const { intersect, union: sortedSetUnion } = sortedSet
|
|
8
|
-
import
|
|
8
|
+
import * as rangeMap from '../types/range_map/module.f.mjs'
|
|
9
9
|
const { merge } = rangeMap
|
|
10
|
-
import cmp from '../types/function/compare/module.f.mjs'
|
|
10
|
+
import * as cmp from '../types/function/compare/module.f.mjs'
|
|
11
11
|
const { unsafeCmp } = cmp
|
|
12
|
-
import
|
|
12
|
+
import * as operator from '../types/function/operator/module.f.mjs'
|
|
13
13
|
const { strictEqual } = operator
|
|
14
|
-
import j from '../json/module.f.mjs'
|
|
14
|
+
import * as j from '../json/module.f.mjs'
|
|
15
15
|
const { stringify } = j
|
|
16
|
-
import f from '../types/function/module.f.mjs'
|
|
16
|
+
import * as f from '../types/function/module.f.mjs'
|
|
17
17
|
const { identity } = f
|
|
18
|
-
import utf16 from '../text/utf16/module.f.mjs'
|
|
18
|
+
import * as utf16 from '../text/utf16/module.f.mjs'
|
|
19
19
|
const { stringToList } = utf16
|
|
20
20
|
|
|
21
|
-
/** @typedef {readonly[string,
|
|
21
|
+
/** @typedef {readonly[string, byteSet.ByteSet, string]} Rule */
|
|
22
22
|
|
|
23
|
-
/** @typedef {
|
|
23
|
+
/** @typedef {list.List<Rule>} Grammar */
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @typedef {{
|
|
27
|
-
* readonly[state in string]:
|
|
27
|
+
* readonly[state in string]: rangeMap.RangeMapArray<string>
|
|
28
28
|
* }} Dfa
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
const stringifyIdentity = stringify(identity)
|
|
32
32
|
|
|
33
|
-
/** @type {(s: string) =>
|
|
34
|
-
const toRange = s => {
|
|
33
|
+
/** @type {(s: string) => byteSet.ByteSet} */
|
|
34
|
+
export const toRange = s => {
|
|
35
35
|
const [b, e] = toArray(stringToList(s))
|
|
36
36
|
return byteSet.range([b, e])
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/** @type {
|
|
39
|
+
/** @type {operator.Fold<number, byteSet.ByteSet>} */
|
|
40
40
|
const toUnionOp = i => bs => byteSetUnion(bs)(one(i))
|
|
41
41
|
|
|
42
|
-
/** @type {(s: string) =>
|
|
43
|
-
const toUnion = s => {
|
|
42
|
+
/** @type {(s: string) => byteSet.ByteSet} */
|
|
43
|
+
export const toUnion = s => {
|
|
44
44
|
const codePoints = stringToList(s)
|
|
45
45
|
return fold(toUnionOp)(empty)(codePoints)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/** @type {
|
|
48
|
+
/** @type {rangeMap.Operators<sortedSet.SortedSet<string>>} */
|
|
49
49
|
const mergeOp = { union: sortedSetUnion(unsafeCmp), equal: equal(strictEqual) }
|
|
50
50
|
|
|
51
|
-
/** @type {(s: string) => (set:
|
|
51
|
+
/** @type {(s: string) => (set: sortedSet.SortedSet<string>) => boolean} */
|
|
52
52
|
const hasState = s => set => !isEmpty(intersect(unsafeCmp)([s])(set))
|
|
53
53
|
|
|
54
|
-
/** @type {(set:
|
|
54
|
+
/** @type {(set: sortedSet.SortedSet<string>) => operator.Fold<Rule, rangeMap.RangeMap<sortedSet.SortedSet<string>>>} */
|
|
55
55
|
const foldOp = set => ([ruleIn, bs, ruleOut]) => rm => {
|
|
56
56
|
if (hasState(ruleIn)(set)) { return merge(mergeOp)(rm)(toRangeMap(bs)(ruleOut)) }
|
|
57
57
|
return rm
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/** @type {
|
|
60
|
+
/** @type {operator.Scan<rangeMap.Entry<sortedSet.SortedSet<string>>, rangeMap.Entry<string>>} */
|
|
61
61
|
const stringifyOp = ([sortedSet, max]) => [[stringifyIdentity(sortedSet), max], stringifyOp]
|
|
62
62
|
|
|
63
63
|
const scanStringify = scan(stringifyOp)
|
|
64
64
|
|
|
65
|
-
/** @type {
|
|
65
|
+
/** @type {operator.Scan<rangeMap.Entry<sortedSet.SortedSet<string>>, sortedSet.SortedSet<string>>} */
|
|
66
66
|
const fetchOp = ([item, _]) => [item, fetchOp]
|
|
67
67
|
|
|
68
68
|
const scanFetch = scan(fetchOp)
|
|
69
69
|
|
|
70
|
-
/** @type {(grammar: Grammar) =>
|
|
70
|
+
/** @type {(grammar: Grammar) => operator.Fold<sortedSet.SortedSet<string>, Dfa>} */
|
|
71
71
|
const addEntry = grammar => set => dfa => {
|
|
72
72
|
const s = stringifyIdentity(set)
|
|
73
73
|
if (s in dfa) { return dfa }
|
|
@@ -88,23 +88,12 @@ const initialState = ['']
|
|
|
88
88
|
const initialStateStringify = stringifyIdentity(initialState)
|
|
89
89
|
|
|
90
90
|
/** @type {(grammar: Grammar) => Dfa} */
|
|
91
|
-
const dfa = grammar => addEntry(grammar)(initialState)({})
|
|
91
|
+
export const dfa = grammar => addEntry(grammar)(initialState)({})
|
|
92
92
|
|
|
93
93
|
const get = rangeMap.get(emptyStateStringify)
|
|
94
94
|
|
|
95
|
-
/** @type {(dfa: Dfa) =>
|
|
95
|
+
/** @type {(dfa: Dfa) => operator.Fold<number, string>} */
|
|
96
96
|
const runOp = dfa => input => s => get(input)(dfa[s])
|
|
97
97
|
|
|
98
|
-
/** @type {(dfa: Dfa) => (input:
|
|
99
|
-
const run = dfa => input => foldScan(runOp(dfa))(initialStateStringify)(input)
|
|
100
|
-
|
|
101
|
-
export default {
|
|
102
|
-
/** @readonly */
|
|
103
|
-
dfa,
|
|
104
|
-
/** @readonly */
|
|
105
|
-
run,
|
|
106
|
-
/** @readonly */
|
|
107
|
-
toRange,
|
|
108
|
-
/** @readonly */
|
|
109
|
-
toUnion
|
|
110
|
-
}
|
|
98
|
+
/** @type {(dfa: Dfa) => (input: list.List<number>) => list.List<string>} */
|
|
99
|
+
export const run = dfa => input => foldScan(runOp(dfa))(initialStateStringify)(input)
|
package/fsm/test.f.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import byteSet from '../types/byte_set/module.f.mjs'
|
|
3
|
-
import o from '../types/object/module.f.mjs'
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
|
+
import * as byteSet from '../types/byte_set/module.f.mjs'
|
|
3
|
+
import * as o from '../types/object/module.f.mjs'
|
|
4
4
|
const { sort, fromEntries } = o
|
|
5
|
-
import json from '../json/module.f.mjs'
|
|
6
|
-
import f from '../types/function/module.f.mjs'
|
|
5
|
+
import * as json from '../json/module.f.mjs'
|
|
6
|
+
import * as f from '../types/function/module.f.mjs'
|
|
7
7
|
const { identity } = f
|
|
8
|
-
import list from '../types/list/module.f.mjs'
|
|
8
|
+
import * as list from '../types/list/module.f.mjs'
|
|
9
9
|
const { toArray } = list
|
|
10
|
-
import utf16 from '../text/utf16/module.f.mjs'
|
|
10
|
+
import * as utf16 from '../text/utf16/module.f.mjs'
|
|
11
11
|
const { stringToList } = utf16
|
|
12
12
|
|
|
13
13
|
const stringifyIdentity = json.stringify(identity)
|
|
@@ -22,7 +22,7 @@ const buildDfa = () => {
|
|
|
22
22
|
const idNext = byteSet.union(idBegin)(digit)
|
|
23
23
|
const dot = _.toUnion('.')
|
|
24
24
|
|
|
25
|
-
/** @type {
|
|
25
|
+
/** @type {_.Grammar} */
|
|
26
26
|
const grammar = [
|
|
27
27
|
['', digit, 'int'],
|
|
28
28
|
['int', digit, 'int'],
|
package/html/module.f.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export default _default;
|
|
1
|
+
/** @type {(element: Element) => list.List<string>} */
|
|
2
|
+
export const element: (element: Element) => list.List<string>;
|
|
3
|
+
export const html: f.Func<Element, list.List<string>>;
|
|
4
|
+
export const htmlToString: f.Func<Element, string>;
|
|
7
5
|
export type Tag = string;
|
|
8
6
|
export type Element1 = readonly [Tag];
|
|
9
7
|
export type Element2A = readonly [Tag, Attributes];
|
|
@@ -11,10 +9,7 @@ export type Element2N = readonly [Tag, readonly Node[]];
|
|
|
11
9
|
export type Element3 = readonly [Tag, Attributes, Nodes];
|
|
12
10
|
export type Element = Element1 | Element2A | Element2N | Element3;
|
|
13
11
|
export type Attributes = { readonly [k in string]: string; };
|
|
14
|
-
export type Nodes =
|
|
12
|
+
export type Nodes = list.List<Node>;
|
|
15
13
|
export type Node = Element | string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
declare const html: import("../types/function/module.f.mjs").Func<Element, List.List<string>>;
|
|
19
|
-
declare const htmlToString: import("../types/function/module.f.mjs").Func<Element, string>;
|
|
20
|
-
import * as List from '../types/list/module.f.mjs';
|
|
14
|
+
import * as list from '../types/list/module.f.mjs';
|
|
15
|
+
import * as f from '../types/function/module.f.mjs';
|
package/html/module.f.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as list from '../types/list/module.f.mjs'
|
|
3
3
|
const { map, flatMap, flat, concat: listConcat } = list
|
|
4
|
-
import s from '../types/string/module.f.mjs'
|
|
4
|
+
import * as s from '../types/string/module.f.mjs'
|
|
5
5
|
const { concat: stringConcat } = s
|
|
6
6
|
import * as O from '../types/object/module.f.mjs'
|
|
7
|
-
import f from '../types/function/module.f.mjs'
|
|
7
|
+
import * as f from '../types/function/module.f.mjs'
|
|
8
8
|
const { compose } = f
|
|
9
|
-
import utf16 from '../text/utf16/module.f.mjs'
|
|
9
|
+
import * as utf16 from '../text/utf16/module.f.mjs'
|
|
10
10
|
const { stringToList } = utf16
|
|
11
11
|
const { fromCharCode } = String
|
|
12
12
|
const { entries } = Object
|
|
@@ -50,7 +50,7 @@ const isVoid = tag => voidTagList.includes(tag)
|
|
|
50
50
|
* }} Attributes
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
|
-
/** @typedef {
|
|
53
|
+
/** @typedef {list.List<Node>} Nodes */
|
|
54
54
|
|
|
55
55
|
/** @typedef {Element | string} Node */
|
|
56
56
|
|
|
@@ -71,33 +71,33 @@ const escapeCharCode = code => {
|
|
|
71
71
|
|
|
72
72
|
const escape = compose(stringToList)(map(escapeCharCode))
|
|
73
73
|
|
|
74
|
-
/** @type {(n: Node) =>
|
|
74
|
+
/** @type {(n: Node) => list.List<string>} */
|
|
75
75
|
const node = n => typeof n === 'string' ? escape(n) : element(n)
|
|
76
76
|
|
|
77
77
|
const nodes = flatMap(node)
|
|
78
78
|
|
|
79
|
-
/** @type {(a: O.Entry<string>) =>
|
|
79
|
+
/** @type {(a: O.Entry<string>) => list.List<string>} */
|
|
80
80
|
const attribute = ([name, value]) => flat([[' ', name, '="'], escape(value), ['"']])
|
|
81
81
|
|
|
82
|
-
/** @type {(a: Attributes) =>
|
|
82
|
+
/** @type {(a: Attributes) => list.List<string>} */
|
|
83
83
|
const attributes = compose(entries)(flatMap(attribute))
|
|
84
84
|
|
|
85
85
|
const open = (/** @type {Element2A} */[tag, a]) => flat([[`<`, tag], attributes(a), [`>`]])
|
|
86
86
|
|
|
87
87
|
const close = (/** @type {string}*/tag) => ['</', tag, '>']
|
|
88
88
|
|
|
89
|
-
/** @type {(_: Element3) =>
|
|
89
|
+
/** @type {(_: Element3) => list.List<string>} */
|
|
90
90
|
const element3 = ([tag, a, ns]) =>
|
|
91
91
|
flat([open([tag, a]), nodes(ns), close(tag)])
|
|
92
92
|
|
|
93
|
-
/** @type {(_: Element2A) =>
|
|
93
|
+
/** @type {(_: Element2A) => list.List<string>} */
|
|
94
94
|
const element2a = e => {
|
|
95
95
|
const [tag] = e
|
|
96
96
|
return flat([open(e), isVoid(tag) ? [] : close(tag)])
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/** @type {(element: Element) =>
|
|
100
|
-
const element = e => {
|
|
99
|
+
/** @type {(element: Element) => list.List<string>} */
|
|
100
|
+
export const element = e => {
|
|
101
101
|
switch (e.length) {
|
|
102
102
|
case 1: { return element2a([e[0], {}]) }
|
|
103
103
|
case 2: {
|
|
@@ -112,15 +112,6 @@ const element = e => {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
const html = compose(element)(listConcat(['<!DOCTYPE html>']))
|
|
115
|
+
export const html = compose(element)(listConcat(['<!DOCTYPE html>']))
|
|
116
116
|
|
|
117
|
-
const htmlToString = compose(html)(stringConcat)
|
|
118
|
-
|
|
119
|
-
export default {
|
|
120
|
-
/** @readonly */
|
|
121
|
-
element,
|
|
122
|
-
/** @readonly */
|
|
123
|
-
html,
|
|
124
|
-
/** @readonly */
|
|
125
|
-
htmlToString,
|
|
126
|
-
}
|
|
117
|
+
export const htmlToString = compose(html)(stringConcat)
|
package/html/test.f.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
empty: () => {
|
|
@@ -14,19 +14,19 @@ export default {
|
|
|
14
14
|
if (r !== '<!DOCTYPE html><area>') { throw r }
|
|
15
15
|
},
|
|
16
16
|
some: () => {
|
|
17
|
-
/** @type {
|
|
17
|
+
/** @type {_.Element} */
|
|
18
18
|
const x = ['div', {}, ['<div>&</div>', ['a', { href: 'hello"' }, []]]]
|
|
19
19
|
const s = _.htmlToString(x)
|
|
20
20
|
if (s !== '<!DOCTYPE html><div><div>&amp;</div><a href="hello""></a></div>') { throw s }
|
|
21
21
|
},
|
|
22
22
|
some2: () => {
|
|
23
|
-
/** @type {
|
|
23
|
+
/** @type {_.Element} */
|
|
24
24
|
const x = ['div', ['<div>&</div>', ['a', { href: 'hello"' }, []]]]
|
|
25
25
|
const s = _.htmlToString(x)
|
|
26
26
|
if (s !== '<!DOCTYPE html><div><div>&amp;</div><a href="hello""></a></div>') { throw s }
|
|
27
27
|
},
|
|
28
28
|
someVoid: () => {
|
|
29
|
-
/** @type {
|
|
29
|
+
/** @type {_.Element} */
|
|
30
30
|
const x = ['div', [['br', {id: '5'}], '<div>&</div>', ['a', { href: 'hello"' }, []]]]
|
|
31
31
|
const s = _.htmlToString(x)
|
|
32
32
|
if (s !== '<!DOCTYPE html><div><br id="5"><div>&amp;</div><a href="hello""></a></div>') { throw s }
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default _default;
|
|
1
|
+
/** @type {(token: JsToken) => Boolean} */
|
|
2
|
+
export const isKeywordToken: (token: JsToken) => boolean;
|
|
3
|
+
/** @type {(input: list.List<number>) => list.List<JsToken>} */
|
|
4
|
+
export const tokenize: (input: list.List<number>) => list.List<JsToken>;
|
|
6
5
|
export type StringToken = {
|
|
7
6
|
readonly kind: "string";
|
|
8
7
|
readonly value: string;
|
|
@@ -132,12 +131,12 @@ export type EofState = {
|
|
|
132
131
|
readonly kind: "eof";
|
|
133
132
|
};
|
|
134
133
|
export type CharCodeOrEof = number | null;
|
|
135
|
-
export type ToToken = (input: number) => readonly [
|
|
134
|
+
export type ToToken = (input: number) => readonly [list.List<JsToken>, TokenizerState];
|
|
136
135
|
/**
|
|
137
136
|
* <T>
|
|
138
137
|
*/
|
|
139
138
|
export type CreateToToken<T> = (state: T) => ToToken;
|
|
140
|
-
export type RangeSet =
|
|
139
|
+
export type RangeSet = list.List<_range.Range>;
|
|
141
140
|
/**
|
|
142
141
|
* <T>
|
|
143
142
|
*/
|
|
@@ -145,12 +144,8 @@ export type RangeFunc<T> = (def: CreateToToken<T>) => (RangeMapToToken<T>);
|
|
|
145
144
|
/**
|
|
146
145
|
* <T>
|
|
147
146
|
*/
|
|
148
|
-
export type RangeMapToToken<T> =
|
|
149
|
-
|
|
150
|
-
declare const tokenize: (input: List.List<number>) => List.List<JsToken>;
|
|
151
|
-
/** @type {(token: JsToken) => Boolean} */
|
|
152
|
-
declare const isKeywordToken: (token: JsToken) => boolean;
|
|
147
|
+
export type RangeMapToToken<T> = range_map.RangeMapArray<CreateToToken<T>>;
|
|
148
|
+
import * as list from '../../types/list/module.f.mjs';
|
|
153
149
|
import * as bigfloatT from '../../types/bigfloat/module.f.mjs';
|
|
154
|
-
import * as
|
|
155
|
-
import * as
|
|
156
|
-
import * as RangeMap from '../../types/range_map/module.f.mjs';
|
|
150
|
+
import * as _range from '../../types/range/module.f.mjs';
|
|
151
|
+
import * as range_map from '../../types/range_map/module.f.mjs';
|