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,8 @@
1
- const list = require('../../types/list/module.f.cjs')
1
+ import list from '../../types/list/module.f.mjs'
2
2
  const { fold } = list
3
- const { reset, fgGreen, fgRed, bold } = require('../../text/sgr/module.f.cjs')
4
- const result = require('../../types/result/module.f.cjs')
3
+ import sgr from '../../text/sgr/module.f.mjs'
4
+ const { reset, fgGreen, fgRed, bold } = sgr
5
+ import * as Result from '../../types/result/module.f.mjs'
5
6
 
6
7
  /**
7
8
  * @typedef {{
@@ -39,13 +40,13 @@ const result = require('../../types/result/module.f.cjs')
39
40
  * readonly error: Log<T>,
40
41
  * readonly measure: Measure<T>,
41
42
  * readonly state: T,
42
- * readonly tryCatch: <R>(f: () => R) => result.Result<R, unknown>,
43
+ * readonly tryCatch: <R>(f: () => R) => Result.Result<R, unknown>,
43
44
  * readonly env: (n: string) => string|undefined
44
45
  * }} Input
45
46
  */
46
47
 
47
48
  /** @type {(s: string) => boolean} */
48
- const isTest = s => s.endsWith('test.f.cjs')
49
+ const isTest = s => s.endsWith('test.f.cjs') || s.endsWith('test.f.mjs')
49
50
 
50
51
  /**
51
52
  * @typedef {{
@@ -66,6 +67,17 @@ const addFail = delta => ts => ({ ...ts, time: ts.time + delta, fail: ts.fail +
66
67
  * @typedef {readonly[TestState, T]} FullState
67
68
  */
68
69
 
70
+ /** @type {(a: number) => string} */
71
+ const timeFormat = a => {
72
+ const y = Math.round(a * 10_000).toString()
73
+ const yl = 5 - y.length
74
+ const x = '0'.repeat(yl > 0 ? yl : 0) + y
75
+ const s = x.length - 4
76
+ const b = x.substring(0, s)
77
+ const e = x.substring(s)
78
+ return `${b}.${e} ms`
79
+ }
80
+
69
81
  /** @type {<T>(input: Input<T>) => readonly[number, T]} */
70
82
  const main = input => {
71
83
  let { moduleMap, log, error, measure, tryCatch, env, state } = input
@@ -88,12 +100,12 @@ const main = input => {
88
100
  // https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
89
101
  state = error(`::error file=${k},line=1,title=[3]['a']()::${r}`)(state)
90
102
  } else {
91
- state = error(`${i}() ${fgRed}error${reset}, ${delta} ms`)(state)
103
+ state = error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`)(state)
92
104
  state = error(`${fgRed}${r}${reset}`)(state)
93
105
  }
94
106
  } else {
95
107
  ts = addPass(delta)(ts)
96
- state = log(`${i}() ${fgGreen}ok${reset}, ${delta} ms`)(state)
108
+ state = log(`${i}() ${fgGreen}ok${reset}, ${timeFormat(delta)}`)(state)
97
109
  }
98
110
  [ts, state] = next(r)([ts, state])
99
111
  }
@@ -130,8 +142,8 @@ const main = input => {
130
142
  [ts, state] = fold(f)([ts, state])(Object.entries(moduleMap))
131
143
  const fgFail = ts.fail === 0 ? fgGreen : fgRed
132
144
  state = log(`${bold}Number of tests: pass: ${fgGreen}${ts.pass}${reset}${bold}, fail: ${fgFail}${ts.fail}${reset}${bold}, total: ${ts.pass + ts.fail}${reset}`)(state)
133
- state = log(`${bold}Time: ${ts.time} ms${reset}`)(state);
145
+ state = log(`${bold}Time: ${timeFormat(ts.time)}${reset}`)(state);
134
146
  return [ts.fail !== 0 ? 1 : 0, state]
135
147
  }
136
148
 
137
- module.exports = main
149
+ export default main
@@ -4,7 +4,7 @@ const assert = () => { throw 'assert' }
4
4
  /** @type {(_: boolean) => void} */
5
5
  const assert_if = c => { if (c) { throw 'assert_if' } }
6
6
 
7
- module.exports = {
7
+ export default {
8
8
  ctor: () => {
9
9
  const c = (() => { })['constructor']
10
10
  const f = c('return 5')
package/dev/test.mjs CHANGED
@@ -45,7 +45,7 @@ const main = async() => {
45
45
  const moduleMap = await loadModuleMap()
46
46
 
47
47
  /** @type {any} */
48
- const f = moduleMap['./dev/test/module.f.cjs'].default
48
+ const f = moduleMap['./dev/test/module.f.mjs'].default
49
49
  const r = f({
50
50
  moduleMap,
51
51
  log: anyLog(console.log),
@@ -1,11 +1,15 @@
1
- const list = require('../types/list/module.f.cjs')
2
- const { flat, map, empty } = list
3
- const { concat } = require('../types/string/module.f.cjs')
4
- const object = require('../types/object/module.f.cjs')
5
- const { compose, fn } = require('../types/function/module.f.cjs')
1
+ import list, * as List from '../types/list/module.f.mjs'
2
+ const { flat, map } = list
3
+ import string from '../types/string/module.f.mjs'
4
+ const { concat } = string
5
+ import object, * as O from '../types/object/module.f.mjs'
6
+ import f from '../types/function/module.f.mjs'
7
+ const { compose, fn } = f
6
8
  const { entries } = Object
7
- const { serialize: bigintSerialize } = require('../types/bigint/module.f.cjs')
8
- const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = require('../json/serializer/module.f.cjs')
9
+ import bi from '../types/bigint/module.f.mjs'
10
+ const { serialize: bigintSerialize } = bi
11
+ import j from '../json/serializer/module.f.mjs'
12
+ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = j
9
13
 
10
14
  /**
11
15
  * @typedef {{
@@ -19,28 +23,28 @@ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize,
19
23
 
20
24
  const colon = [':']
21
25
 
22
- /** @typedef {object.Entry<Unknown>} Entry*/
26
+ /** @typedef {O.Entry<Unknown>} Entry*/
23
27
 
24
- /** @typedef {(list.List<Entry>)} Entries */
28
+ /** @typedef {(List.List<Entry>)} Entries */
25
29
 
26
30
  /** @typedef {(entries: Entries) => Entries} MapEntries */
27
31
 
28
- /** @type {(mapEntries: MapEntries) => (value: Unknown) => list.List<string>} */
32
+ /** @type {(mapEntries: MapEntries) => (value: Unknown) => List.List<string>} */
29
33
  const serialize = sort => {
30
- /** @type {(kv: readonly[string, Unknown]) => list.List<string>} */
34
+ /** @type {(kv: readonly[string, Unknown]) => List.List<string>} */
31
35
  const propertySerialize = ([k, v]) => flat([
32
36
  stringSerialize(k),
33
37
  colon,
34
38
  f(v)
35
39
  ])
36
40
  const mapPropertySerialize = map(propertySerialize)
37
- /** @type {(object: Object) => list.List<string>} */
41
+ /** @type {(object: Object) => List.List<string>} */
38
42
  const objectSerialize = fn(entries)
39
43
  .then(sort)
40
44
  .then(mapPropertySerialize)
41
45
  .then(objectWrap)
42
46
  .result
43
- /** @type {(value: Unknown) => list.List<string>} */
47
+ /** @type {(value: Unknown) => List.List<string>} */
44
48
  const f = value => {
45
49
  switch (typeof value) {
46
50
  case 'boolean': { return boolSerialize(value) }
@@ -66,8 +70,7 @@ const serialize = sort => {
66
70
  */
67
71
  const stringify = sort => compose(serialize(sort))(concat)
68
72
 
69
- module.exports = {
70
-
73
+ export default {
71
74
  /** @readonly */
72
75
  stringify,
73
76
  /** @readonly */
@@ -1,17 +1,18 @@
1
- const result = require('../../types/result/module.f.cjs')
2
- const list = require('../../types/list/module.f.cjs')
1
+ import result, * as Result from '../../types/result/module.f.mjs'
2
+ import list, * as List from '../../types/list/module.f.mjs'
3
3
  const { fold, first, drop, toArray } = list
4
- const operator = require('../../types/function/operator/module.f.cjs')
5
- const tokenizer = require('../tokenizer/module.f.cjs')
6
- const map = require('../../types/map/module.f.cjs')
4
+ import * as Operator from '../../types/function/operator/module.f.mjs'
5
+ import * as tokenizerT from '../tokenizer/module.f.mjs'
6
+ import map, * as Map from '../../types/map/module.f.mjs'
7
7
  const { setReplace } = map
8
- const djs = require('../module.f.cjs')
9
- const { fromMap } = require('../../types/object/module.f.cjs')
8
+ import * as Djs from '../module.f.mjs'
9
+ import o from '../../types/object/module.f.mjs'
10
+ const { fromMap } = o
10
11
 
11
12
  /**
12
13
  * @typedef {{
13
14
  * readonly kind: 'object'
14
- * readonly values: map.Map<djs.Unknown>
15
+ * readonly values: Map.Map<Djs.Unknown>
15
16
  * readonly key: string
16
17
  * }} JsonObject
17
18
  * */
@@ -19,7 +20,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
19
20
  /**
20
21
  * @typedef {{
21
22
  * readonly kind: 'array'
22
- * readonly values: list.List<djs.Unknown>
23
+ * readonly values: List.List<Djs.Unknown>
23
24
  * }} JsonArray
24
25
  * */
25
26
 
@@ -30,7 +31,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
30
31
  * } JsonStackElement
31
32
  */
32
33
 
33
- /** @typedef {list.List<JsonStackElement>} JsonStack */
34
+ /** @typedef {List.List<JsonStackElement>} JsonStack */
34
35
 
35
36
  /**
36
37
  * @typedef {{
@@ -50,7 +51,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
50
51
  /**
51
52
  * @typedef {{
52
53
  * readonly status: 'result'
53
- * readonly value: djs.Unknown
54
+ * readonly value: Djs.Unknown
54
55
  * }} StateResult
55
56
  */
56
57
 
@@ -70,7 +71,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
70
71
  * } DjsState
71
72
  */
72
73
 
73
- /** @type {(token: tokenizer.DjsToken) => (state: StateModule) => DjsState}} */
74
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateModule) => DjsState}} */
74
75
  const parseModuleOp = token => state => {
75
76
  switch(state.stage)
76
77
  {
@@ -101,10 +102,10 @@ const parseModuleOp = token => state => {
101
102
  /** @type {(obj: JsonObject) => (key: string) => JsonObject} */
102
103
  const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key })
103
104
 
104
- /** @type {(obj: JsonObject) => (value: djs.Unknown) => JsonObject} */
105
+ /** @type {(obj: JsonObject) => (value: Djs.Unknown) => JsonObject} */
105
106
  const addValueToObject = obj => value => ({ kind: 'object', values: setReplace(obj.key)(value)(obj.values), key: '' })
106
107
 
107
- /** @type {(array: JsonArray) => (value: djs.Unknown) => JsonArray} */
108
+ /** @type {(array: JsonArray) => (value: Djs.Unknown) => JsonArray} */
108
109
  const addToArray = array => value => ({ kind: 'array', values: list.concat(array.values)([value]) })
109
110
 
110
111
  /** @type {(state: StateParse) => (key: string) => DjsState} */
@@ -113,7 +114,7 @@ const pushKey = state => value => {
113
114
  return { status: 'error', message: 'error' }
114
115
  }
115
116
 
116
- /** @type {(state: StateParse) => (value: djs.Unknown) => DjsState} */
117
+ /** @type {(state: StateParse) => (value: Djs.Unknown) => DjsState} */
117
118
  const pushValue = state => value => {
118
119
  if (state.top === null) { return { status: 'result', value: value } }
119
120
  if (state.top.kind === 'array') { return { status: '[v', top: addToArray(state.top)(value), stack: state.stack } }
@@ -148,7 +149,7 @@ const endObject = state => {
148
149
  return pushValue(newState)(obj)
149
150
  }
150
151
 
151
- /** @type {(token: tokenizer.DjsToken) => djs.Unknown} */
152
+ /** @type {(token: tokenizerT.DjsToken) => Djs.Unknown} */
152
153
  const tokenToValue = token => {
153
154
  switch (token.kind) {
154
155
  case 'null': return null
@@ -161,7 +162,7 @@ const tokenToValue = token => {
161
162
  }
162
163
  }
163
164
 
164
- /** @type {(token: tokenizer.DjsToken) => boolean} */
165
+ /** @type {(token: tokenizerT.DjsToken) => boolean} */
165
166
  const isValueToken = token => {
166
167
  switch (token.kind) {
167
168
  case 'null':
@@ -174,7 +175,7 @@ const isValueToken = token => {
174
175
  }
175
176
  }
176
177
 
177
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
178
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
178
179
  const parseValueOp = token => state => {
179
180
  if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
180
181
  if (token.kind === '[') { return startArray(state) }
@@ -183,7 +184,7 @@ const parseValueOp = token => state => {
183
184
  return { status: 'error', message: 'unexpected token' }
184
185
  }
185
186
 
186
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
187
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
187
188
  const parseArrayStartOp = token => state => {
188
189
  if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
189
190
  if (token.kind === '[') { return startArray(state) }
@@ -193,7 +194,7 @@ const parseArrayStartOp = token => state => {
193
194
  return { status: 'error', message: 'unexpected token' }
194
195
  }
195
196
 
196
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
197
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
197
198
  const parseArrayValueOp = token => state => {
198
199
  if (token.kind === ']') { return endArray(state) }
199
200
  if (token.kind === ',') { return { status: '[,', top: state.top, stack: state.stack } }
@@ -201,7 +202,7 @@ const parseArrayValueOp = token => state => {
201
202
  return { status: 'error', message: 'unexpected token' }
202
203
  }
203
204
 
204
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
205
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
205
206
  const parseObjectStartOp = token => state => {
206
207
  if (token.kind === 'string') { return pushKey(state)(token.value) }
207
208
  if (token.kind === '}') { return endObject(state) }
@@ -209,14 +210,14 @@ const parseObjectStartOp = token => state => {
209
210
  return { status: 'error', message: 'unexpected token' }
210
211
  }
211
212
 
212
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
213
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
213
214
  const parseObjectKeyOp = token => state => {
214
215
  if (token.kind === ':') { return { status: '{:', top: state.top, stack: state.stack } }
215
216
  if (token.kind === 'ws') { return state }
216
217
  return { status: 'error', message: 'unexpected token' }
217
218
  }
218
219
 
219
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
220
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
220
221
  const parseObjectColonOp = token => state => {
221
222
  if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
222
223
  if (token.kind === '[') { return startArray(state) }
@@ -225,7 +226,7 @@ const parseObjectColonOp = token => state => {
225
226
  return { status: 'error', message: 'unexpected token' }
226
227
  }
227
228
 
228
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
229
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
229
230
  const parseObjectNextOp = token => state => {
230
231
  if (token.kind === '}') { return endObject(state) }
231
232
  if (token.kind === ',') { return { status: '{,', top: state.top, stack: state.stack } }
@@ -233,14 +234,14 @@ const parseObjectNextOp = token => state => {
233
234
  return { status: 'error', message: 'unexpected token' }
234
235
  }
235
236
 
236
- /** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
237
+ /** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
237
238
  const parseObjectCommaOp = token => state => {
238
239
  if (token.kind === 'string') { return pushKey(state)(token.value) }
239
240
  if (token.kind === 'ws') { return state }
240
241
  return { status: 'error', message: 'unexpected token' }
241
242
  }
242
243
 
243
- /** @type {operator.Fold<tokenizer.DjsToken, DjsState>} */
244
+ /** @type {Operator.Fold<tokenizerT.DjsToken, DjsState>} */
244
245
  const foldOp = token => state => {
245
246
  switch (state.status) {
246
247
  case 'module': return parseModuleOp(token)(state)
@@ -258,7 +259,7 @@ const foldOp = token => state => {
258
259
  }
259
260
  }
260
261
 
261
- /** @type {(tokenList: list.List<tokenizer.DjsToken>) => result.Result<djs.Unknown, string>} */
262
+ /** @type {(tokenList: List.List<tokenizerT.DjsToken>) => Result.Result<Djs.Unknown, string>} */
262
263
  const parse = tokenList => {
263
264
  const state = fold(foldOp)({ status: 'module', stage: 'module' })(tokenList)
264
265
  switch (state.status) {
@@ -268,7 +269,7 @@ const parse = tokenList => {
268
269
  }
269
270
  }
270
271
 
271
- module.exports = {
272
+ export default {
272
273
  /** @readonly */
273
274
  parse
274
275
  }
@@ -1,16 +1,18 @@
1
- const parser = require('./module.f.cjs')
2
- const tokenizer = require('../tokenizer/module.f.cjs')
3
- const { toArray } = require('../../types/list/module.f.cjs')
4
- const djs = require('../module.f.cjs')
5
- const { sort } = require('../../types/object/module.f.cjs')
6
- const encoding = require('../../text/utf16/module.f.cjs');
1
+ import parser from './module.f.mjs'
2
+ import tokenizer, * as tokenizerT from '../tokenizer/module.f.mjs'
3
+ import list from '../../types/list/module.f.mjs'
4
+ const { toArray } = list
5
+ import djs from '../module.f.mjs'
6
+ import o from '../../types/object/module.f.mjs'
7
+ const { sort } = o
8
+ import encoding from '../../text/utf16/module.f.mjs'
7
9
 
8
- /** @type {(s: string) => readonly tokenizer.DjsToken[]} */
10
+ /** @type {(s: string) => readonly tokenizerT.DjsToken[]} */
9
11
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
10
12
 
11
13
  const stringify = djs.stringify(sort)
12
14
 
13
- module.exports = {
15
+ export default {
14
16
  valid: [
15
17
  () => {
16
18
  const tokenList = tokenizeString('module.exports=null')
@@ -1,9 +1,11 @@
1
- const json = require('../json/module.f.cjs')
2
- const { sort } = require('../types/object/module.f.cjs')
3
- const { identity } = require('../types/function/module.f.cjs')
4
- const djs= require('./module.f.cjs')
1
+ import json from '../json/module.f.mjs'
2
+ import list from '../types/object/module.f.mjs'
3
+ const { sort } = list
4
+ import f from '../types/function/module.f.mjs'
5
+ const { identity } = f
6
+ import djs from './module.f.mjs'
5
7
 
6
- module.exports = {
8
+ export default {
7
9
  stringify: [
8
10
  {
9
11
  sort: () => {
@@ -1,19 +1,20 @@
1
- const operator = require('../../types/function/operator/module.f.cjs')
2
- const list = require('../../types/list/module.f.cjs')
1
+ import operator, * as Operator from '../../types/function/operator/module.f.mjs'
2
+ import list, * as List from '../../types/list/module.f.mjs'
3
3
  const { empty, flat, stateScan } = list
4
- const { multiply } = require('../../types/bigfloat/module.f.cjs')
5
- const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
4
+ import bf from '../../types/bigfloat/module.f.mjs'
5
+ const { multiply } = bf
6
+ import jsTokenizer, * as jsTokenizerT from '../../js/tokenizer/module.f.mjs'
6
7
 
7
8
  /**
8
9
  * @typedef {|
9
10
  * {readonly kind: 'true' | 'false' | 'null'} |
10
11
  * {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' | '.' | '=' } |
11
- * jsTokenizer.StringToken |
12
- * jsTokenizer.NumberToken |
13
- * jsTokenizer.ErrorToken |
14
- * jsTokenizer.IdToken |
15
- * jsTokenizer.BigIntToken |
16
- * jsTokenizer.WhitespaceToken
12
+ * jsTokenizerT.StringToken |
13
+ * jsTokenizerT.NumberToken |
14
+ * jsTokenizerT.ErrorToken |
15
+ * jsTokenizerT.IdToken |
16
+ * jsTokenizerT.BigIntToken |
17
+ * jsTokenizerT.WhitespaceToken
17
18
  * } DjsToken
18
19
  */
19
20
 
@@ -25,11 +26,11 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
25
26
 
26
27
  /**
27
28
  * @typedef {|
28
- * jsTokenizer.JsToken | null
29
+ * jsTokenizerT.JsToken | null
29
30
  * } ScanInput
30
31
  */
31
32
 
32
- /** @type {(input: jsTokenizer.JsToken) => list.List<DjsToken>} */
33
+ /** @type {(input: jsTokenizerT.JsToken) => List.List<DjsToken>} */
33
34
  const mapToken = input =>
34
35
  {
35
36
  switch(input.kind)
@@ -55,7 +56,7 @@ const mapToken = input =>
55
56
  }
56
57
  }
57
58
 
58
- /** @type {(input: ScanInput) => readonly [list.List<DjsToken>, ScanState]} */
59
+ /** @type {(input: ScanInput) => readonly [List.List<DjsToken>, ScanState]} */
59
60
  const parseDefaultState = input =>
60
61
  {
61
62
  if (input === null) return [empty, { kind: 'def'}]
@@ -66,7 +67,7 @@ const parseDefaultState = input =>
66
67
  }
67
68
  }
68
69
 
69
- /** @type {(input: ScanInput) => readonly [list.List<DjsToken>, ScanState]} */
70
+ /** @type {(input: ScanInput) => readonly [List.List<DjsToken>, ScanState]} */
70
71
  const parseMinusState = input =>
71
72
  {
72
73
  if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
@@ -79,7 +80,7 @@ const parseMinusState = input =>
79
80
  }
80
81
  }
81
82
 
82
- /** @type {operator.StateScan<ScanInput, ScanState, list.List<DjsToken>>} */
83
+ /** @type {Operator.StateScan<ScanInput, ScanState, List.List<DjsToken>>} */
83
84
  const scanToken = state => input => {
84
85
  switch(state.kind)
85
86
  {
@@ -88,15 +89,15 @@ const scanToken = state => input => {
88
89
  }
89
90
  }
90
91
 
91
- /** @type {(input: list.List<number>) => list.List<DjsToken>} */
92
+ /** @type {(input: List.List<number>) => List.List<DjsToken>} */
92
93
  const tokenize = input =>
93
94
  {
94
- /** @type {list.List<ScanInput>} */
95
+ /** @type {List.List<ScanInput>} */
95
96
  const jsTokens = jsTokenizer.tokenize(input)
96
97
  return flat(stateScan(scanToken)({ kind: 'def' })(list.concat(jsTokens)([null])))
97
98
  }
98
99
 
99
- module.exports = {
100
+ export default {
100
101
  /** @readonly */
101
102
  tokenize
102
103
  }
@@ -1,15 +1,17 @@
1
- const tokenizer = require('./module.f.cjs')
2
- const { toArray, countdown } = require('../../types/list/module.f.cjs')
3
- const djs = require('../../djs/module.f.cjs')
4
- const { sort } = require('../../types/object/module.f.cjs')
5
- const encoding = require('../../text/utf16/module.f.cjs');
1
+ import tokenizer, * as tokenizerT from './module.f.mjs'
2
+ import list from '../../types/list/module.f.mjs'
3
+ const { toArray, countdown } = list
4
+ import djs from '../module.f.mjs'
5
+ import o from '../../types/object/module.f.mjs'
6
+ const { sort } = o
7
+ import encoding from '../../text/utf16/module.f.mjs'
6
8
 
7
- /** @type {(s: string) => readonly tokenizer.DjsToken[]} */
9
+ /** @type {(s: string) => readonly tokenizerT.DjsToken[]} */
8
10
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
9
11
 
10
12
  const stringify = djs.stringify(sort)
11
13
 
12
- module.exports = {
14
+ export default {
13
15
  djs: [
14
16
  () => {
15
17
  const result = tokenizeString('')
@@ -1,12 +1,14 @@
1
- const operator = require('../types/function/operator/module.f.cjs')
2
- const range_map = require('../types/range_map/module.f.cjs')
1
+ import operator from '../types/function/operator/module.f.mjs'
2
+ import range_map, * as RM from '../types/range_map/module.f.mjs'
3
3
  const { merge: rangeMapMerge, fromRange, get } = range_map
4
- const { reduce: listReduce } = require('../types/list/module.f.cjs')
5
- const { range: asciiRange } = require('../text/ascii/module.f.cjs')
4
+ import list, * as List from '../types/list/module.f.mjs'
5
+ const { reduce: listReduce } = list
6
+ import ascii from '../text/ascii/module.f.mjs'
7
+ const { range: asciiRange } = ascii
6
8
  const { fromCharCode } = String
7
- const { fn } = require('../types/function/module.f.cjs')
8
- const list = require('../types/list/module.f.cjs')
9
- const _range = require('../types/range/module.f.cjs')
9
+ import f from '../types/function/module.f.mjs'
10
+ const { fn } = f
11
+ import _range, * as Range from '../types/range/module.f.mjs'
10
12
  const { one } = _range
11
13
  const { toArray, map } = list
12
14
 
@@ -21,7 +23,7 @@ const { toArray, map } = list
21
23
 
22
24
  /**
23
25
  * @template T
24
- * @typedef {range_map.RangeMapArray<CreateToResult<T>>} State
26
+ * @typedef {RM.RangeMapArray<CreateToResult<T>>} State
25
27
  */
26
28
 
27
29
  /** @type {ToResult} */
@@ -40,10 +42,10 @@ const union = a => b => {
40
42
  /** @type {readonly never[]} */
41
43
  const empty = []
42
44
 
43
- /** @type {<T>(a: list.List<State<T>>) => State<T>} */
45
+ /** @type {<T>(a: List.List<State<T>>) => State<T>} */
44
46
  const reduce = a => {
45
- /** @typedef {typeof a extends list.List<State<infer T>> ? T : never} T */
46
- /** @type {range_map.RangeMerge<CreateToResult<T>>} */
47
+ /** @typedef {typeof a extends List.List<State<infer T>> ? T : never} T */
48
+ /** @type {RM.RangeMerge<CreateToResult<T>>} */
47
49
  const merge = rangeMapMerge({
48
50
  union,
49
51
  equal: operator.strictEqual,
@@ -51,7 +53,6 @@ const reduce = a => {
51
53
  return toArray(listReduce(merge)(empty)(a))
52
54
  }
53
55
 
54
-
55
56
  const codePointRange = fromRange(def)
56
57
 
57
58
  const range = fn(asciiRange).then(codePointRange).result
@@ -59,16 +60,16 @@ const range = fn(asciiRange).then(codePointRange).result
59
60
  /** @type {(l: readonly string[]) => <T>(f: CreateToResult<T>) => State<T>} */
60
61
  const rangeSet = l => f => {
61
62
  /** @typedef {typeof f extends CreateToResult<infer T> ? T : never} T */
62
- /** @type {(a: _range.Range) => (f: CreateToResult<T>) => State<T>} */
63
+ /** @type {(a: Range.Range) => (f: CreateToResult<T>) => State<T>} */
63
64
  const codePointRange = fromRange(def)
64
65
  /** @type {(r: string) => State<T>} */
65
66
  const g = r => codePointRange(asciiRange(r))(f)
66
67
  return reduce(map(g)(l))
67
68
  }
68
69
 
69
- /** @type {<T>(a: list.List<State<T>>) => CreateToResult<T>} */
70
+ /** @type {<T>(a: List.List<State<T>>) => CreateToResult<T>} */
70
71
  const create = a => {
71
- /** @typedef {typeof a extends list.List<State<infer T>> ? T : never} T */
72
+ /** @typedef {typeof a extends List.List<State<infer T>> ? T : never} T */
72
73
  const i = reduce(a)
73
74
  /** @type {(v: number) => (i: State<T>) => (v: T) => ToResult} */
74
75
  const x = get(def)
@@ -114,7 +115,7 @@ const init = create([
114
115
  range('~')(() => () => [['~'], unexpectedSymbol]),
115
116
  ])(void 0)
116
117
 
117
- module.exports = {
118
+ export default {
118
119
  /** @readonly */
119
120
  terminal,
120
121
  /** @readonly */
@@ -1,6 +1,8 @@
1
- const _ = require('./module.f.cjs')
2
- const { one } = require('../text/ascii/module.f.cjs')
3
- const { stringify } = require('../json/module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ import ascii from '../text/ascii/module.f.mjs'
3
+ const { one } = ascii
4
+ import j from '../json/module.f.mjs'
5
+ const { stringify } = j
4
6
  const s = stringify(i => i)
5
7
 
6
8
  /** @type {(v: string) => string} */
@@ -9,7 +11,7 @@ const f = v => {
9
11
  return s(_.init(n)[0])
10
12
  }
11
13
 
12
- module.exports = {
14
+ export default {
13
15
  a: () => {
14
16
  const x = f('1')
15
17
  if (x != '["1"]') { throw x }