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.
Files changed (136) hide show
  1. package/.github/workflows/ci.yml +3 -3
  2. package/README.md +1 -0
  3. package/com/cpp/{module.f.cjs → module.f.mjs} +22 -21
  4. package/com/cpp/{test.f.cjs → test.f.mjs} +2 -2
  5. package/com/cpp/testlib.f.mjs +9 -0
  6. package/com/cs/{module.f.cjs → module.f.mjs} +20 -19
  7. package/com/cs/{test.f.cjs → test.f.mjs} +2 -2
  8. package/com/cs/testlib.f.mjs +10 -0
  9. package/com/rust/{module.f.cjs → module.f.mjs} +37 -35
  10. package/com/rust/{test.f.cjs → test.f.mjs} +2 -2
  11. package/com/rust/testlib.f.mjs +10 -0
  12. package/com/test/{build.f.cjs → build.f.mjs} +6 -6
  13. package/com/test/{build.cjs → build.mjs} +16 -8
  14. package/com/types/{module.f.cjs → module.f.mjs} +9 -8
  15. package/com/types/{testlib.f.cjs → testlib.f.mjs} +2 -2
  16. package/commonjs/build/{module.f.cjs → module.f.mjs} +23 -23
  17. package/commonjs/build/{test.f.cjs → test.f.mjs} +13 -12
  18. package/commonjs/module/function/{module.f.cjs → module.f.mjs} +4 -4
  19. package/commonjs/module/{module.f.cjs → module.f.mjs} +3 -5
  20. package/commonjs/module.f.mjs +11 -0
  21. package/commonjs/{module.cjs → module.mjs} +8 -6
  22. package/commonjs/package/dependencies/{module.f.cjs → module.f.mjs} +5 -5
  23. package/commonjs/package/dependencies/{test.f.cjs → test.f.mjs} +2 -2
  24. package/commonjs/package/{module.f.cjs → module.f.mjs} +7 -6
  25. package/commonjs/package/{test.f.cjs → test.f.mjs} +2 -2
  26. package/commonjs/path/{module.f.cjs → module.f.mjs} +15 -14
  27. package/commonjs/path/{test.f.cjs → test.f.mjs} +16 -14
  28. package/commonjs/{test.cjs → test.mjs} +4 -4
  29. package/dev/{module.f.cjs → module.f.mjs} +1 -1
  30. package/dev/module.mjs +5 -3
  31. package/dev/test/{module.f.cjs → module.f.mjs} +21 -9
  32. package/dev/{test.f.cjs → test.f.mjs} +1 -1
  33. package/dev/test.mjs +1 -1
  34. package/djs/{module.f.cjs → module.f.mjs} +18 -15
  35. package/djs/parser/{module.f.cjs → module.f.mjs} +29 -28
  36. package/djs/parser/{test.f.cjs → test.f.mjs} +10 -8
  37. package/djs/{test.f.cjs → test.f.mjs} +7 -5
  38. package/djs/tokenizer/{module.f.cjs → module.f.mjs} +19 -18
  39. package/djs/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
  40. package/fsc/{module.f.cjs → module.f.mjs} +17 -16
  41. package/fsc/{test.f.cjs → test.f.mjs} +6 -4
  42. package/fsm/{module.f.cjs → module.f.mjs} +28 -24
  43. package/fsm/{test.f.cjs → test.f.mjs} +13 -9
  44. package/html/{module.f.cjs → module.f.mjs} +16 -13
  45. package/html/{test.f.cjs → test.f.mjs} +5 -5
  46. package/index.f.mjs +45 -35
  47. package/issues/README.md +15 -0
  48. package/js/tokenizer/{module.f.cjs → module.f.mjs} +52 -51
  49. package/js/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
  50. package/json/{module.f.cjs → module.f.mjs} +18 -17
  51. package/json/parser/{module.f.cjs → module.f.mjs} +27 -26
  52. package/json/parser/{test.f.cjs → test.f.mjs} +10 -8
  53. package/json/serializer/{module.f.cjs → module.f.mjs} +12 -12
  54. package/json/serializer/{test.f.cjs → test.f.mjs} +4 -3
  55. package/json/{test.f.cjs → test.f.mjs} +6 -4
  56. package/json/tokenizer/{module.f.cjs → module.f.mjs} +16 -15
  57. package/json/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
  58. package/jsr.json +1 -1
  59. package/nodejs/version/main.mjs +5 -0
  60. package/nodejs/version/{module.f.cjs → module.f.mjs} +2 -2
  61. package/nodejs/version/{test.f.cjs → test.f.mjs} +5 -5
  62. package/package.json +3 -3
  63. package/prime_field/{module.f.cjs → module.f.mjs} +6 -5
  64. package/prime_field/{test.f.cjs → test.f.mjs} +3 -2
  65. package/secp/{module.f.cjs → module.f.mjs} +7 -6
  66. package/secp/{test.f.cjs → test.f.mjs} +6 -6
  67. package/sha2/{module.f.cjs → module.f.mjs} +5 -5
  68. package/sha2/{test.f.cjs → test.f.mjs} +7 -6
  69. package/text/ascii/{module.f.cjs → module.f.mjs} +3 -3
  70. package/text/ascii/test.f.mjs +14 -0
  71. package/text/{module.f.cjs → module.f.mjs} +6 -6
  72. package/text/sgr/{module.f.cjs → module.f.mjs} +1 -1
  73. package/text/{test.f.cjs → test.f.mjs} +5 -4
  74. package/text/utf16/{module.f.cjs → module.f.mjs} +16 -14
  75. package/text/utf16/{test.f.cjs → test.f.mjs} +7 -6
  76. package/text/utf8/{module.f.cjs → module.f.mjs} +11 -11
  77. package/text/utf8/{test.f.cjs → test.f.mjs} +6 -5
  78. package/tsconfig.json +2 -2
  79. package/types/array/{module.f.cjs → module.f.mjs} +2 -2
  80. package/types/array/{test.f.cjs → test.f.mjs} +5 -4
  81. package/types/bigfloat/{module.f.cjs → module.f.mjs} +3 -3
  82. package/types/bigfloat/{test.f.cjs → test.f.mjs} +3 -2
  83. package/types/bigint/{module.f.cjs → module.f.mjs} +8 -7
  84. package/types/bigint/{test.f.cjs → test.f.mjs} +3 -2
  85. package/types/btree/find/{module.f.cjs → module.f.mjs} +12 -12
  86. package/types/btree/find/{test.f.cjs → test.f.mjs} +11 -9
  87. package/types/btree/{module.f.cjs → module.f.mjs} +7 -12
  88. package/types/btree/remove/{module.f.cjs → module.f.mjs} +17 -16
  89. package/types/btree/remove/{test.f.cjs → test.f.mjs} +9 -7
  90. package/types/btree/set/{module.f.cjs → module.f.mjs} +9 -9
  91. package/types/btree/set/{test.f.cjs → test.f.mjs} +8 -6
  92. package/types/btree/{test.f.cjs → test.f.mjs} +23 -20
  93. package/types/btree/types/{module.f.cjs → module.f.mjs} +1 -1
  94. package/types/byte_set/{module.f.cjs → module.f.mjs} +8 -7
  95. package/types/byte_set/{test.f.cjs → test.f.mjs} +8 -7
  96. package/types/function/compare/{module.f.cjs → module.f.mjs} +2 -2
  97. package/types/function/compare/{test.f.cjs → test.f.mjs} +3 -2
  98. package/types/function/{module.f.cjs → module.f.mjs} +1 -5
  99. package/types/function/operator/{module.f.cjs → module.f.mjs} +1 -1
  100. package/types/function/{test.f.cjs → test.f.mjs} +4 -2
  101. package/types/list/{module.f.cjs → module.f.mjs} +12 -12
  102. package/types/list/{test.f.cjs → test.f.mjs} +13 -11
  103. package/types/map/{module.f.cjs → module.f.mjs} +21 -18
  104. package/types/map/{test.f.cjs → test.f.mjs} +5 -4
  105. package/types/nibble_set/{module.f.cjs → module.f.mjs} +1 -1
  106. package/types/nibble_set/{test.f.cjs → test.f.mjs} +4 -3
  107. package/types/nullable/{module.f.cjs → module.f.mjs} +1 -1
  108. package/types/nullable/{test.f.cjs → test.f.mjs} +2 -2
  109. package/types/number/module.f.mjs +26 -0
  110. package/types/number/{test.f.cjs → test.f.mjs} +3 -2
  111. package/types/object/{module.f.cjs → module.f.mjs} +6 -6
  112. package/types/object/{test.f.cjs → test.f.mjs} +2 -2
  113. package/types/range/{module.f.cjs → module.f.mjs} +1 -1
  114. package/types/range/{test.f.cjs → test.f.mjs} +2 -2
  115. package/types/range_map/{module.f.cjs → module.f.mjs} +16 -15
  116. package/types/range_map/{test.f.cjs → test.f.mjs} +35 -33
  117. package/types/result/{module.f.cjs → module.f.mjs} +1 -1
  118. package/types/result/{module.cjs → module.mjs} +3 -3
  119. package/types/sorted_list/{module.f.cjs → module.f.mjs} +11 -10
  120. package/types/sorted_list/{test.f.cjs → test.f.mjs} +14 -10
  121. package/types/sorted_set/{module.f.cjs → module.f.mjs} +8 -7
  122. package/types/sorted_set/{test.f.cjs → test.f.mjs} +14 -10
  123. package/types/string/{module.f.cjs → module.f.mjs} +8 -7
  124. package/types/string/{test.f.cjs → test.f.mjs} +5 -3
  125. package/types/string_set/{module.f.cjs → module.f.mjs} +15 -10
  126. package/types/string_set/{test.f.cjs → test.f.mjs} +2 -2
  127. package/com/cpp/testlib.f.cjs +0 -6
  128. package/com/cs/testlib.f.cjs +0 -6
  129. package/com/module.f.cjs +0 -6
  130. package/com/rust/testlib.f.cjs +0 -6
  131. package/commonjs/module.f.cjs +0 -20
  132. package/nodejs/module.f.cjs +0 -4
  133. package/nodejs/version/main.cjs +0 -6
  134. package/text/ascii/test.f.cjs +0 -12
  135. package/types/number/module.f.cjs +0 -24
  136. package/types/object/test.html +0 -9
@@ -1,26 +1,29 @@
1
- const btree = require('./types/module.f.cjs')
2
- const { values } = require('./module.f.cjs')
3
- const json = require('../../json/module.f.cjs')
4
- const { sort } = require('../object/module.f.cjs')
5
- const { cmp } = require('../string/module.f.cjs')
6
- const list = require('../list/module.f.cjs')
7
- const s = require('./set/module.f.cjs')
8
- const f = require('./find/module.f.cjs')
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.cjs')
11
- require('./set/test.f.cjs')
12
- require('./remove/test.f.cjs')
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: list.List<json.Unknown>) => string} */
19
+ /** @type {(sequence: List.List<jsonT.Unknown>) => string} */
17
20
  const stringify = sequence => jsonStr(list.toArray(sequence))
18
21
 
19
- /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
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 {btree.Node<string>} */
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 {btree.Node<string>} */
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 {btree.Node<string>} */
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 {btree.Node<string>} */
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 {btree.Node<string>} */
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 {list.Result<string>} */
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
- module.exports = {
82
+ export default {
80
83
  valueTest1,
81
84
  valuesTest2,
82
85
  findTrue,
@@ -61,4 +61,4 @@
61
61
  * @typedef { readonly[...Branch5<T>, T, Node<T>] } Branch7
62
62
  */
63
63
 
64
- module.exports = {}
64
+ export default {}
@@ -1,7 +1,8 @@
1
- const { fn, compose } = require('../function/module.f.cjs')
2
- const rangeMap = require('../range_map/module.f.cjs')
3
- const sortedSet = require('../sorted_set/module.f.cjs')
4
- const list = require('../list/module.f.cjs')
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) => rangeMap.RangeMap<sortedSet.SortedSet<string>>} */
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) => rangeMap.RangeMap<sortedSet.SortedSet<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
- module.exports = {
62
+ export default {
62
63
  /** @readonly */
63
64
  empty,
64
65
  /** @readonly */
@@ -1,13 +1,14 @@
1
- const _ = require('./module.f.cjs')
2
- const { every, countdown, map } = require('../list/module.f.cjs')
3
- const json = require('../../json/module.f.cjs')
4
- const { sort } = require('../object/module.f.cjs')
5
- const { toArray } = require('../list/module.f.cjs')
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 json.Unknown[]) => string} */
8
+ /** @type {(a: readonly jsonT.Unknown[]) => string} */
8
9
  const stringify = a => json.stringify(sort)(a)
9
10
 
10
- module.exports = {
11
+ export default {
11
12
  has: [
12
13
  () => {
13
14
  if (_.has(0)(_.empty)) { throw _.empty }
@@ -1,4 +1,4 @@
1
- const array = require('../../array/module.f.cjs')
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
- module.exports = {
30
+ export default {
31
31
  /** @readonly */
32
32
  unsafeCmp,
33
33
  /** @readonly */
@@ -1,6 +1,7 @@
1
- const { unsafeCmp } = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ const { unsafeCmp } = _
2
3
 
3
- module.exports = () => {
4
+ export default () => {
4
5
  const result = unsafeCmp(true)(false)
5
6
  if (result !== 1) { throw result }
6
7
  }
@@ -31,11 +31,7 @@ const fn = result => ({
31
31
  then: g => fn(compose(result)(g))
32
32
  })
33
33
 
34
- module.exports = {
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 */
@@ -76,7 +76,7 @@ const increment = addition(1)
76
76
 
77
77
  const counter = () => increment
78
78
 
79
- module.exports = {
79
+ export default {
80
80
  /** @readonly */
81
81
  join,
82
82
  /** @readonly */
@@ -1,6 +1,8 @@
1
- const { fn } = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
2
 
3
- module.exports = () => {
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
- const function_ = require('../function/module.f.cjs')
1
+ import function_ from '../function/module.f.mjs'
2
2
  const { identity, fn, compose } = function_
3
- const operator = require('../function/operator/module.f.cjs')
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: operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>} */
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: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
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: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
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: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
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: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
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: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
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 {operator.StateScan<T, Number, Entry<T>>} */
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: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
306
+ /** @type {<T>(e: Operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
307
307
  const equal = e => {
308
- /** @typedef {typeof e extends operator.Equal<infer T> ? T : never} T */
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
- module.exports = {
319
+ export default {
320
320
  /** @readonly */
321
321
  empty: null,
322
322
  /** @readonly */
@@ -1,9 +1,11 @@
1
- const _ = require('./module.f.cjs')
2
- const json = require('../../json/module.f.cjs')
3
- const { sort } = require('../object/module.f.cjs')
4
- const { addition, strictEqual, reduceToScan } = require('../function/operator/module.f.cjs')
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: _.List<json.Unknown>) => string} */
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 {_.List<number>} */
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 {_.List<number>} */
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 {_.List<number>} */
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 {_.List<number>} */
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 {_.List<number>} */
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
- module.exports = {
269
+ export default {
268
270
  stringifyTest,
269
271
  cycle,
270
272
  countdown,
@@ -1,21 +1,24 @@
1
- const btreeTypes = require('../btree/types/module.f.cjs')
2
- const {
3
- values,
4
- find: { value, find },
5
- set: { set },
6
- remove: { remove: btreeRemove }
7
- } = require("../btree/module.f.cjs")
8
- const compare = require('../function/compare/module.f.cjs')
9
- const { cmp } = require('../string/module.f.cjs')
10
- const list = require('../list/module.f.cjs')
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
- const operator = require('../function/operator/module.f.cjs')
15
+ import operator, * as Operator from '../function/operator/module.f.mjs'
13
16
 
14
- /** @typedef {compare.Sign} Sign */
17
+ /** @typedef {Compare.Sign} Sign */
15
18
 
16
19
  /**
17
20
  * @template T
18
- * @typedef {compare.Compare<T>} Cmp
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: operator.Reduce<T>) => (entry: Entry<T>) => (map: Map<T>) => Map<T>} */
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: operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>} */
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>) => list.List<Entry<T>>} */
57
+ /** @type {<T>(map: Map<T>) => List.List<Entry<T>>} */
55
58
  const entries = values
56
59
 
57
- /** @type {<T>(entries: list.List<Entry<T>>) => Map<T>} */
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
- module.exports = {
66
+ export default {
64
67
  /** @readonly */
65
68
  empty: null,
66
69
  /** @readonly */
@@ -1,7 +1,8 @@
1
- const { at, setReplace, setReduce, empty, entries, remove } = require('./module.f.cjs')
2
- const seq = require('../list/module.f.cjs')
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
- module.exports = {
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.cjs').Map<number>} */
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
- module.exports = {
29
+ export default {
30
30
  /** @readonly */
31
31
  empty,
32
32
  /** @readonly */
@@ -1,7 +1,8 @@
1
- const { every, map, countdown } = require('../list/module.f.cjs')
2
- const _ = require('./module.f.cjs')
1
+ import list from '../list/module.f.mjs'
2
+ const { every, map, countdown } = list
3
+ import _ from './module.f.mjs'
3
4
 
4
- module.exports = {
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
- module.exports = {
12
+ export default {
13
13
  /** @readonly */
14
14
  map,
15
15
  /** @readonly */
@@ -1,6 +1,6 @@
1
- const _ = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
2
 
3
- module.exports = () => {
3
+ export default () => {
4
4
  const optionSq = _.map(v => v * v)
5
5
  const sq3 = optionSq(3)
6
6
  if (sq3 !== 9) { throw sq3 }
@@ -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,7 @@
1
- const { sum, min, max, cmp } = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ const { sum, min, max, cmp } = _
2
3
 
3
- module.exports = {
4
+ export default {
4
5
  sum: () => {
5
6
  const result = sum([2, 3, 4, 5])
6
7
  if (result !== 14) { throw result }
@@ -1,6 +1,6 @@
1
- const list = require('../list/module.f.cjs')
1
+ import list, * as List from '../list/module.f.mjs'
2
2
  const { iterable } = list
3
- const map = require('../map/module.f.cjs')
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: list.List<Entry<T>>) => list.List<Entry<T>>} */
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: list.List<Entry<T>>) => Map<T>} */
28
+ /** @type {<T>(e: List.List<Entry<T>>) => Map<T>} */
29
29
  const fromEntries = e => objectFromEntries(iterable(e))
30
30
 
31
- /** @type {<T>(m: map.Map<T>) => Map<T>} */
31
+ /** @type {<T>(m: Map.Map<T>) => Map<T>} */
32
32
  const fromMap = m => fromEntries(mapEntries(m))
33
33
 
34
- module.exports = {
34
+ export default {
35
35
  /** @readonly */
36
36
  at,
37
37
  /** @readonly */
@@ -1,6 +1,6 @@
1
- const _ = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  ctor: () => {
5
5
  const a = {}
6
6
  const value = _.at('constructor')(a)
@@ -6,7 +6,7 @@ const contains = ([b, e]) => i => b <= i && i <= e
6
6
  /** @type {(i: number) => Range} */
7
7
  const one = a => [a, a]
8
8
 
9
- module.exports = {
9
+ export default {
10
10
  /** @readonly */
11
11
  contains,
12
12
  /** @readonly */
@@ -1,6 +1,6 @@
1
- const _ = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
2
 
3
- module.exports = () => {
3
+ export default () => {
4
4
  if (!_.contains([0, 5])(1)) { throw 1 }
5
5
  if (!_.contains([0, 5])(0)) { throw 0 }
6
6
  if (!_.contains([0, 5])(5)) { throw 5 }