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,26 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
1
|
+
import * as btreeT from './types/module.f.mjs'
|
|
2
|
+
import _ from './module.f.mjs'
|
|
3
|
+
const { values } = _
|
|
4
|
+
import json, * as jsonT from '../../json/module.f.mjs'
|
|
5
|
+
import o from '../object/module.f.mjs'
|
|
6
|
+
const { sort } = o
|
|
7
|
+
import str from '../string/module.f.mjs'
|
|
8
|
+
const { cmp } = str
|
|
9
|
+
import list, * as List from '../list/module.f.mjs'
|
|
10
|
+
import s from './set/module.f.mjs'
|
|
11
|
+
import f from './find/module.f.mjs'
|
|
9
12
|
|
|
10
|
-
require('./find/test.f.
|
|
11
|
-
require('./set/test.f.
|
|
12
|
-
require('./remove/test.f.
|
|
13
|
+
// require('./find/test.f.mjs')
|
|
14
|
+
// require('./set/test.f.mjs')
|
|
15
|
+
// require('./remove/test.f.mjs')
|
|
13
16
|
|
|
14
17
|
const jsonStr = json.stringify(sort)
|
|
15
18
|
|
|
16
|
-
/** @type {(sequence:
|
|
19
|
+
/** @type {(sequence: List.List<jsonT.Unknown>) => string} */
|
|
17
20
|
const stringify = sequence => jsonStr(list.toArray(sequence))
|
|
18
21
|
|
|
19
|
-
/** @type {(node:
|
|
22
|
+
/** @type {(node: btreeT.Node<string>) => (value: string) => btreeT.Node<string>} */
|
|
20
23
|
const set = node => value => s.set(cmp(value))(() => value)(node)
|
|
21
24
|
|
|
22
25
|
const valueTest1 = () => {
|
|
23
|
-
/** @type {
|
|
26
|
+
/** @type {btreeT.Node<string>} */
|
|
24
27
|
let _map = ['a']
|
|
25
28
|
_map = set(_map)('b')
|
|
26
29
|
_map = set(_map)('c')
|
|
@@ -32,7 +35,7 @@ const valueTest1 = () => {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
const valuesTest2 = () => {
|
|
35
|
-
/** @type {
|
|
38
|
+
/** @type {btreeT.Node<string>} */
|
|
36
39
|
let _map = ['1']
|
|
37
40
|
for(let i = 2; i <= 10; i++)
|
|
38
41
|
_map = set(_map)((i*i).toString())
|
|
@@ -41,7 +44,7 @@ const valuesTest2 = () => {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
const findTrue = () => {
|
|
44
|
-
/** @type {
|
|
47
|
+
/** @type {btreeT.Node<string>} */
|
|
45
48
|
let _map = ['a']
|
|
46
49
|
_map = set(_map)('b')
|
|
47
50
|
_map = set(_map)('c')
|
|
@@ -50,7 +53,7 @@ const findTrue = () => {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
const find = () => {
|
|
53
|
-
/** @type {
|
|
56
|
+
/** @type {btreeT.Node<string>} */
|
|
54
57
|
let _map = ['a']
|
|
55
58
|
_map = set(_map)('b')
|
|
56
59
|
_map = set(_map)('c')
|
|
@@ -59,7 +62,7 @@ const find = () => {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
const test = () => {
|
|
62
|
-
/** @type {
|
|
65
|
+
/** @type {btreeT.Node<string>} */
|
|
63
66
|
let _map = ['a']
|
|
64
67
|
_map = set(_map)('b')
|
|
65
68
|
_map = set(_map)('c')
|
|
@@ -68,7 +71,7 @@ const test = () => {
|
|
|
68
71
|
_map = set(_map)('f')
|
|
69
72
|
//
|
|
70
73
|
{
|
|
71
|
-
/** @type {
|
|
74
|
+
/** @type {List.Result<string>} */
|
|
72
75
|
let _item = list.next(values(_map))
|
|
73
76
|
while (_item !== null) {
|
|
74
77
|
_item = list.next(_item.tail)
|
|
@@ -76,7 +79,7 @@ const test = () => {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
export default {
|
|
80
83
|
valueTest1,
|
|
81
84
|
valuesTest2,
|
|
82
85
|
findTrue,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import f from '../function/module.f.mjs'
|
|
2
|
+
const { fn, compose } = f
|
|
3
|
+
import * as RangeMap from '../range_map/module.f.mjs'
|
|
4
|
+
import sortedSet, * as SortedSet from '../sorted_set/module.f.mjs'
|
|
5
|
+
import list from '../list/module.f.mjs'
|
|
5
6
|
const { reverse, countdown, flat, map } = list
|
|
6
7
|
|
|
7
8
|
/** @typedef {bigint} ByteSet */
|
|
@@ -48,17 +49,17 @@ const unset = n => s => difference(s)(one(n))
|
|
|
48
49
|
|
|
49
50
|
const counter = reverse(countdown(256))
|
|
50
51
|
|
|
51
|
-
/** @type {(n: ByteSet) => (s: string) => (i: number) =>
|
|
52
|
+
/** @type {(n: ByteSet) => (s: string) => (i: number) => RangeMap.RangeMap<SortedSet.SortedSet<string>>} */
|
|
52
53
|
const toRangeMapOp = n => s => i => {
|
|
53
54
|
const current = has(i + 1)(n)
|
|
54
55
|
const prev = has(i)(n)
|
|
55
56
|
return current === prev ? null : [[prev ? [s] : [], i]]
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
/** @type {(n: ByteSet) => (s: string) =>
|
|
59
|
+
/** @type {(n: ByteSet) => (s: string) => RangeMap.RangeMap<SortedSet.SortedSet<string>>} */
|
|
59
60
|
const toRangeMap = n => s => flat(map(toRangeMapOp(n)(s))(counter))
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
export default {
|
|
62
63
|
/** @readonly */
|
|
63
64
|
empty,
|
|
64
65
|
/** @readonly */
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
import list from '../list/module.f.mjs'
|
|
3
|
+
const { every, countdown, map, toArray } = list
|
|
4
|
+
import json, * as jsonT from '../../json/module.f.mjs'
|
|
5
|
+
import o from '../object/module.f.mjs'
|
|
6
|
+
const { sort } = o
|
|
6
7
|
|
|
7
|
-
/** @type {(a: readonly
|
|
8
|
+
/** @type {(a: readonly jsonT.Unknown[]) => string} */
|
|
8
9
|
const stringify = a => json.stringify(sort)(a)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
export default {
|
|
11
12
|
has: [
|
|
12
13
|
() => {
|
|
13
14
|
if (_.has(0)(_.empty)) { throw _.empty }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as array from '../../array/module.f.mjs'
|
|
2
2
|
|
|
3
3
|
/** @typedef {array.Index3} Index3 */
|
|
4
4
|
/** @typedef {array.Index5} Index5 */
|
|
@@ -27,7 +27,7 @@ const index5 = cmp => ([v0, v1]) => {
|
|
|
27
27
|
/** @type {<T>(a: T) => (b: T) => Sign} */
|
|
28
28
|
const unsafeCmp = a => b => a < b ? -1 : a > b ? 1 : 0
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
export default {
|
|
31
31
|
/** @readonly */
|
|
32
32
|
unsafeCmp,
|
|
33
33
|
/** @readonly */
|
|
@@ -31,11 +31,7 @@ const fn = result => ({
|
|
|
31
31
|
then: g => fn(compose(result)(g))
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
/** @readonly */
|
|
36
|
-
compare: require('./compare/module.f.cjs'),
|
|
37
|
-
/** @readonly */
|
|
38
|
-
operator: require('./operator/module.f.cjs'),
|
|
34
|
+
export default {
|
|
39
35
|
/** @readonly */
|
|
40
36
|
identity,
|
|
41
37
|
/** @readonly */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const { fn } = _
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
4
6
|
/** @type {(x: string) => readonly[string]} */
|
|
5
7
|
const f = x => [x]
|
|
6
8
|
/** @type {(x: readonly[string]) => readonly[number]} */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import function_ from '../function/module.f.mjs'
|
|
2
2
|
const { identity, fn, compose } = function_
|
|
3
|
-
|
|
3
|
+
import operator, * as Operator from '../function/operator/module.f.mjs'
|
|
4
4
|
const {
|
|
5
5
|
addition,
|
|
6
6
|
logicalNot,
|
|
@@ -234,25 +234,25 @@ const cycle = list => () => {
|
|
|
234
234
|
return i === null ? null : { first: i.first, tail: concat(i.tail)(cycle(list)) }
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
/** @type {<I, O>(op:
|
|
237
|
+
/** @type {<I, O>(op: Operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>} */
|
|
238
238
|
const scanStep = op => ne => {
|
|
239
239
|
const [first, newOp] = op(ne.first)
|
|
240
240
|
return { first, tail: scan(newOp)(ne.tail) }
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
/** @type {<I, O>(op:
|
|
243
|
+
/** @type {<I, O>(op: Operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
|
|
244
244
|
const scan = op => apply(scanStep(op))
|
|
245
245
|
|
|
246
|
-
/** @type {<I, S, O>(op:
|
|
246
|
+
/** @type {<I, S, O>(op: Operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
|
|
247
247
|
const stateScan = op => compose(stateScanToScan(op))(scan)
|
|
248
248
|
|
|
249
|
-
/** @type {<I,O>(op:
|
|
249
|
+
/** @type {<I,O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
|
|
250
250
|
const foldScan = op => compose(foldToScan(op))(scan)
|
|
251
251
|
|
|
252
|
-
/** @type {<I,O>(op:
|
|
252
|
+
/** @type {<I,O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
|
|
253
253
|
const fold = op => init => compose(foldScan(op)(init))(last(init))
|
|
254
254
|
|
|
255
|
-
/** @type {<T>(op:
|
|
255
|
+
/** @type {<T>(op: Operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
256
256
|
const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
|
|
257
257
|
|
|
258
258
|
/** @type {<T>(list: List<T>) => Thunk<number>} */
|
|
@@ -283,7 +283,7 @@ const entryOperator = index => value => [[index, value], index + 1]
|
|
|
283
283
|
/** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
|
|
284
284
|
const entries = input => {
|
|
285
285
|
/** @typedef {typeof input extends List<infer T> ? T : never} T */
|
|
286
|
-
/** @type {
|
|
286
|
+
/** @type {Operator.StateScan<T, Number, Entry<T>>} */
|
|
287
287
|
const o = entryOperator
|
|
288
288
|
return stateScan(o)(0)(input)
|
|
289
289
|
}
|
|
@@ -303,9 +303,9 @@ const zip = a => b => () => {
|
|
|
303
303
|
return { first: [aResult.first, bResult.first], tail: zip(aResult.tail)(bResult.tail) }
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
/** @type {<T>(e:
|
|
306
|
+
/** @type {<T>(e: Operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
|
|
307
307
|
const equal = e => {
|
|
308
|
-
/** @typedef {typeof e extends
|
|
308
|
+
/** @typedef {typeof e extends Operator.Equal<infer T> ? T : never} T */
|
|
309
309
|
/** @type {(a: List<T>) => (b: List<T>) => List<boolean>} */
|
|
310
310
|
const f = a => b => () => {
|
|
311
311
|
const [aResult, bResult] = [next(a), next(b)]
|
|
@@ -316,7 +316,7 @@ const equal = e => {
|
|
|
316
316
|
return a => b => every(f(a)(b))
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
|
|
319
|
+
export default {
|
|
320
320
|
/** @readonly */
|
|
321
321
|
empty: null,
|
|
322
322
|
/** @readonly */
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const {
|
|
1
|
+
import _, * as T from './module.f.mjs'
|
|
2
|
+
import json, * as Json from '../../json/module.f.mjs'
|
|
3
|
+
import o from '../object/module.f.mjs'
|
|
4
|
+
const { sort } = o
|
|
5
|
+
import operator from '../function/operator/module.f.mjs'
|
|
6
|
+
const { addition, strictEqual, reduceToScan } = operator
|
|
5
7
|
|
|
6
|
-
/** @type {(sequence:
|
|
8
|
+
/** @type {(sequence: T.List<Json.Unknown>) => string} */
|
|
7
9
|
const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
8
10
|
|
|
9
11
|
const stringifyTest = () => {
|
|
@@ -195,7 +197,7 @@ const stress = () => ({
|
|
|
195
197
|
if (first !== n - 1) { throw first }
|
|
196
198
|
},
|
|
197
199
|
concatBack: () => {
|
|
198
|
-
/** @type {
|
|
200
|
+
/** @type {T.List<number>} */
|
|
199
201
|
let sequence = []
|
|
200
202
|
// 20_000_000 is too much
|
|
201
203
|
for (let i = 0; i < 10_000_000; ++i) {
|
|
@@ -204,7 +206,7 @@ const stress = () => ({
|
|
|
204
206
|
const r = _.toArray(sequence)
|
|
205
207
|
},
|
|
206
208
|
flatToArray: () => {
|
|
207
|
-
/** @type {
|
|
209
|
+
/** @type {T.List<number>} */
|
|
208
210
|
let sequence = []
|
|
209
211
|
// 4_000_000 is too much
|
|
210
212
|
for (let i = 0; i < 2_000_000; ++i) {
|
|
@@ -213,7 +215,7 @@ const stress = () => ({
|
|
|
213
215
|
const r = _.toArray(sequence)
|
|
214
216
|
},
|
|
215
217
|
flatNext: () => {
|
|
216
|
-
/** @type {
|
|
218
|
+
/** @type {T.List<number>} */
|
|
217
219
|
let sequence = []
|
|
218
220
|
// 4_000_000 is too much
|
|
219
221
|
for (let i = 0; i < 2_000_000; ++i) {
|
|
@@ -222,7 +224,7 @@ const stress = () => ({
|
|
|
222
224
|
const a = _.next(sequence)
|
|
223
225
|
},
|
|
224
226
|
concatFront: () => {
|
|
225
|
-
/** @type {
|
|
227
|
+
/** @type {T.List<number>} */
|
|
226
228
|
let sequence = []
|
|
227
229
|
// 20_000_000 is too much
|
|
228
230
|
for (let i = 0; i < 10_000_000; ++i) {
|
|
@@ -231,7 +233,7 @@ const stress = () => ({
|
|
|
231
233
|
const a = _.next(sequence)
|
|
232
234
|
},
|
|
233
235
|
flatFront: () => {
|
|
234
|
-
/** @type {
|
|
236
|
+
/** @type {T.List<number>} */
|
|
235
237
|
let sequence = []
|
|
236
238
|
// 10_000_000 is too much
|
|
237
239
|
for (let i = 0; i < 5_000_000; ++i) {
|
|
@@ -264,7 +266,7 @@ const stress = () => ({
|
|
|
264
266
|
|
|
265
267
|
})
|
|
266
268
|
|
|
267
|
-
|
|
269
|
+
export default {
|
|
268
270
|
stringifyTest,
|
|
269
271
|
cycle,
|
|
270
272
|
countdown,
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} =
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
|
|
1
|
+
import * as btreeTypes from '../btree/types/module.f.mjs'
|
|
2
|
+
import btf from '../btree/find/module.f.mjs'
|
|
3
|
+
const { value, find } = btf
|
|
4
|
+
import bts from '../btree/set/module.f.mjs'
|
|
5
|
+
const { set } = bts
|
|
6
|
+
import btr from '../btree/remove/module.f.mjs'
|
|
7
|
+
const { remove: btreeRemove } = btr
|
|
8
|
+
import bt from '../btree/module.f.mjs'
|
|
9
|
+
const { values } = bt
|
|
10
|
+
import compare, * as Compare from '../function/compare/module.f.mjs'
|
|
11
|
+
import s from '../string/module.f.mjs'
|
|
12
|
+
const { cmp } = s
|
|
13
|
+
import list, * as List from '../list/module.f.mjs'
|
|
11
14
|
const { fold } = list
|
|
12
|
-
|
|
15
|
+
import operator, * as Operator from '../function/operator/module.f.mjs'
|
|
13
16
|
|
|
14
|
-
/** @typedef {
|
|
17
|
+
/** @typedef {Compare.Sign} Sign */
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* @template T
|
|
18
|
-
* @typedef {
|
|
21
|
+
* @typedef {Compare.Compare<T>} Cmp
|
|
19
22
|
*/
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -38,11 +41,11 @@ const at = name => map => {
|
|
|
38
41
|
return result === null ? null : result[1]
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
/** @type {<T>(reduce:
|
|
44
|
+
/** @type {<T>(reduce: Operator.Reduce<T>) => (entry: Entry<T>) => (map: Map<T>) => Map<T>} */
|
|
42
45
|
const setReduceEntry = reduce => entry =>
|
|
43
46
|
set(keyCmp(entry[0]))(old => old === null ? entry : [old[0], reduce(old[1])(entry[1])])
|
|
44
47
|
|
|
45
|
-
/** @type {<T>(reduce:
|
|
48
|
+
/** @type {<T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>} */
|
|
46
49
|
const setReduce = reduce => name => value => setReduceEntry(reduce)([name, value])
|
|
47
50
|
|
|
48
51
|
/** @type {<T>(a: T) => (b: T) => T} */
|
|
@@ -51,16 +54,16 @@ const replace = () => b => b
|
|
|
51
54
|
/** @type {(name: string) => <T>(value: T) => (map: Map<T>) => Map<T>} */
|
|
52
55
|
const setReplace = name => value => setReduceEntry(replace)([name, value])
|
|
53
56
|
|
|
54
|
-
/** @type {<T>(map: Map<T>) =>
|
|
57
|
+
/** @type {<T>(map: Map<T>) => List.List<Entry<T>>} */
|
|
55
58
|
const entries = values
|
|
56
59
|
|
|
57
|
-
/** @type {<T>(entries:
|
|
60
|
+
/** @type {<T>(entries: List.List<Entry<T>>) => Map<T>} */
|
|
58
61
|
const fromEntries = fold(setReduceEntry(replace))(null)
|
|
59
62
|
|
|
60
63
|
/** @type {(name: string) => <T>(map: Map<T>) => Map<T>} */
|
|
61
64
|
const remove = name => btreeRemove(keyCmp(name))
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
export default {
|
|
64
67
|
/** @readonly */
|
|
65
68
|
empty: null,
|
|
66
69
|
/** @readonly */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
const { at, setReplace, setReduce, empty, entries, remove } = _
|
|
3
|
+
import seq from '../list/module.f.mjs'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export default {
|
|
5
6
|
main: [
|
|
6
7
|
() => {
|
|
7
8
|
let m = setReplace('a')(1)(null)
|
|
@@ -57,7 +58,7 @@ module.exports = {
|
|
|
57
58
|
},
|
|
58
59
|
],
|
|
59
60
|
stress: () => {
|
|
60
|
-
/** @type {import('./module.f.
|
|
61
|
+
/** @type {import('./module.f.mjs').Map<number>} */
|
|
61
62
|
let m = empty
|
|
62
63
|
for (let i = 0; i < 100_000; ++i) {
|
|
63
64
|
m = setReplace((i * i).toString())(i)(m)
|
|
@@ -26,7 +26,7 @@ const range = ([a, b]) => one(b - a + 1) - 1 << a
|
|
|
26
26
|
/** @type {(r: readonly[number, number]) => (s: NibbleSet) => NibbleSet} */
|
|
27
27
|
const setRange = r => s => s | range(r)
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
export default {
|
|
30
30
|
/** @readonly */
|
|
31
31
|
empty,
|
|
32
32
|
/** @readonly */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import list from '../list/module.f.mjs'
|
|
2
|
+
const { every, map, countdown } = list
|
|
3
|
+
import _ from './module.f.mjs'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export default {
|
|
5
6
|
has: () => {
|
|
6
7
|
if (_.has(0)(_.empty)) { throw _.empty }
|
|
7
8
|
if (_.has(1)(_.empty)) { throw _.empty }
|
|
@@ -9,7 +9,7 @@ const map = f => value => value === null ? null : f(value)
|
|
|
9
9
|
/** @type {<T, R>(f: (_: T) => R) => (none: () => R) => (_: Nullable<T>) => Nullable<R>} */
|
|
10
10
|
const match = f => none => value => value === null ? none() : f(value)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
export default {
|
|
13
13
|
/** @readonly */
|
|
14
14
|
map,
|
|
15
15
|
/** @readonly */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import list from '../list/module.f.mjs'
|
|
2
|
+
const { reduce } = list
|
|
3
|
+
import operator from '../function/operator/module.f.mjs'
|
|
4
|
+
const { addition, min: minOp, max: maxOp } = operator
|
|
5
|
+
import compare, * as Compare from '../function/compare/module.f.mjs'
|
|
6
|
+
const { unsafeCmp } = compare
|
|
7
|
+
|
|
8
|
+
const sum = reduce(addition)(0)
|
|
9
|
+
|
|
10
|
+
const min = reduce(minOp)(null)
|
|
11
|
+
|
|
12
|
+
const max = reduce(maxOp)(null)
|
|
13
|
+
|
|
14
|
+
/** @type {(a: number) => (b: number) => Compare.Sign} */
|
|
15
|
+
const cmp = unsafeCmp
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
/** @readonly */
|
|
19
|
+
sum,
|
|
20
|
+
/** @readonly */
|
|
21
|
+
min,
|
|
22
|
+
/** @readonly */
|
|
23
|
+
max,
|
|
24
|
+
/** @readonly */
|
|
25
|
+
cmp,
|
|
26
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import list, * as List from '../list/module.f.mjs'
|
|
2
2
|
const { iterable } = list
|
|
3
|
-
|
|
3
|
+
import map, * as Map from '../map/module.f.mjs'
|
|
4
4
|
const { entries: mapEntries, fromEntries: mapFromEntries } = map
|
|
5
5
|
const { getOwnPropertyDescriptor, fromEntries: objectFromEntries } = Object
|
|
6
6
|
|
|
@@ -22,16 +22,16 @@ const at = name => object => {
|
|
|
22
22
|
return r === void 0 ? null : r.value
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** @type {<T>(e:
|
|
25
|
+
/** @type {<T>(e: List.List<Entry<T>>) => List.List<Entry<T>>} */
|
|
26
26
|
const sort = e => mapEntries(mapFromEntries(e))
|
|
27
27
|
|
|
28
|
-
/** @type {<T>(e:
|
|
28
|
+
/** @type {<T>(e: List.List<Entry<T>>) => Map<T>} */
|
|
29
29
|
const fromEntries = e => objectFromEntries(iterable(e))
|
|
30
30
|
|
|
31
|
-
/** @type {<T>(m:
|
|
31
|
+
/** @type {<T>(m: Map.Map<T>) => Map<T>} */
|
|
32
32
|
const fromMap = m => fromEntries(mapEntries(m))
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
export default {
|
|
35
35
|
/** @readonly */
|
|
36
36
|
at,
|
|
37
37
|
/** @readonly */
|