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,7 +1,9 @@
1
- const list = require('../../types/list/module.f.cjs')
2
- const operator = require('../../types/function/operator/module.f.cjs')
3
- const { contains } = require('../../types/range/module.f.cjs')
4
- const { fn } = require('../../types/function/module.f.cjs')
1
+ import list, * as List from '../../types/list/module.f.mjs'
2
+ import operator, * as Operator from '../../types/function/operator/module.f.mjs'
3
+ import range from '../../types/range/module.f.mjs'
4
+ const { contains } = range
5
+ import f from '../../types/function/module.f.mjs'
6
+ const { fn } = f
5
7
  const { map, flat, stateScan, reduce, flatMap, empty } = list
6
8
 
7
9
  /** @typedef {u16|null} WordOrEof */
@@ -29,7 +31,7 @@ const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
29
31
  /** @type {(a: i32) => boolean} */
30
32
  const isSupplementaryPlane = contains([0x01_0000, 0x10_ffff])
31
33
 
32
- /** @type {(input: i32) => list.List<u16>} */
34
+ /** @type {(input: i32) => List.List<u16>} */
33
35
  const codePointToUtf16 = codePoint => {
34
36
  if (isBmpCodePoint(codePoint)) { return [codePoint] }
35
37
  if (isSupplementaryPlane(codePoint)) {
@@ -45,7 +47,7 @@ const fromCodePointList = flatMap(codePointToUtf16)
45
47
 
46
48
  const u16 = contains([0x0000, 0xFFFF])
47
49
 
48
- /** @type {operator.StateScan<u16, Utf16State, list.List<i32>>} */
50
+ /** @type {Operator.StateScan<u16, Utf16State, List.List<i32>>} */
49
51
  const utf16ByteToCodePointOp = state => word => {
50
52
  if (!u16(word)) {
51
53
  return [[0xffffffff], state]
@@ -65,21 +67,21 @@ const utf16ByteToCodePointOp = state => word => {
65
67
  return [[state | errorMask, word | errorMask], null]
66
68
  }
67
69
 
68
- /** @type {(state: Utf16State) => readonly[list.List<i32>, Utf16State]} */
70
+ /** @type {(state: Utf16State) => readonly[List.List<i32>, Utf16State]} */
69
71
  const utf16EofToCodePointOp = state => [state === null ? empty : [state | errorMask], null]
70
72
 
71
- /** @type {operator.StateScan<WordOrEof, Utf16State, list.List<i32>>} */
73
+ /** @type {Operator.StateScan<WordOrEof, Utf16State, List.List<i32>>} */
72
74
  const utf16ByteOrEofToCodePointOp = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
73
75
 
74
- /** @type {list.List<WordOrEof>} */
76
+ /** @type {List.List<WordOrEof>} */
75
77
  const eofList = [null]
76
78
 
77
- /** @type {(input: list.List<u16>) => list.List<i32>} */
79
+ /** @type {(input: List.List<u16>) => List.List<i32>} */
78
80
  const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
79
81
 
80
- /** @type {(s: string) => list.List<u16>} */
82
+ /** @type {(s: string) => List.List<u16>} */
81
83
  const stringToList = s => {
82
- /** @type {(i: number) => list.Result<number>} */
84
+ /** @type {(i: number) => List.Result<number>} */
83
85
  const at = i => {
84
86
  const first = s.charCodeAt(i)
85
87
  return isNaN(first) ? empty : { first, tail: () => at(i + 1) }
@@ -87,12 +89,12 @@ const stringToList = s => {
87
89
  return at(0)
88
90
  }
89
91
 
90
- /** @type {(input: list.List<u16>) => string} */
92
+ /** @type {(input: List.List<u16>) => string} */
91
93
  const listToString = fn(map(String.fromCharCode))
92
94
  .then(reduce(operator.concat)(''))
93
95
  .result
94
96
 
95
- module.exports = {
97
+ export default {
96
98
  /** @readonly */
97
99
  fromCodePointList,
98
100
  /** @readonly */
@@ -1,12 +1,13 @@
1
- const encoding = require('./module.f.cjs')
2
- const json = require('../../json/module.f.cjs')
3
- const { sort } = require('../../types/object/module.f.cjs')
4
- const list = require('../../types/list/module.f.cjs')
1
+ import encoding from './module.f.mjs'
2
+ import json, * as jsonT from '../../json/module.f.mjs'
3
+ import o from '../../types/object/module.f.mjs'
4
+ const { sort } = o
5
+ import list from '../../types/list/module.f.mjs'
5
6
 
6
- /** @type {(a: readonly json.Unknown[]) => string} */
7
+ /** @type {(a: readonly jsonT.Unknown[]) => string} */
7
8
  const stringify = a => json.stringify(sort)(a)
8
9
 
9
- module.exports = {
10
+ export default {
10
11
  toCodePointList: [
11
12
  () => {
12
13
  const result = stringify(list.toArray(encoding.toCodePointList([-1, 65536])))
@@ -1,11 +1,11 @@
1
- const list = require('../../types/list/module.f.cjs')
2
- const operator = require('../../types/function/operator/module.f.cjs')
3
- const array = require('../../types/array/module.f.cjs')
1
+ import list, * as List from '../../types/list/module.f.mjs'
2
+ import * as operator from '../../types/function/operator/module.f.mjs'
3
+ import * as arrayT from '../../types/array/module.f.mjs'
4
4
  const { flatMap, flat, stateScan } = list
5
5
 
6
6
  /** @typedef {u8|null} ByteOrEof */
7
7
 
8
- /** @typedef {array.Array1<number>|array.Array2<number>|array.Array3<number>} Utf8NonEmptyState */
8
+ /** @typedef {arrayT.Array1<number>|arrayT.Array2<number>|arrayT.Array3<number>} Utf8NonEmptyState */
9
9
 
10
10
  /** @typedef {null|Utf8NonEmptyState} Utf8State */
11
11
 
@@ -15,7 +15,7 @@ const { flatMap, flat, stateScan } = list
15
15
 
16
16
  const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
17
17
 
18
- /** @type {(input:number) => list.List<u8>} */
18
+ /** @type {(input:number) => List.List<u8>} */
19
19
  const codePointToUtf8 = input => {
20
20
  if (input >= 0x0000 && input <= 0x007f) { return [input & 0b01111_1111] }
21
21
  if (input >= 0x0080 && input <= 0x07ff) { return [input >> 6 | 0b1100_0000, input & 0b0011_1111 | 0b1000_0000] }
@@ -58,7 +58,7 @@ const utf8StateToError = state => {
58
58
  return x | errorMask
59
59
  }
60
60
 
61
- /** @type {operator.StateScan<number, Utf8State, list.List<i32>>} */
61
+ /** @type {operator.StateScan<number, Utf8State, List.List<i32>>} */
62
62
  const utf8ByteToCodePointOp = state => byte => {
63
63
  if (byte < 0x00 || byte > 0xff) {
64
64
  return [[errorMask], state]
@@ -94,20 +94,20 @@ const utf8ByteToCodePointOp = state => byte => {
94
94
  return [[error, byte | errorMask], null]
95
95
  }
96
96
 
97
- /** @type {(state: Utf8State) => readonly[list.List<i32>, Utf8State]} */
97
+ /** @type {(state: Utf8State) => readonly[List.List<i32>, Utf8State]} */
98
98
  const utf8EofToCodePointOp = state =>
99
99
  [state === null ? null : [utf8StateToError(state)], null]
100
100
 
101
- /** @type {operator.StateScan<ByteOrEof, Utf8State, list.List<i32>>} */
101
+ /** @type {operator.StateScan<ByteOrEof, Utf8State, List.List<i32>>} */
102
102
  const utf8ByteOrEofToCodePointOp = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
103
103
 
104
- /** @type {list.List<ByteOrEof>} */
104
+ /** @type {List.List<ByteOrEof>} */
105
105
  const eofList = [null]
106
106
 
107
- /** @type {(input: list.List<u8>) => list.List<i32>} */
107
+ /** @type {(input: List.List<u8>) => List.List<i32>} */
108
108
  const toCodePointList = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
109
109
 
110
- module.exports = {
110
+ export default {
111
111
  /** @readonly */
112
112
  fromCodePointList,
113
113
  /** @readonly */
@@ -1,11 +1,12 @@
1
- const encoding = require('./module.f.cjs')
2
- const json = require('../../json/module.f.cjs')
3
- const { sort } = require('../../types/object/module.f.cjs')
4
- const list = require('../../types/list/module.f.cjs')
1
+ import encoding from './module.f.mjs'
2
+ import json from '../../json/module.f.mjs'
3
+ import o from '../../types/object/module.f.mjs'
4
+ const { sort } = o
5
+ import list from '../../types/list/module.f.mjs'
5
6
 
6
7
  const stringify = json.stringify(sort)
7
8
 
8
- module.exports = {
9
+ export default {
9
10
  toCodePoint: [
10
11
  () => {
11
12
  const result = stringify(list.toArray(encoding.toCodePointList([-1, 256])))
package/tsconfig.json CHANGED
@@ -24,7 +24,7 @@
24
24
  // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
25
 
26
26
  /* Modules */
27
- "module": "commonjs", /* Specify what module code is generated. */
27
+ "module": "ES2022", /* Specify what module code is generated. */
28
28
  // "rootDir": "./", /* Specify the root folder within your source files. */
29
29
  // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30
30
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
@@ -33,7 +33,7 @@
33
33
  // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
34
34
  // "types": [], /* Specify type package names to be included without being referenced in a source file. */
35
35
  // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36
- "resolveJsonModule": true, /* Enable importing .json files */
36
+ // "resolveJsonModule": true, /* Enable importing .json files */
37
37
  // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
38
38
 
39
39
  /* JavaScript Support */
@@ -1,4 +1,4 @@
1
- const option = require('../nullable/module.f.cjs')
1
+ import option from '../nullable/module.f.mjs'
2
2
  const { map } = option
3
3
 
4
4
  /**
@@ -117,7 +117,7 @@ const splitLast = a => {
117
117
  return [uncheckHead(a), lastA]
118
118
  }
119
119
 
120
- module.exports = {
120
+ export default {
121
121
  /** @readonly */
122
122
  at,
123
123
  /** @readnly */
@@ -1,10 +1,11 @@
1
- const _ = require('./module.f.cjs')
2
- const json = require('../../json/module.f.cjs')
3
- const { sort } = require('../object/module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ import json from '../../json/module.f.mjs'
3
+ import o from '../object/module.f.mjs'
4
+ const { sort } = o
4
5
 
5
6
  const stringify = json.stringify(sort)
6
7
 
7
- module.exports = {
8
+ export default {
8
9
  stringify: () => {
9
10
  const result = stringify([1, 20, 300])
10
11
  if (result !== '[1,20,300]') { throw result }
@@ -1,5 +1,5 @@
1
- const compare = require('../function/compare/module.f.cjs')
2
- const { abs, sign } = require('../bigint/module.f.cjs')
1
+ import bi from '../bigint/module.f.mjs'
2
+ const { abs, sign } = bi
3
3
 
4
4
  /** @typedef {readonly[bigint,number]} BigFloat */
5
5
 
@@ -86,7 +86,7 @@ const decToBin = dec => {
86
86
  return multiply(r53)(s)
87
87
  }
88
88
 
89
- module.exports = {
89
+ export default {
90
90
  /** @readonly */
91
91
  decToBin,
92
92
  /** @readonly */
@@ -1,6 +1,7 @@
1
- const { decToBin } = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ const { decToBin } = _
2
3
 
3
- module.exports = {
4
+ export default {
4
5
  decToBin: [
5
6
  () => {
6
7
  const result = decToBin([0n, 0])
@@ -1,9 +1,10 @@
1
- const compare = require('../function/compare/module.f.cjs')
2
- const op = require('../function/operator/module.f.cjs')
1
+ import compare, * as compareT from '../function/compare/module.f.mjs'
2
+ import op, * as Op from '../function/operator/module.f.mjs'
3
3
  const { unsafeCmp } = compare
4
- const { reduce } = require('../list/module.f.cjs')
4
+ import list from '../list/module.f.mjs'
5
+ const { reduce } = list
5
6
 
6
- /** @typedef {op.Unary<bigint, bigint>} Unary*/
7
+ /** @typedef {Op.Unary<bigint, bigint>} Unary*/
7
8
 
8
9
  /** @type {(a: bigint) => (b: bigint) => bigint} */
9
10
  const addition = a => b => a + b
@@ -13,7 +14,7 @@ const sum = reduce(addition)(0n)
13
14
  /** @type {(a: bigint) => bigint} */
14
15
  const abs = a => a >= 0 ? a : -a
15
16
 
16
- /** @type {(a: bigint) => compare.Sign} */
17
+ /** @type {(a: bigint) => compareT.Sign} */
17
18
  const sign = a => unsafeCmp(a)(0n)
18
19
 
19
20
  /** @type {(a: bigint) => string} */
@@ -23,7 +24,7 @@ const serialize = a => `${a}n`
23
24
  * @template T
24
25
  * @typedef {{
25
26
  * readonly 0: T
26
- * readonly add: op.Reduce<T>
27
+ * readonly add: Op.Reduce<T>
27
28
  * }} Additive
28
29
  */
29
30
 
@@ -117,7 +118,7 @@ const bitLength = v => {
117
118
  return log2(v) + 1n
118
119
  }
119
120
 
120
- module.exports = {
121
+ export default {
121
122
  /** @readonly */
122
123
  addition,
123
124
  /** @readonly */
@@ -1,6 +1,7 @@
1
- const { sum, abs, serialize, log2, bitLength } = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ const { sum, abs, serialize, log2, bitLength } = _
2
3
 
3
- module.exports = {
4
+ export default {
4
5
  sum: () => {
5
6
  const result = sum([2n, 3n, 4n, 5n])
6
7
  if (result !== 14n) { throw result }
@@ -1,12 +1,12 @@
1
- const _ = require('../types/module.f.cjs')
2
- const list = require('../../list/module.f.cjs')
3
- const cmp = require('../../function/compare/module.f.cjs')
1
+ import * as _ from '../types/module.f.mjs'
2
+ import list, * as List from '../../list/module.f.mjs'
3
+ import cmp, * as cmpT from '../../function/compare/module.f.mjs'
4
4
  const { index3, index5 } = cmp
5
- const array = require('../../array/module.f.cjs')
5
+ import array, * as arrayT from '../../array/module.f.mjs'
6
6
 
7
7
  /**
8
8
  * @template T
9
- * @typedef {readonly[cmp.Index3, _.Leaf1<T>]} FirstLeaf1
9
+ * @typedef {readonly[cmpT.Index3, _.Leaf1<T>]} FirstLeaf1
10
10
  */
11
11
 
12
12
  /**
@@ -16,7 +16,7 @@ const array = require('../../array/module.f.cjs')
16
16
 
17
17
  /**
18
18
  * @template T
19
- * @typedef {readonly[cmp.Index5, _.Leaf2<T>]} FirstLeaf2
19
+ * @typedef {readonly[cmpT.Index5, _.Leaf2<T>]} FirstLeaf2
20
20
  */
21
21
 
22
22
  /**
@@ -50,7 +50,7 @@ const child = item =>
50
50
 
51
51
  /**
52
52
  * @template T
53
- * @typedef {list.List<PathItem<T>>} Path
53
+ * @typedef {List.List<PathItem<T>>} Path
54
54
  */
55
55
 
56
56
  /**
@@ -61,19 +61,19 @@ const child = item =>
61
61
  * }} Result<T>
62
62
  */
63
63
 
64
- /** @type {<T>(c: cmp.Compare<T>) => (node: _.Node<T>) => Result<T>} */
64
+ /** @type {<T>(c: cmpT.Compare<T>) => (node: _.Node<T>) => Result<T>} */
65
65
  const find = c => {
66
66
  const i3 = index3(c)
67
67
  const i5 = index5(c)
68
- /** @typedef {typeof c extends cmp.Compare<infer T> ? T : never} T */
68
+ /** @typedef {typeof c extends cmpT.Compare<infer T> ? T : never} T */
69
69
  /** @type {(prior: Path<T>) => (node: _.Node<T>) => Result<T>} */
70
70
  const f = tail => node => {
71
- /** @type {(index: array.KeyOf<typeof node>) => Result<T>} */
71
+ /** @type {(index: arrayT.KeyOf<typeof node>) => Result<T>} */
72
72
  const append = index => {
73
73
  const first = /** @type {PathItem<T>} */([index, node])
74
74
  return f({ first, tail })(child(first))
75
75
  }
76
- /** @type {(index: array.KeyOf<typeof node>) => Result<T>} */
76
+ /** @type {(index: arrayT.KeyOf<typeof node>) => Result<T>} */
77
77
  const done = index => ({ first: /** @type {First<T>} */([index, node]), tail })
78
78
  switch (node.length) {
79
79
  case 1: { return done(i3(node[0])) }
@@ -123,7 +123,7 @@ const value = ([i, r]) => {
123
123
  }
124
124
  }
125
125
 
126
- module.exports = {
126
+ export default {
127
127
  /** @readonly */
128
128
  find,
129
129
  /** @readonly */
@@ -1,17 +1,19 @@
1
- const _ = require('./module.f.cjs')
2
- const list = require('../../list/module.f.cjs')
3
- const json = require('../../../json/module.f.cjs')
4
- const { sort } = require('../../object/module.f.cjs')
5
- const btree = require('../types/module.f.cjs')
6
- const { cmp } = require('../../string/module.f.cjs')
7
- const s = require('../set/module.f.cjs')
1
+ import _, * as T from './module.f.mjs'
2
+ import list from '../../list/module.f.mjs'
3
+ import json, * as jsonT from '../../../json/module.f.mjs'
4
+ import o from '../../object/module.f.mjs'
5
+ const { sort } = o
6
+ import * as btree from '../types/module.f.mjs'
7
+ import string from '../../string/module.f.mjs'
8
+ const { cmp } = string
9
+ import s from '../set/module.f.mjs'
8
10
 
9
11
  const jsonStr = json.stringify(sort)
10
12
 
11
13
  /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
12
14
  const set = node => value => s.set(cmp(value))(() => value)(node)
13
15
 
14
- /** @type {(r: _.Result<json.Unknown>) => string} */
16
+ /** @type {(r: T.Result<jsonT.Unknown>) => string} */
15
17
  const str = r => jsonStr(list.toArray(list.map(x => x[0])(r)))
16
18
 
17
19
  /** @type {(i: string) => (m: btree.Node<string>) => string} */
@@ -113,4 +115,4 @@ const test = () => {
113
115
  }
114
116
  }
115
117
 
116
- module.exports = test
118
+ export default test
@@ -1,9 +1,10 @@
1
- const list = require('../list/module.f.cjs')
1
+ import list, * as List from '../list/module.f.mjs'
2
2
  const { flat } = list
3
- const { map } = require('../nullable/module.f.cjs')
4
- const _ = require('./types/module.f.cjs')
3
+ import n from '../nullable/module.f.mjs'
4
+ const { map } = n
5
+ import * as _ from './types/module.f.mjs'
5
6
 
6
- /** @type {<T>(node: _.Node<T>) => list.Thunk<T>} */
7
+ /** @type {<T>(node: _.Node<T>) => List.Thunk<T>} */
7
8
  const nodeValues = node => () => {
8
9
  switch (node.length) {
9
10
  case 1: case 2: { return node }
@@ -26,18 +27,12 @@ const nodeValues = node => () => {
26
27
  }
27
28
  }
28
29
 
29
- /** @type {<T>(tree: _.Tree<T>) => list.List<T>} */
30
+ /** @type {<T>(tree: _.Tree<T>) => List.List<T>} */
30
31
  const values = map(nodeValues)
31
32
 
32
- module.exports = {
33
+ export default {
33
34
  /** @readonly */
34
35
  empty: null,
35
36
  /** @readonly */
36
- find: require('./find/module.f.cjs'),
37
- /** @readonly */
38
- remove: require('./remove/module.f.cjs'),
39
- /** @readonly */
40
- set: require('./set/module.f.cjs'),
41
- /** @readonly */
42
37
  values,
43
38
  }
@@ -1,10 +1,11 @@
1
- const _ = require('../types/module.f.cjs')
2
- const cmp = require('../../function/compare/module.f.cjs')
3
- const find = require('../find/module.f.cjs')
4
- const list = require('../../list/module.f.cjs')
1
+ import * as _ from '../types/module.f.mjs'
2
+ import cmp, * as cmpT from '../../function/compare/module.f.mjs'
3
+ import find, * as findT from '../find/module.f.mjs'
4
+ import list from '../../list/module.f.mjs'
5
5
  const { fold, concat, next } = list
6
- const array = require('../../array/module.f.cjs')
7
- const { map } = require('../../nullable/module.f.cjs')
6
+ import array, * as arrayT from '../../array/module.f.mjs'
7
+ import n from '../../nullable/module.f.mjs'
8
+ const { map } = n
8
9
 
9
10
  /**
10
11
  * @template T
@@ -15,11 +16,11 @@ const { map } = require('../../nullable/module.f.cjs')
15
16
  * @template T
16
17
  * @typedef {{
17
18
  * readonly first: Leaf01<T>,
18
- * readonly tail: find.Path<T>
19
+ * readonly tail: findT.Path<T>
19
20
  * }} RemovePath
20
21
  */
21
22
 
22
- /** @type {<T>(tail: find.Path<T>) => (n: _.Node<T>) => readonly[T, RemovePath<T>]} */
23
+ /** @type {<T>(tail: findT.Path<T>) => (n: _.Node<T>) => readonly[T, RemovePath<T>]} */
23
24
  const path = tail => n => {
24
25
  switch (n.length) {
25
26
  case 1: { return [n[0], { first: null, tail }] }
@@ -93,10 +94,10 @@ const initValue1 = a => n => {
93
94
  * @typedef {(a: A) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} Merge
94
95
  */
95
96
 
96
- /** @type {<A, T>(ms: array.Array2<Merge<A, T>>) => (i: find.PathItem<T>) => (a: A) => Branch<T>} */
97
+ /** @type {<A, T>(ms: arrayT.Array2<Merge<A, T>>) => (i: findT.PathItem<T>) => (a: A) => Branch<T>} */
97
98
  const reduceX = ms => ([i, n]) => a => {
98
99
  const [m0, m2] = ms
99
- /** @typedef {typeof ms extends array.Array2<Merge<infer A, infer T>> ? [A,T] : never} AT */
100
+ /** @typedef {typeof ms extends arrayT.Array2<Merge<infer A, infer T>> ? [A,T] : never} AT */
100
101
  /** @typedef {AT[0]} A */
101
102
  /** @typedef {AT[1]} T */
102
103
  /** @type {(m: Merge<A, T>) => Branch<T>} */
@@ -115,15 +116,15 @@ const reduce = fold(reduceX([reduceValue0, reduceValue2]))
115
116
 
116
117
  const initReduce = reduceX([initValue0, initValue1])
117
118
 
118
- /** @type {<T>(c: cmp.Compare<T>) => (node: _.Node<T>) => _.Tree<T>} */
119
+ /** @type {<T>(c: cmpT.Compare<T>) => (node: _.Node<T>) => _.Tree<T>} */
119
120
  const nodeRemove = c => node => {
120
- /** @typedef {typeof c extends cmp.Compare<infer T> ? T : never} T */
121
+ /** @typedef {typeof c extends cmpT.Compare<infer T> ? T : never} T */
121
122
  /** @type {() => null | RemovePath<T>} */
122
123
  const f = () => {
123
124
  const { first, tail } = find.find(c)(node)
124
- /** @type {(n: _.Node<T>) => (f: (v: T) => find.PathItem<T>) => RemovePath<T>} */
125
+ /** @type {(n: _.Node<T>) => (f: (v: T) => findT.PathItem<T>) => RemovePath<T>} */
125
126
  const branch = n => f => {
126
- const [v, p] = path(/** @type {find.Path<T>} */(null))(n)
127
+ const [v, p] = path(/** @type {findT.Path<T>} */(null))(n)
127
128
  return { first: p.first, tail: concat(p.tail)({ first: f(v), tail }) }
128
129
  }
129
130
  const [i, n] = first
@@ -155,10 +156,10 @@ const nodeRemove = c => node => {
155
156
  return result.length === 1 ? result[0] : result
156
157
  }
157
158
 
158
- /** @type {<T>(c: cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>} */
159
+ /** @type {<T>(c: cmpT.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>} */
159
160
  const remove = c => map(nodeRemove(c))
160
161
 
161
- module.exports = {
162
+ export default {
162
163
  /** @readonly */
163
164
  nodeRemove,
164
165
  /** @readonly */
@@ -1,9 +1,11 @@
1
- const _ = require('./module.f.cjs')
2
- const btree = require('../types/module.f.cjs')
3
- const s = require('../set/module.f.cjs')
4
- const { cmp } = require('../../string/module.f.cjs')
5
- const json = require('../../../json/module.f.cjs')
6
- const { sort } = require('../../object/module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ import * as btree from '../types/module.f.mjs'
3
+ import s from '../set/module.f.mjs'
4
+ import str from '../../string/module.f.mjs'
5
+ const { cmp } = str
6
+ import json from '../../../json/module.f.mjs'
7
+ import o from '../../object/module.f.mjs'
8
+ const { sort } = o
7
9
 
8
10
  /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
9
11
  const set = node => value => s.set(cmp(value))(() => value)(node)
@@ -486,7 +488,7 @@ const test2 = () => {
486
488
  }
487
489
  }
488
490
 
489
- module.exports = {
491
+ export default {
490
492
  test,
491
493
  test2,
492
494
  }
@@ -1,8 +1,8 @@
1
- const _ = require('../types/module.f.cjs')
2
- const btreeFind = require('../find/module.f.cjs')
1
+ import * as _ from '../types/module.f.mjs'
2
+ import btreeFind, * as btreeFindT from '../find/module.f.mjs'
3
3
  const { find } = btreeFind
4
- const cmp = require('../../function/compare/module.f.cjs')
5
- const list = require('../../list/module.f.cjs')
4
+ import cmp, * as cmpT from '../../function/compare/module.f.mjs'
5
+ import list from '../../list/module.f.mjs'
6
6
  const { fold } = list
7
7
 
8
8
  /**
@@ -13,7 +13,7 @@ const { fold } = list
13
13
  /** @type {<T>(b: _.Branch5<T> | _.Branch7<T>) => Branch1To3<T>} */
14
14
  const b57 = b => b.length === 5 ? [b] : [[b[0], b[1], b[2]], b[3], [b[4], b[5], b[6]]]
15
15
 
16
- /** @type {<T>(i: btreeFind.PathItem<T>) => (a: Branch1To3<T>) => Branch1To3<T>} */
16
+ /** @type {<T>(i: btreeFindT.PathItem<T>) => (a: Branch1To3<T>) => Branch1To3<T>} */
17
17
  const reduceOp = ([i, x]) => a => {
18
18
  switch (i) {
19
19
  case 0: {
@@ -36,11 +36,11 @@ const reduceOp = ([i, x]) => a => {
36
36
 
37
37
  const reduceBranch = fold(reduceOp)
38
38
 
39
- /** @type {<T>(c: cmp.Compare<T>) => (g: (value: T | null) => T) => (node: _.Node<T>) => _.Node<T>} */
39
+ /** @type {<T>(c: cmpT.Compare<T>) => (g: (value: T | null) => T) => (node: _.Node<T>) => _.Node<T>} */
40
40
  const nodeSet = c => g => node => {
41
41
  const { first, tail } = find(c)(node)
42
42
  const [i, x] = first;
43
- /** @typedef {typeof c extends cmp.Compare<infer T> ? T : never} T */
43
+ /** @typedef {typeof c extends cmpT.Compare<infer T> ? T : never} T */
44
44
  /** @type {() => Branch1To3<T>} */
45
45
  const f = () => {
46
46
  switch (i) {
@@ -87,10 +87,10 @@ const nodeSet = c => g => node => {
87
87
  return r.length === 1 ? r[0] : r
88
88
  }
89
89
 
90
- /** @type {<T>(c: cmp.Compare<T>) => (f: (value: T|null) => T) => (tree: _.Tree<T>) => _.Node<T>} */
90
+ /** @type {<T>(c: cmpT.Compare<T>) => (f: (value: T|null) => T) => (tree: _.Tree<T>) => _.Node<T>} */
91
91
  const set = c => f => tree => tree === null ? [f(null)] : nodeSet(c)(f)(tree)
92
92
 
93
- module.exports = {
93
+ export default {
94
94
  /** @readonly */
95
95
  set,
96
96
  }
@@ -1,8 +1,10 @@
1
- const _ = require('./module.f.cjs')
2
- const btree = require('../types/module.f.cjs')
3
- const { cmp } = require('../../string/module.f.cjs')
4
- const json = require('../../../json/module.f.cjs')
5
- const { sort } = require('../../object/module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ import * as btree from '../types/module.f.mjs'
3
+ import s from '../../string/module.f.mjs'
4
+ const { cmp } = s
5
+ import json, * as jsonT from '../../../json/module.f.mjs'
6
+ import o from '../../object/module.f.mjs'
7
+ const { sort } = o
6
8
 
7
9
  /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
8
10
  const set = node => value => _.set(cmp(value))(() => value)(node)
@@ -380,4 +382,4 @@ const test = [
380
382
  }
381
383
  ]
382
384
 
383
- module.exports = test
385
+ export default test