functionalscript 0.0.592 → 0.1.594
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/.github/workflows/ci.yml +3 -3
- package/README.md +1 -0
- package/com/cpp/{module.f.cjs → module.f.mjs} +22 -21
- package/com/cpp/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.mjs +9 -0
- package/com/cs/{module.f.cjs → module.f.mjs} +20 -19
- package/com/cs/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cs/testlib.f.mjs +10 -0
- package/com/rust/{module.f.cjs → module.f.mjs} +37 -35
- package/com/rust/{test.f.cjs → test.f.mjs} +2 -2
- package/com/rust/testlib.f.mjs +10 -0
- package/com/test/{build.f.cjs → build.f.mjs} +6 -6
- package/com/test/{build.cjs → build.mjs} +16 -8
- package/com/types/{module.f.cjs → module.f.mjs} +9 -8
- package/com/types/{testlib.f.cjs → testlib.f.mjs} +2 -2
- package/commonjs/build/{module.f.cjs → module.f.mjs} +23 -23
- package/commonjs/build/{test.f.cjs → test.f.mjs} +13 -12
- package/commonjs/module/function/{module.f.cjs → module.f.mjs} +4 -4
- package/commonjs/module/{module.f.cjs → module.f.mjs} +3 -5
- package/commonjs/module.f.mjs +11 -0
- package/commonjs/{module.cjs → module.mjs} +8 -6
- package/commonjs/package/dependencies/{module.f.cjs → module.f.mjs} +5 -5
- package/commonjs/package/dependencies/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/package/{module.f.cjs → module.f.mjs} +7 -6
- package/commonjs/package/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/path/{module.f.cjs → module.f.mjs} +15 -14
- package/commonjs/path/{test.f.cjs → test.f.mjs} +16 -14
- package/commonjs/{test.cjs → test.mjs} +4 -4
- package/dev/{module.f.cjs → module.f.mjs} +1 -1
- package/dev/module.mjs +5 -3
- package/dev/test/{module.f.cjs → module.f.mjs} +21 -9
- package/dev/{test.f.cjs → test.f.mjs} +1 -1
- package/dev/test.mjs +1 -1
- package/djs/{module.f.cjs → module.f.mjs} +18 -15
- package/djs/parser/{module.f.cjs → module.f.mjs} +29 -28
- package/djs/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/djs/{test.f.cjs → test.f.mjs} +7 -5
- package/djs/tokenizer/{module.f.cjs → module.f.mjs} +19 -18
- package/djs/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/fsc/{module.f.cjs → module.f.mjs} +17 -16
- package/fsc/{test.f.cjs → test.f.mjs} +6 -4
- package/fsm/{module.f.cjs → module.f.mjs} +28 -24
- package/fsm/{test.f.cjs → test.f.mjs} +13 -9
- package/html/{module.f.cjs → module.f.mjs} +16 -13
- package/html/{test.f.cjs → test.f.mjs} +5 -5
- package/index.f.mjs +45 -35
- package/issues/README.md +15 -0
- package/js/tokenizer/{module.f.cjs → module.f.mjs} +52 -51
- package/js/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/json/{module.f.cjs → module.f.mjs} +18 -17
- package/json/parser/{module.f.cjs → module.f.mjs} +27 -26
- package/json/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/json/serializer/{module.f.cjs → module.f.mjs} +12 -12
- package/json/serializer/{test.f.cjs → test.f.mjs} +4 -3
- package/json/{test.f.cjs → test.f.mjs} +6 -4
- package/json/tokenizer/{module.f.cjs → module.f.mjs} +16 -15
- package/json/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/jsr.json +1 -1
- package/nodejs/version/main.mjs +5 -0
- package/nodejs/version/{module.f.cjs → module.f.mjs} +2 -2
- package/nodejs/version/{test.f.cjs → test.f.mjs} +5 -5
- package/package.json +3 -3
- package/prime_field/{module.f.cjs → module.f.mjs} +6 -5
- package/prime_field/{test.f.cjs → test.f.mjs} +3 -2
- package/secp/{module.f.cjs → module.f.mjs} +7 -6
- package/secp/{test.f.cjs → test.f.mjs} +6 -6
- package/sha2/{module.f.cjs → module.f.mjs} +5 -5
- package/sha2/{test.f.cjs → test.f.mjs} +7 -6
- package/text/ascii/{module.f.cjs → module.f.mjs} +3 -3
- package/text/ascii/test.f.mjs +14 -0
- package/text/{module.f.cjs → module.f.mjs} +6 -6
- package/text/sgr/{module.f.cjs → module.f.mjs} +1 -1
- package/text/{test.f.cjs → test.f.mjs} +5 -4
- package/text/utf16/{module.f.cjs → module.f.mjs} +16 -14
- package/text/utf16/{test.f.cjs → test.f.mjs} +7 -6
- package/text/utf8/{module.f.cjs → module.f.mjs} +11 -11
- package/text/utf8/{test.f.cjs → test.f.mjs} +6 -5
- package/tsconfig.json +2 -2
- package/types/array/{module.f.cjs → module.f.mjs} +2 -2
- package/types/array/{test.f.cjs → test.f.mjs} +5 -4
- package/types/bigfloat/{module.f.cjs → module.f.mjs} +3 -3
- package/types/bigfloat/{test.f.cjs → test.f.mjs} +3 -2
- package/types/bigint/{module.f.cjs → module.f.mjs} +8 -7
- package/types/bigint/{test.f.cjs → test.f.mjs} +3 -2
- package/types/btree/find/{module.f.cjs → module.f.mjs} +12 -12
- package/types/btree/find/{test.f.cjs → test.f.mjs} +11 -9
- package/types/btree/{module.f.cjs → module.f.mjs} +7 -12
- package/types/btree/remove/{module.f.cjs → module.f.mjs} +17 -16
- package/types/btree/remove/{test.f.cjs → test.f.mjs} +9 -7
- package/types/btree/set/{module.f.cjs → module.f.mjs} +9 -9
- package/types/btree/set/{test.f.cjs → test.f.mjs} +8 -6
- package/types/btree/{test.f.cjs → test.f.mjs} +23 -20
- package/types/btree/types/{module.f.cjs → module.f.mjs} +1 -1
- package/types/byte_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/byte_set/{test.f.cjs → test.f.mjs} +8 -7
- package/types/function/compare/{module.f.cjs → module.f.mjs} +2 -2
- package/types/function/compare/{test.f.cjs → test.f.mjs} +3 -2
- package/types/function/{module.f.cjs → module.f.mjs} +1 -5
- package/types/function/operator/{module.f.cjs → module.f.mjs} +1 -1
- package/types/function/{test.f.cjs → test.f.mjs} +4 -2
- package/types/list/{module.f.cjs → module.f.mjs} +12 -12
- package/types/list/{test.f.cjs → test.f.mjs} +13 -11
- package/types/map/{module.f.cjs → module.f.mjs} +21 -18
- package/types/map/{test.f.cjs → test.f.mjs} +5 -4
- package/types/nibble_set/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nibble_set/{test.f.cjs → test.f.mjs} +4 -3
- package/types/nullable/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nullable/{test.f.cjs → test.f.mjs} +2 -2
- package/types/number/module.f.mjs +26 -0
- package/types/number/{test.f.cjs → test.f.mjs} +3 -2
- package/types/object/{module.f.cjs → module.f.mjs} +6 -6
- package/types/object/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range/{module.f.cjs → module.f.mjs} +1 -1
- package/types/range/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range_map/{module.f.cjs → module.f.mjs} +16 -15
- package/types/range_map/{test.f.cjs → test.f.mjs} +35 -33
- package/types/result/{module.f.cjs → module.f.mjs} +1 -1
- package/types/result/{module.cjs → module.mjs} +3 -3
- package/types/sorted_list/{module.f.cjs → module.f.mjs} +11 -10
- package/types/sorted_list/{test.f.cjs → test.f.mjs} +14 -10
- package/types/sorted_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/sorted_set/{test.f.cjs → test.f.mjs} +14 -10
- package/types/string/{module.f.cjs → module.f.mjs} +8 -7
- package/types/string/{test.f.cjs → test.f.mjs} +5 -3
- package/types/string_set/{module.f.cjs → module.f.mjs} +15 -10
- package/types/string_set/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.cjs +0 -6
- package/com/cs/testlib.f.cjs +0 -6
- package/com/module.f.cjs +0 -6
- package/com/rust/testlib.f.cjs +0 -6
- package/commonjs/module.f.cjs +0 -20
- package/nodejs/module.f.cjs +0 -4
- package/nodejs/version/main.cjs +0 -6
- package/text/ascii/test.f.cjs +0 -12
- package/types/number/module.f.cjs +0 -24
- package/types/object/test.html +0 -9
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import sortedList, * as SL from '../sorted_list/module.f.mjs'
|
|
2
2
|
const { genericMerge } = sortedList
|
|
3
|
-
|
|
3
|
+
import list from '../list/module.f.mjs'
|
|
4
4
|
const { next } = list
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
import * as Option from '../nullable/module.f.mjs'
|
|
6
|
+
import number from '../number/module.f.mjs'
|
|
7
|
+
const { cmp } = number
|
|
8
|
+
import * as O from '../function/operator/module.f.mjs'
|
|
9
|
+
import _range, * as Range from '../range/module.f.mjs'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @template T
|
|
@@ -14,7 +15,7 @@ const _range = require('../range/module.f.cjs')
|
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @template T
|
|
17
|
-
* @typedef {
|
|
18
|
+
* @typedef {SL.SortedList<Entry<T>>} RangeMap
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -25,22 +26,22 @@ const _range = require('../range/module.f.cjs')
|
|
|
25
26
|
/**
|
|
26
27
|
* @template T
|
|
27
28
|
* @typedef {{
|
|
28
|
-
* readonly union:
|
|
29
|
-
* readonly equal:
|
|
29
|
+
* readonly union: O.Reduce<T>
|
|
30
|
+
* readonly equal: O.Equal<T>
|
|
30
31
|
* }} Operators
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* @template T
|
|
35
|
-
* @typedef {
|
|
36
|
+
* @typedef {Option.Nullable<Entry<T>>} RangeState
|
|
36
37
|
*/
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* @template T
|
|
40
|
-
* @typedef {
|
|
41
|
+
* @typedef {O.Reduce<RangeMap<T>>} RangeMerge
|
|
41
42
|
*/
|
|
42
43
|
|
|
43
|
-
/** @type {<T>(union:
|
|
44
|
+
/** @type {<T>(union: O.Reduce<T>) => (equal: O.Equal<T>) => SL.ReduceOp<Entry<T>, RangeState<T>>} */
|
|
44
45
|
const reduceOp = union => equal => state => ([aItem, aMax]) => ([bItem, bMax]) => {
|
|
45
46
|
const sign = cmp(aMax)(bMax)
|
|
46
47
|
const min = sign === 1 ? bMax : aMax
|
|
@@ -49,7 +50,7 @@ const reduceOp = union => equal => state => ([aItem, aMax]) => ([bItem, bMax]) =
|
|
|
49
50
|
return [newState, sign, [u, min]]
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
/** @type {<T>(equal:
|
|
53
|
+
/** @type {<T>(equal: O.Equal<T>) => SL.TailReduce<Entry<T>, RangeState<T>>} */
|
|
53
54
|
const tailReduce = equal => state => tail => {
|
|
54
55
|
if (state === null) { return tail }
|
|
55
56
|
const tailResult = next(tail)
|
|
@@ -78,10 +79,10 @@ const get = def => value => rm => {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
/** @type {<T>(def: T) => (r:
|
|
82
|
+
/** @type {<T>(def: T) => (r: Range.Range) => (value: T) => RangeMapArray<T>} */
|
|
82
83
|
const fromRange = def => ([a, b]) => v => [[def, a - 1], [v, b]]
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
export default {
|
|
85
86
|
/** @readonly */
|
|
86
87
|
merge,
|
|
87
88
|
/** @readonly */
|
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
1
|
+
import _, * as T from './module.f.mjs'
|
|
2
|
+
import compare from '../function/compare/module.f.mjs'
|
|
3
|
+
const { unsafeCmp } = compare
|
|
4
|
+
import json, * as jsonT from '../../json/module.f.mjs'
|
|
5
|
+
import object from '../object/module.f.mjs'
|
|
6
|
+
const { sort } = object
|
|
7
|
+
import sortedSet, * as SortedSet from '../sorted_set/module.f.mjs'
|
|
8
|
+
import list from '../list/module.f.mjs'
|
|
9
|
+
import operator from '../function/operator/module.f.mjs'
|
|
8
10
|
|
|
9
|
-
/** @type {(a: readonly
|
|
11
|
+
/** @type {(a: readonly jsonT.Unknown[]) => string} */
|
|
10
12
|
const stringify = json.stringify(sort)
|
|
11
13
|
|
|
12
|
-
/** @type {
|
|
14
|
+
/** @type {T.Operators<SortedSet.SortedSet<string>>} */
|
|
13
15
|
const op = { union: sortedSet.union(unsafeCmp), equal: list.equal(operator.strictEqual) }
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
export default {
|
|
16
18
|
merge: [
|
|
17
19
|
() => {
|
|
18
|
-
/** @type {
|
|
20
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
19
21
|
const a = [[['a'], 1], [['b'], 2]]
|
|
20
|
-
/** @type {
|
|
22
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
21
23
|
const b = null
|
|
22
24
|
const merged = _.merge(op)(a)(b)
|
|
23
25
|
const result = stringify(list.toArray(merged))
|
|
24
26
|
if (result !== '[[["a"],1],[["b"],2]]') { throw result }
|
|
25
27
|
},
|
|
26
28
|
() => {
|
|
27
|
-
/** @type {
|
|
29
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
28
30
|
const a = null
|
|
29
|
-
/** @type {
|
|
31
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
30
32
|
const b = [[['a'], 1], [['b'], 2]]
|
|
31
33
|
const merged = _.merge(op)(a)(b)
|
|
32
34
|
const result = stringify(list.toArray(merged))
|
|
33
35
|
if (result !== '[[["a"],1],[["b"],2]]') { throw result }
|
|
34
36
|
},
|
|
35
37
|
() => {
|
|
36
|
-
/** @type {
|
|
38
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
37
39
|
const a = [[['a'], 1], [['b'], 2]]
|
|
38
|
-
/** @type {
|
|
40
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
39
41
|
const b = [[['a'], 1], [['b'], 2]]
|
|
40
42
|
const merged = _.merge(op)(a)(b)
|
|
41
43
|
const result = stringify(list.toArray(merged))
|
|
42
44
|
if (result !== '[[["a"],1],[["b"],2]]') { throw result }
|
|
43
45
|
},
|
|
44
46
|
() => {
|
|
45
|
-
/** @type {
|
|
47
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
46
48
|
const a = [[['a'], 1], [['c'], 3]]
|
|
47
|
-
/** @type {
|
|
49
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
48
50
|
const b = [[['b'], 2], [['d'], 4]]
|
|
49
51
|
const merged = _.merge(op)(a)(b)
|
|
50
52
|
const result = stringify(list.toArray(merged))
|
|
51
53
|
if (result !== '[[["a","b"],1],[["b","c"],2],[["c","d"],3],[["d"],4]]') { throw result }
|
|
52
54
|
},
|
|
53
55
|
() => {
|
|
54
|
-
/** @type {
|
|
56
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
55
57
|
const a = [[['a'], 1], [['d'], 4]]
|
|
56
|
-
/** @type {
|
|
58
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
57
59
|
const b = [[['b'], 2], [['c'], 3]]
|
|
58
60
|
const merged = _.merge(op)(a)(b)
|
|
59
61
|
const result = stringify(list.toArray(merged))
|
|
60
62
|
if (result !== '[[["a","b"],1],[["b","d"],2],[["c","d"],3],[["d"],4]]') { throw result }
|
|
61
63
|
},
|
|
62
64
|
() => {
|
|
63
|
-
/** @type {
|
|
65
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
64
66
|
const a = [[['a'], 1], [['b'], 2]]
|
|
65
|
-
/** @type {
|
|
67
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
66
68
|
const b = [[['b'], 1], [['a'], 2]]
|
|
67
69
|
const merged = _.merge(op)(a)(b)
|
|
68
70
|
const result = stringify(list.toArray(merged))
|
|
69
71
|
if (result !== '[[["a","b"],2]]') { throw result }
|
|
70
72
|
},
|
|
71
73
|
() => {
|
|
72
|
-
/** @type {
|
|
74
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
73
75
|
const a = [[['a'], 1], [['b'], 2], [['a'], 3]]
|
|
74
|
-
/** @type {
|
|
76
|
+
/** @type {T.RangeMap<SortedSet.SortedSet<string>>} */
|
|
75
77
|
const b = [[['a'], 5]]
|
|
76
78
|
const merged = _.merge(op)(a)(b)
|
|
77
79
|
const result = stringify(list.toArray(merged))
|
|
@@ -79,54 +81,54 @@ module.exports = {
|
|
|
79
81
|
}
|
|
80
82
|
],
|
|
81
83
|
get: () => {
|
|
82
|
-
/** @type {
|
|
84
|
+
/** @type {SortedSet.SortedSet<string>} */
|
|
83
85
|
const sortedSetEmpty = []
|
|
84
86
|
const get = _.get(sortedSetEmpty)
|
|
85
87
|
return [
|
|
86
88
|
() => {
|
|
87
|
-
/** @type {
|
|
89
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
88
90
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
89
91
|
const result = stringify(get(5)(rm))
|
|
90
92
|
if (result !== '["a"]') { throw result }
|
|
91
93
|
},
|
|
92
94
|
() => {
|
|
93
|
-
/** @type {
|
|
95
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
94
96
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
95
97
|
const result = stringify(get(10)(rm))
|
|
96
98
|
if (result !== '["a"]') { throw result }
|
|
97
99
|
},
|
|
98
100
|
() => {
|
|
99
|
-
/** @type {
|
|
101
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
100
102
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
101
103
|
const result = stringify(get(15)(rm))
|
|
102
104
|
if (result !== '["b"]') { throw result }
|
|
103
105
|
},
|
|
104
106
|
() => {
|
|
105
|
-
/** @type {
|
|
107
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
106
108
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
107
109
|
const result = stringify(get(20)(rm))
|
|
108
110
|
if (result !== '["b"]') { throw result }
|
|
109
111
|
},
|
|
110
112
|
() => {
|
|
111
|
-
/** @type {
|
|
113
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
112
114
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
113
115
|
const result = stringify(get(25)(rm))
|
|
114
116
|
if (result !== '["c"]') { throw result }
|
|
115
117
|
},
|
|
116
118
|
() => {
|
|
117
|
-
/** @type {
|
|
119
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
118
120
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
119
121
|
const result = stringify(get(30)(rm))
|
|
120
122
|
if (result !== '["c"]') { throw result }
|
|
121
123
|
},
|
|
122
124
|
() => {
|
|
123
|
-
/** @type {
|
|
125
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
124
126
|
const rm = [[['a'], 10], [['b'], 20], [['c'], 30]]
|
|
125
127
|
const result = stringify(get(35)(rm))
|
|
126
128
|
if (result !== '[]') { throw result }
|
|
127
129
|
},
|
|
128
130
|
() => {
|
|
129
|
-
/** @type {
|
|
131
|
+
/** @type {T.RangeMapArray<SortedSet.SortedSet<string>>} */
|
|
130
132
|
const rm = []
|
|
131
133
|
const result = stringify(get(10)(rm))
|
|
132
134
|
if (result !== '[]') { throw result }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import result, * as Result from './module.f.mjs'
|
|
2
2
|
const { ok, error } = result
|
|
3
3
|
|
|
4
|
-
/** @type {<T>(f: () => T) =>
|
|
4
|
+
/** @type {<T>(f: () => T) => Result.Result<T, unknown>} */
|
|
5
5
|
const tryCatch = f => {
|
|
6
6
|
// Side effect: `try catch` is not allowed in FunctionalScript.
|
|
7
7
|
try {
|
|
@@ -11,7 +11,7 @@ const tryCatch = f => {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
export default {
|
|
15
15
|
/** @readonly */
|
|
16
16
|
tryCatch,
|
|
17
17
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as compare from '../function/compare/module.f.mjs'
|
|
2
|
+
import list, * as List from '../list/module.f.mjs'
|
|
3
|
+
import * as option from '../nullable/module.f.mjs'
|
|
4
4
|
const { next } = list
|
|
5
|
-
|
|
5
|
+
import f from '../function/module.f.mjs'
|
|
6
|
+
const { identity } = f
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @template T
|
|
9
|
-
* @typedef {
|
|
10
|
+
* @typedef {List.List<T>} SortedList
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -28,7 +29,7 @@ const { identity } = require('../function/module.f.cjs')
|
|
|
28
29
|
/**
|
|
29
30
|
* @template T
|
|
30
31
|
* @template S
|
|
31
|
-
* @typedef {(state: S) => (tail:
|
|
32
|
+
* @typedef {(state: S) => (tail: List.List<T>) => List.List<T>} TailReduce
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -40,12 +41,12 @@ const { identity } = require('../function/module.f.cjs')
|
|
|
40
41
|
* }} MergeReduce
|
|
41
42
|
*/
|
|
42
43
|
|
|
43
|
-
/** @type {<T,S>(reduce: MergeReduce<T,S>) => (state: S) => (a:
|
|
44
|
+
/** @type {<T,S>(reduce: MergeReduce<T,S>) => (state: S) => (a: List.List<T>) => (b: List.List<T>) => List.List<T>} */
|
|
44
45
|
const genericMerge = ({ reduceOp, tailReduce }) => {
|
|
45
46
|
/** @typedef {typeof reduceOp extends ReduceOp<infer T, infer S> ? [T, S] : never} TS */
|
|
46
47
|
/** @typedef {TS[0]} T */
|
|
47
48
|
/** @typedef {TS[1]} S */
|
|
48
|
-
/** @type {(state: S) => (a:
|
|
49
|
+
/** @type {(state: S) => (a: List.List<T>) => (b: List.List<T>) => List.List<T>} */
|
|
49
50
|
const f = state => a => b => () => {
|
|
50
51
|
const aResult = next(a)
|
|
51
52
|
if (aResult === null) { return tailReduce(state)(b) }
|
|
@@ -79,7 +80,7 @@ const cmpReduce = cmp => () => a => b => {
|
|
|
79
80
|
return [sign === 1 ? b : a, sign, null]
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
/** @type {() => <T>(tail:
|
|
83
|
+
/** @type {() => <T>(tail: List.List<T>) => List.List<T>} */
|
|
83
84
|
const mergeTail = () => identity
|
|
84
85
|
|
|
85
86
|
/** @type {<T>(cmp: Cmp<T>) => (value: T) => (array: SortedArray<T>) => T|null} */
|
|
@@ -104,7 +105,7 @@ const find = cmp => value => array => {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
export default {
|
|
108
109
|
/** @readonly */
|
|
109
110
|
merge,
|
|
110
111
|
/** @readonly */
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
import compare from '../function/compare/module.f.mjs'
|
|
3
|
+
const { unsafeCmp } = compare
|
|
4
|
+
import json, * as Json from '../../json/module.f.mjs'
|
|
5
|
+
import object from '../object/module.f.mjs'
|
|
6
|
+
const { sort } = object
|
|
7
|
+
import list from '../list/module.f.mjs'
|
|
8
|
+
const { toArray, countdown, length } = list
|
|
9
|
+
import map, * as Map from '../map/module.f.mjs'
|
|
10
|
+
import f from '../function/module.f.mjs'
|
|
11
|
+
const { flip } = f
|
|
8
12
|
|
|
9
|
-
/** @type {(a: readonly
|
|
13
|
+
/** @type {(a: readonly Json.Unknown[]) => string} */
|
|
10
14
|
const stringify = a => json.stringify(sort)(a)
|
|
11
15
|
|
|
12
|
-
/** @type {<T>(a: T) => (b: T) =>
|
|
16
|
+
/** @type {<T>(a: T) => (b: T) => Map.Sign} */
|
|
13
17
|
const reverseCmp = flip(unsafeCmp)
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
export default {
|
|
16
20
|
sortedMergre: [
|
|
17
21
|
() => {
|
|
18
22
|
const result = stringify(toArray(_.merge(unsafeCmp)([2, 3, 4])([1, 3, 5])))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
import * as Compare from '../function/compare/module.f.mjs'
|
|
2
|
+
import list from "../list/module.f.mjs"
|
|
3
|
+
const { toArray } = list
|
|
4
|
+
import sortedList, * as SortedList from '../sorted_list/module.f.mjs'
|
|
4
5
|
const { merge, genericMerge, find } = sortedList
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -10,7 +11,7 @@ const { merge, genericMerge, find } = sortedList
|
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @template T
|
|
13
|
-
* @typedef {(a: T) => (b: T) =>
|
|
14
|
+
* @typedef {(a: T) => (b: T) => Compare.Sign} Cmp
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
/** @typedef {number} Byte */
|
|
@@ -23,10 +24,10 @@ const intersect = cmp => a => b => toArray(intersectMerge(cmp)(a)(b))
|
|
|
23
24
|
|
|
24
25
|
const tailReduce = () => () => null
|
|
25
26
|
|
|
26
|
-
/** @type {<T>(cmp: Cmp<T>) => (a:
|
|
27
|
+
/** @type {<T>(cmp: Cmp<T>) => (a: SortedList.SortedList<T>) => (b: SortedList.SortedList<T>) => SortedList.SortedList<T>} */
|
|
27
28
|
const intersectMerge = cmp => genericMerge({ reduceOp: intersectReduce(cmp), tailReduce })(null)
|
|
28
29
|
|
|
29
|
-
/** @type {<T,S>(cmp: Cmp<T>) =>
|
|
30
|
+
/** @type {<T,S>(cmp: Cmp<T>) => SortedList.ReduceOp<T,S>} */
|
|
30
31
|
const intersectReduce = cmp => state => a => b => {
|
|
31
32
|
const sign = cmp(a)(b)
|
|
32
33
|
return [sign === 0 ? a : null, sign, state]
|
|
@@ -35,7 +36,7 @@ const intersectReduce = cmp => state => a => b => {
|
|
|
35
36
|
/** @type {<T>(cmp: Cmp<T>) => (value: T) => (set: SortedSet<T>) => boolean} */
|
|
36
37
|
const has = cmp => value => set => find(cmp)(value)(set) === value
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
export default {
|
|
39
40
|
/** @readonly */
|
|
40
41
|
union,
|
|
41
42
|
/** @readonly */
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
import compare from '../function/compare/module.f.mjs'
|
|
3
|
+
const { unsafeCmp } = compare
|
|
4
|
+
import json, * as Json from '../../json/module.f.mjs'
|
|
5
|
+
import object from '../object/module.f.mjs'
|
|
6
|
+
const { sort } = object
|
|
7
|
+
import list from '../list/module.f.mjs'
|
|
8
|
+
const { toArray, countdown, length } = list
|
|
9
|
+
import map, * as Map from '../map/module.f.mjs'
|
|
10
|
+
import f from '../function/module.f.mjs'
|
|
11
|
+
const { flip } = f
|
|
8
12
|
|
|
9
|
-
/** @type {(a: readonly
|
|
13
|
+
/** @type {(a: readonly Json.Unknown[]) => string} */
|
|
10
14
|
const stringify = a => json.stringify(sort)(a)
|
|
11
15
|
|
|
12
|
-
/** @type {<T>(a: T) => (b: T) =>
|
|
16
|
+
/** @type {<T>(a: T) => (b: T) => Map.Sign} */
|
|
13
17
|
const reverseCmp = flip(unsafeCmp)
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
export default {
|
|
16
20
|
union: [
|
|
17
21
|
() => {
|
|
18
22
|
const result = stringify(toArray(_.union(unsafeCmp)([2, 3, 4])([1, 3, 5])))
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import list, * as List from '../list/module.f.mjs'
|
|
2
2
|
const { reduce: listReduce, repeat: listRepeat } = list
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
import f from '../function/module.f.mjs'
|
|
4
|
+
const { compose } = f
|
|
5
|
+
import compare, * as Compare from '../function/compare/module.f.mjs'
|
|
5
6
|
const { unsafeCmp } = compare
|
|
6
|
-
|
|
7
|
+
import op, * as Op from '../function/operator/module.f.mjs'
|
|
7
8
|
const { join: joinOp, concat: concatOp } = op
|
|
8
9
|
|
|
9
|
-
/** @type {(o:
|
|
10
|
+
/** @type {(o: Op.Reduce<string>) => (input: List.List<string>) => string} */
|
|
10
11
|
const reduce = o => listReduce(o)('')
|
|
11
12
|
|
|
12
13
|
const join = compose(joinOp)(reduce)
|
|
@@ -16,10 +17,10 @@ const concat = reduce(concatOp)
|
|
|
16
17
|
/** @type {(n: string) => (v: number) => string} */
|
|
17
18
|
const repeat = v => compose(listRepeat(v))(concat)
|
|
18
19
|
|
|
19
|
-
/** @type {(a: string) => (b: string) =>
|
|
20
|
+
/** @type {(a: string) => (b: string) => Compare.Sign} */
|
|
20
21
|
const cmp = unsafeCmp
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
export default {
|
|
23
24
|
/** @readonly */
|
|
24
25
|
join,
|
|
25
26
|
/** @readonly */
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const { repeat
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
const { join, concat, repeat, cmp } = _
|
|
3
|
+
import list from '../list/module.f.mjs'
|
|
4
|
+
const { repeat: repeatList } = list
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
export default {
|
|
5
7
|
join: {
|
|
6
8
|
0: () => {
|
|
7
9
|
const result = join('/')([])
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as BtreeTypes from '../btree/types/module.f.mjs'
|
|
2
|
+
import btree from '../btree/module.f.mjs'
|
|
3
|
+
import btf from '../btree/find/module.f.mjs'
|
|
4
|
+
const { find, isFound } = btf
|
|
5
|
+
import btr from '../btree/remove/module.f.mjs'
|
|
6
|
+
const { remove: btreeRemove } = btr
|
|
7
|
+
import bts from '../btree/set/module.f.mjs'
|
|
8
|
+
const { set: btreeSet } = bts
|
|
3
9
|
const {
|
|
4
|
-
find: { find, isFound },
|
|
5
|
-
remove: { remove: btreeRemove },
|
|
6
|
-
set: { set: btreeSet },
|
|
7
10
|
/** @type {(s: StringSet) => list.List<string>} */
|
|
8
11
|
values,
|
|
9
12
|
empty,
|
|
10
13
|
} = btree
|
|
11
|
-
|
|
12
|
-
const
|
|
14
|
+
import string from "../string/module.f.mjs"
|
|
15
|
+
const { cmp } = string
|
|
16
|
+
import list from '../list/module.f.mjs'
|
|
13
17
|
const { fold } = list
|
|
14
|
-
|
|
18
|
+
import f from '../function/module.f.mjs'
|
|
19
|
+
const { compose } = f
|
|
15
20
|
|
|
16
|
-
/** @typedef {
|
|
21
|
+
/** @typedef {BtreeTypes.Tree<string>} StringSet */
|
|
17
22
|
|
|
18
23
|
/** @type {(value: string) => (set: StringSet) => boolean} */
|
|
19
24
|
const contains = value => {
|
|
@@ -29,7 +34,7 @@ const fromValues = fold(set)(null)
|
|
|
29
34
|
/** @type {(value: string) => (s: StringSet) => StringSet} */
|
|
30
35
|
const remove = compose(cmp)(btreeRemove)
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
export default {
|
|
33
38
|
/** @readonly */
|
|
34
39
|
empty,
|
|
35
40
|
/** @readonly */
|
package/com/cpp/testlib.f.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const { join } = require("../../types/string/module.f.cjs");
|
|
2
|
-
const { flat } = require("../../text/module.f.cjs")
|
|
3
|
-
const library = require('../types/testlib.f.cjs')
|
|
4
|
-
const { cpp } = require('./module.f.cjs')
|
|
5
|
-
|
|
6
|
-
module.exports = () => join('\n')(flat(' ')(cpp('My')(library)))
|
package/com/cs/testlib.f.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const { flat } = require('../../text/module.f.cjs');
|
|
2
|
-
const { join } = require('../../types/string/module.f.cjs');
|
|
3
|
-
const { cs } = require('./module.f.cjs');
|
|
4
|
-
const library = require('../types/testlib.f.cjs')
|
|
5
|
-
|
|
6
|
-
module.exports = join('\n')(flat(' ')(cs('My')(library)))
|
package/com/module.f.cjs
DELETED
package/com/rust/testlib.f.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const { flat } = require('../../text/module.f.cjs');
|
|
2
|
-
const { join } = require('../../types/string/module.f.cjs');
|
|
3
|
-
const { rust } = require('./module.f.cjs');
|
|
4
|
-
const library = require('../types/testlib.f.cjs')
|
|
5
|
-
|
|
6
|
-
module.exports = join('\n')(flat(' ')(rust(library)))
|
package/commonjs/module.f.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** @typedef {(packageName: string) => PackageMap|Package|null} PackageMap */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {readonly[
|
|
5
|
-
* string,
|
|
6
|
-
* PackageMap,
|
|
7
|
-
* (fileName: string) => string|null
|
|
8
|
-
* ]} Package
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
/** @readonly */
|
|
13
|
-
build: require('./build/module.f.cjs'),
|
|
14
|
-
/** @readonly */
|
|
15
|
-
module: require('./module/module.f.cjs'),
|
|
16
|
-
/** @readonly */
|
|
17
|
-
package: require('./package/module.f.cjs'),
|
|
18
|
-
/** @readonly */
|
|
19
|
-
path: require('./path/module.f.cjs'),
|
|
20
|
-
}
|
package/nodejs/module.f.cjs
DELETED
package/nodejs/version/main.cjs
DELETED
package/text/ascii/test.f.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const { range } = require('./module.f.cjs')
|
|
2
|
-
const json = require('../../json/module.f.cjs')
|
|
3
|
-
const { sort } = require('../../types/object/module.f.cjs')
|
|
4
|
-
|
|
5
|
-
const stringify = json.stringify(sort)
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
range: () => {
|
|
9
|
-
const r = stringify(range("A"))
|
|
10
|
-
if (r !== '[65,65]') { throw r }
|
|
11
|
-
}
|
|
12
|
-
}
|