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,6 +1,7 @@
1
- const obj = require('../../types/object/module.f.cjs')
2
- const list = require('../../types/list/module.f.cjs')
3
- const { compose } = require('../../types/function/module.f.cjs')
1
+ import obj, * as O from '../../types/object/module.f.mjs'
2
+ import list, * as List from '../../types/list/module.f.mjs'
3
+ import f from '../../types/function/module.f.mjs'
4
+ const { compose } = f
4
5
  const { filter } = list
5
6
  const { entries } = Object
6
7
 
@@ -16,7 +17,7 @@ const { entries } = Object
16
17
 
17
18
  /** @typedef {{readonly[k in string]: Type}} FieldArray */
18
19
 
19
- /** @typedef {obj.Entry<Type>} Field */
20
+ /** @typedef {O.Entry<Type>} Field */
20
21
 
21
22
  /**
22
23
  * @typedef {{
@@ -27,7 +28,7 @@ const { entries } = Object
27
28
 
28
29
  /** @typedef {{readonly[k in string]: FieldArray}} MethodArray */
29
30
 
30
- /** @typedef {obj.Entry<FieldArray>} Method */
31
+ /** @typedef {O.Entry<FieldArray>} Method */
31
32
 
32
33
  /** @typedef {BaseType|Id|Pointer} Type */
33
34
 
@@ -53,18 +54,18 @@ const { entries } = Object
53
54
 
54
55
  /** @typedef {readonly['*', Type]} Pointer */
55
56
 
56
- /** @type {(kv: obj.Entry<Type>) => boolean} */
57
+ /** @type {(kv: O.Entry<Type>) => boolean} */
57
58
  const isParam = ([name]) => name !== '_'
58
59
 
59
60
  const filterParam = filter(isParam)
60
61
 
61
- /** @type {(fa: FieldArray) => list.List<Field> } */
62
+ /** @type {(fa: FieldArray) => List.List<Field> } */
62
63
  const paramList = compose(entries)(filterParam)
63
64
 
64
65
  /** @type {<T>(v: T) => (f: (type: Type) => T) => (fa: FieldArray) => T} */
65
66
  const result = v => f => fa => '_' in fa ? f(fa._) : v
66
67
 
67
- module.exports = {
68
+ export default {
68
69
  /** @readonly */
69
70
  paramList,
70
71
  /** @readonly */
@@ -1,7 +1,7 @@
1
- const _ = require('./module.f.cjs')
1
+ import * as _ from './module.f.mjs'
2
2
 
3
3
  /** @type {_.Library} */
4
- module.exports = {
4
+ export default {
5
5
  Slice: {
6
6
  struct: {
7
7
  Start: ['*', 'u8'],
@@ -1,29 +1,29 @@
1
- const package_ = require('../package/module.f.cjs')
2
- const module_ = require('../module/module.f.cjs')
1
+ import package_, * as packageT from '../package/module.f.mjs'
2
+ import module_, * as moduleT from '../module/module.f.mjs'
3
3
  const { idToString, dir } = module_
4
- const function_ = require('../module/function/module.f.cjs')
5
- const map = require('../../types/map/module.f.cjs')
4
+ import * as function_ from '../module/function/module.f.mjs'
5
+ import map, * as Map from '../../types/map/module.f.mjs'
6
6
  const { empty: mapEmpty, setReplace } = map
7
- const object = require('../../types/object/module.f.cjs')
7
+ import object from '../../types/object/module.f.mjs'
8
8
  const { fromMap } = object
9
- const path = require('../path/module.f.cjs')
9
+ import path from '../path/module.f.mjs'
10
10
  const { parseAndFind } = path
11
- const stringSet = require('../../types/string_set/module.f.cjs')
11
+ import stringSet, * as StringSet from '../../types/string_set/module.f.mjs'
12
12
  const { set: setSet, contains: setContains, empty: stringSetEmpty } = stringSet
13
13
 
14
14
  /**
15
15
  * @template M
16
16
  * @typedef {{
17
- * readonly packageGet: package_.Get
18
- * readonly moduleMapInterface: module_.MapInterface<M>
19
- * readonly moduleId: module_.Id
17
+ * readonly packageGet: packageT.Get
18
+ * readonly moduleMapInterface: moduleT.MapInterface<M>
19
+ * readonly moduleId: moduleT.Id
20
20
  * readonly moduleMap: M
21
21
  * }} Config
22
22
  */
23
23
 
24
24
  /**
25
25
  * @template M
26
- * @typedef {readonly[module_.State, M]} Result
26
+ * @typedef {readonly[moduleT.State, M]} Result
27
27
  */
28
28
 
29
29
  /** @type {<M>(moduleMap: M) => Result<M>} */
@@ -31,19 +31,19 @@ const notFound = moduleMap => [['error', ['file not found']], moduleMap]
31
31
 
32
32
  /**
33
33
  * @type {(compile: function_.Compile) =>
34
- * (packageGet: package_.Get) =>
35
- * <M>(moduleMapInterface: module_.MapInterface<M>) =>
36
- * (moduleId: module_.Id) =>
34
+ * (packageGet: packageT.Get) =>
35
+ * <M>(moduleMapInterface: moduleT.MapInterface<M>) =>
36
+ * (moduleId: moduleT.Id) =>
37
37
  * (moduleMap: M) =>
38
38
  * Result<M>
39
39
  * }
40
40
  */
41
41
  const getOrBuild = compile => packageGet => moduleMapInterface => {
42
- /** @typedef {typeof moduleMapInterface extends module_.MapInterface<infer M> ? M : never} M */
42
+ /** @typedef {typeof moduleMapInterface extends moduleT.MapInterface<infer M> ? M : never} M */
43
43
 
44
44
  /**
45
- * @type {(buildSet: stringSet.StringSet) =>
46
- * (moduleId: module_.Id) =>
45
+ * @type {(buildSet: StringSet.StringSet) =>
46
+ * (moduleId: moduleT.Id) =>
47
47
  * (source: string) =>
48
48
  * (moduleMap: M) =>
49
49
  * Result<M>}
@@ -52,9 +52,9 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
52
52
  const moduleIdStr = idToString(moduleId)
53
53
  const buildSet1 = setSet(moduleIdStr)(buildSet)
54
54
  const moduleDir = dir(moduleId)
55
- /** @type {function_.Require<readonly[map.Map<string>, M]>} */
55
+ /** @type {function_.Require<readonly[Map.Map<string>, M]>} */
56
56
  const require_ = p => ([requireMap, m]) => {
57
- /** @type {(e: unknown) => function_.Result<readonly[map.Map<string>, M]>} */
57
+ /** @type {(e: unknown) => function_.Result<readonly[Map.Map<string>, M]>} */
58
58
  const error = e => [['error', e], [requireMap, m]]
59
59
  if (moduleDir === null) { return error('file not found') }
60
60
  const r = parseAndFind(packageGet)(moduleDir)(p)
@@ -65,9 +65,9 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
65
65
  return [state[0] === 'error' ? state : ['ok', state[1].exports], [setReplace(p)(rIdStr)(requireMap), m1]]
66
66
  }
67
67
  return source => moduleMap => {
68
- /** @type {(s: module_.State) => (m: M) => Result<M>} */
68
+ /** @type {(s: moduleT.State) => (m: M) => Result<M>} */
69
69
  const set = s => m => [s, moduleMapInterface.setReplace(moduleIdStr)(s)(m)]
70
- /** @type {(e: module_.Error) => (m: M) => Result<M>} */
70
+ /** @type {(e: moduleT.Error) => (m: M) => Result<M>} */
71
71
  const error = e => set(['error', e])
72
72
  // check compilation
73
73
  const [kind, result] = compile(source)
@@ -80,7 +80,7 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
80
80
  return x(moduleMap2)
81
81
  }
82
82
  }
83
- /** @type {(moduleId: module_.Id) => (moduleMap: M) => Result<M>} */
83
+ /** @type {(moduleId: moduleT.Id) => (moduleMap: M) => Result<M>} */
84
84
  const f = moduleId => moduleMap => {
85
85
  const moduleIdStr = idToString(moduleId)
86
86
  // check moduleMap
@@ -98,7 +98,7 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
98
98
  return f
99
99
  }
100
100
 
101
- module.exports = {
101
+ export default {
102
102
  /** @readonly */
103
103
  getOrBuild,
104
104
  }
@@ -1,12 +1,13 @@
1
- const _ = require('./module.f.cjs')
2
- const map = require('../../types/map/module.f.cjs')
3
- const module_ = require('../module/module.f.cjs')
4
- const function_ = require('../module/function/module.f.cjs')
5
- const result = require('../../types/result/module.f.cjs')
6
- const package_ = require('../package/module.f.cjs')
7
- const { at } = require('../../types/object/module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ import map, * as Map from '../../types/map/module.f.mjs'
3
+ import * as Module from '../module/module.f.mjs'
4
+ import * as ModuleFunction from '../module/function/module.f.mjs'
5
+ import * as Result from '../../types/result/module.f.mjs'
6
+ import * as Package from '../package/module.f.mjs'
7
+ import o from '../../types/object/module.f.mjs'
8
+ const { at } = o
8
9
 
9
- /** @type {{ readonly [k in string]?: result.Result<function_.Function_, unknown> }} */
10
+ /** @type {{ readonly [k in string]?: Result.Result<ModuleFunction.Function_, unknown> }} */
10
11
  const compileMap = {
11
12
  ':index.js': [
12
13
  'ok',
@@ -30,7 +31,7 @@ const compileMap = {
30
31
  () => m0 => [['ok', 'x:r.js'], m0]],
31
32
  }
32
33
 
33
- /** @type {function_.Compile} */
34
+ /** @type {ModuleFunction.Compile} */
34
35
  const compile = source => compileMap[source] ?? ['error', 'invalid source']
35
36
 
36
37
  /** @typedef {{ readonly [k in string]: string }} StringMap */
@@ -55,7 +56,7 @@ const packageMap = {
55
56
  },
56
57
  }
57
58
 
58
- /** @type {package_.Get} */
59
+ /** @type {Package.Get} */
59
60
  const packageGet = packageId => {
60
61
  const p = at(packageId)(packageMap)
61
62
  return p === null ? null :
@@ -68,9 +69,9 @@ const packageGet = packageId => {
68
69
  const getOrBuild = _.getOrBuild
69
70
  (compile)
70
71
  (packageGet)
71
- (/** @type {module_.MapInterface<map.Map<module_.State>>} */(map))
72
+ (/** @type {Module.MapInterface<Map.Map<Module.State>>} */(map))
72
73
 
73
- module.exports = () => {
74
+ export default () => {
74
75
  let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(map.empty)
75
76
  {
76
77
  if (r === null) { throw 'r === null' }
@@ -2,13 +2,13 @@
2
2
  * An IO interface for creating and running module functions.
3
3
  */
4
4
 
5
- const result = require('../../../types/result/module.f.cjs')
5
+ import * as Result from '../../../types/result/module.f.mjs'
6
6
 
7
7
  /** @typedef {<M>(require: Require<M>) => (prior: M) => Result<M>} Function_ */
8
8
 
9
9
  /**
10
10
  * @template M
11
- * @typedef {readonly[result.Result<unknown, unknown>, M]} Result
11
+ * @typedef {readonly[Result.Result<unknown, unknown>, M]} Result
12
12
  */
13
13
 
14
14
  /**
@@ -16,6 +16,6 @@ const result = require('../../../types/result/module.f.cjs')
16
16
  * @typedef {(path: string) => (prior: M) => Result<M>} Require
17
17
  */
18
18
 
19
- /** @typedef {(source: string) => result.Result<Function_, unknown>} Compile */
19
+ /** @typedef {(source: string) => Result.Result<Function_, unknown>} Compile */
20
20
 
21
- module.exports = {}
21
+ export default {}
@@ -1,4 +1,4 @@
1
- const object = require('../../types/object/module.f.cjs')
1
+ import object, * as O from '../../types/object/module.f.mjs'
2
2
 
3
3
  /**
4
4
  * @template M
@@ -18,7 +18,7 @@ const object = require('../../types/object/module.f.cjs')
18
18
  /**
19
19
  * @typedef {{
20
20
  * readonly exports: unknown
21
- * readonly requireMap: object.Map<string>
21
+ * readonly requireMap: O.Map<string>
22
22
  * }} Module
23
23
  */
24
24
 
@@ -51,9 +51,7 @@ const dir = id => {
51
51
  /** @type {(id: Id) => string} */
52
52
  const idToString = id => `${id.package}/${id.path.join('/')}`
53
53
 
54
- module.exports = {
55
- /** @readonly */
56
- function: require('./function/module.f.cjs'),
54
+ export default {
57
55
  /** @readonly */
58
56
  dir,
59
57
  /** @readonly */
@@ -0,0 +1,11 @@
1
+ /** @typedef {(packageName: string) => PackageMap|Package|null} PackageMap */
2
+
3
+ /**
4
+ * @typedef {readonly[
5
+ * string,
6
+ * PackageMap,
7
+ * (fileName: string) => string|null
8
+ * ]} Package
9
+ */
10
+
11
+ export default {}
@@ -1,8 +1,10 @@
1
- const { tryCatch } = require('../types/result/module.cjs')
2
- const { unwrap } = require('../types/result/module.f.cjs')
3
- const moduleFunction = require('./module/function/module.f.cjs')
1
+ import unsafeResult from '../types/result/module.mjs'
2
+ const { tryCatch } = unsafeResult
3
+ import result from '../types/result/module.f.mjs'
4
+ const { unwrap } = result
5
+ import * as ModuleFunction from './module/function/module.f.mjs'
4
6
 
5
- /** @type {(f: Function) => moduleFunction.Function_} */
7
+ /** @type {(f: Function) => ModuleFunction.Function_} */
6
8
  const build = f => immutableRequire => mutableData => {
7
9
  /** @type {(path: string) => unknown} */
8
10
  const mutableRequire = path => {
@@ -20,12 +22,12 @@ const build = f => immutableRequire => mutableData => {
20
22
  return [result, mutableData]
21
23
  }
22
24
 
23
- /** @type {moduleFunction.Compile} */
25
+ /** @type {ModuleFunction.Compile} */
24
26
  const compile = source =>
25
27
  // Side effect: a `Function` constructor is not allowed in FunctionalScript.
26
28
  tryCatch(() => build(Function('module', 'require', `"use strict";${source}`)))
27
29
 
28
- module.exports = {
30
+ export default {
29
31
  /** @readonly */
30
32
  compile,
31
33
  }
@@ -1,6 +1,6 @@
1
- const json = require('../../../json/module.f.cjs')
1
+ import json, * as jsonT from '../../../json/module.f.mjs'
2
2
  const { isObject } = json
3
- const list = require('../../../types/list/module.f.cjs')
3
+ import list from '../../../types/list/module.f.mjs'
4
4
  const { map, every } = list
5
5
  const { entries } = Object
6
6
 
@@ -10,17 +10,17 @@ const { entries } = Object
10
10
 
11
11
  /** @typedef {DependencyMapJson|null} DependenciesJson */
12
12
 
13
- /** @type {(entry: json.Entry) => boolean} */
13
+ /** @type {(entry: jsonT.Entry) => boolean} */
14
14
  const isDependencyJson = ([, v]) => typeof v === 'string'
15
15
 
16
- /** @type {(j: json.Unknown) => j is DependenciesJson} */
16
+ /** @type {(j: jsonT.Unknown) => j is DependenciesJson} */
17
17
  const isDependenciesJson = j => {
18
18
  if (j === null) { return true }
19
19
  if (!isObject(j)) { return false }
20
20
  return every(map(isDependencyJson)(entries(j)))
21
21
  }
22
22
 
23
- module.exports = {
23
+ export default {
24
24
  /** @readonly */
25
25
  isDependenciesJson,
26
26
  }
@@ -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 (!_.isDependenciesJson(null)) { throw 'error' }
5
5
  if (!_.isDependenciesJson({})) { throw 'error' }
6
6
  if (!_.isDependenciesJson({'a':'b'})) { throw 'error' }
@@ -1,18 +1,19 @@
1
- const json = require('../../json/module.f.cjs')
1
+ import json, * as jsonT from '../../json/module.f.mjs'
2
2
  const { isObject } = json
3
- const dependencies = require('./dependencies/module.f.cjs')
3
+ import dependencies, * as dependenciesT from './dependencies/module.f.mjs'
4
4
  const { isDependenciesJson } = dependencies
5
- const { at } = require('../../types/object/module.f.cjs')
5
+ import o from '../../types/object/module.f.mjs'
6
+ const { at } = o
6
7
 
7
8
  /**
8
9
  * @typedef {{
9
10
  * readonly name: string
10
11
  * readonly version: string
11
- * readonly dependencies?: dependencies.DependenciesJson
12
+ * readonly dependencies?: dependenciesT.DependenciesJson
12
13
  * }} PackageJson
13
14
  */
14
15
 
15
- /** @type {(j: json.Unknown) => j is PackageJson} */
16
+ /** @type {(j: jsonT.Unknown) => j is PackageJson} */
16
17
  const isPackageJson = j => {
17
18
  if (!isObject(j)) { return false }
18
19
  if (typeof j.name !== 'string') { return false }
@@ -33,7 +34,7 @@ const isPackageJson = j => {
33
34
  * @typedef {(packageId: string) => Package | null} Get
34
35
  */
35
36
 
36
- module.exports = {
37
+ export default {
37
38
  /** @readonly */
38
39
  dependencies,
39
40
  /** @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 (_.isPackageJson(null)) { throw 'error' }
5
5
  if (_.isPackageJson({})) { throw 'error' }
6
6
  if (_.isPackageJson({name:'x',version:12})) { throw 'error' }
@@ -1,8 +1,9 @@
1
- const list = require("../../types/list/module.f.cjs")
1
+ import list, * as List from '../../types/list/module.f.mjs'
2
2
  const { next, fold, reverse, first, flat, toArray, filterMap, isEmpty, concat } = list
3
- const { join } = require('../../types/string/module.f.cjs')
4
- const package_ = require("../package/module.f.cjs")
5
- const module_ = require("../module/module.f.cjs")
3
+ import string from '../../types/string/module.f.mjs'
4
+ const { join } = string
5
+ import package_, * as packageT from '../package/module.f.mjs'
6
+ import module_, * as moduleT from '../module/module.f.mjs'
6
7
 
7
8
  /** @typedef {readonly string[]} Items */
8
9
 
@@ -17,7 +18,7 @@ const module_ = require("../module/module.f.cjs")
17
18
  /** @type {(path: string) => readonly string[]} */
18
19
  const split = path => path.split('/')
19
20
 
20
- /** @typedef {readonly[list.List<string>] | null} OptionList */
21
+ /** @typedef {readonly[List.List<string>] | null} OptionList */
21
22
 
22
23
  /** @type {(items: string) => (prior: OptionList) => OptionList} */
23
24
  const normItemsOp = first => prior => {
@@ -36,7 +37,7 @@ const normItemsOp = first => prior => {
36
37
  }
37
38
  }
38
39
 
39
- /** @type {(items: list.List<string>) => OptionList} */
40
+ /** @type {(items: List.List<string>) => OptionList} */
40
41
  const normItems = items => {
41
42
  const result = fold(normItemsOp)([list.empty])(items)
42
43
  return result === null ? result : [reverse(result[0])]
@@ -46,7 +47,7 @@ const firstNull = first(null)
46
47
 
47
48
  /** @type {(local: string) => (path: string) => LocalPath|null} */
48
49
  const parseLocal = local => {
49
- /** @type {(path: string) => readonly[boolean, boolean, list.List<string>]} */
50
+ /** @type {(path: string) => readonly[boolean, boolean, List.List<string>]} */
50
51
  const fSeq = path => {
51
52
  const pathSeq = split(path)
52
53
  const dir = [null, '', '.', '..'].includes(pathSeq[pathSeq.length - 1])
@@ -67,9 +68,9 @@ const parseLocal = local => {
67
68
  }
68
69
  }
69
70
 
70
- /** @typedef {readonly[string, list.List<string>]} IdPath */
71
+ /** @typedef {readonly[string, List.List<string>]} IdPath */
71
72
 
72
- /** @type {(prior: readonly[string|null, list.List<string>]) => list.Thunk<IdPath>} */
73
+ /** @type {(prior: readonly[string|null, List.List<string>]) => List.Thunk<IdPath>} */
73
74
  const variants = prior => () => {
74
75
  const [a, b] = prior
75
76
  const r = next(b)
@@ -97,7 +98,7 @@ const mapDependency = d => ([external, internal]) => {
97
98
  /**
98
99
  * @type {(d: (local: string) => string|null) =>
99
100
  * (dir: boolean) =>
100
- * (items: list.List<string>) =>
101
+ * (items: List.List<string>) =>
101
102
  * Path|null}
102
103
  */
103
104
  const parseGlobal = dependencies =>
@@ -131,7 +132,7 @@ const parse = packageId => dependencies => {
131
132
 
132
133
  /**
133
134
  * @typedef {{
134
- * readonly id: module_.Id
135
+ * readonly id: moduleT.Id
135
136
  * readonly source: string
136
137
  * }} FoundResult
137
138
  */
@@ -139,8 +140,8 @@ const parse = packageId => dependencies => {
139
140
  /** @typedef {FoundResult| null} Result */
140
141
 
141
142
  /**
142
- * @type {(packageGet: package_.Get) =>
143
- * (moduleId: module_.Id) =>
143
+ * @type {(packageGet: packageT.Get) =>
144
+ * (moduleId: moduleT.Id) =>
144
145
  * (path: string) =>
145
146
  * Result
146
147
  * }
@@ -163,7 +164,7 @@ const parseAndFind = packageGet => moduleId => path => {
163
164
  return firstNull(filterMap(tryFile)(fileList))
164
165
  }
165
166
 
166
- module.exports = {
167
+ export default {
167
168
  /** @readonly */
168
169
  parseLocal,
169
170
  /** @readonly */
@@ -1,18 +1,20 @@
1
- const _ = require('./module.f.cjs')
2
- const { todo } = require('../../dev/module.f.cjs')
3
- const json = require('../../json/module.f.cjs')
4
- const { identity } = require('../../types/function/module.f.cjs')
5
- const object = require('../../types/object/module.f.cjs')
6
- const { at } = require('../../types/object/module.f.cjs')
7
- const package_ = require('../package/module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ import dev from '../../dev/module.f.mjs'
3
+ const { todo } = dev
4
+ import json, * as jsonT from '../../json/module.f.mjs'
5
+ import f from '../../types/function/module.f.mjs'
6
+ const { identity } = f
7
+ import object, * as O from '../../types/object/module.f.mjs'
8
+ const { at } = object
9
+ import * as packageT from '../package/module.f.mjs'
8
10
 
9
- /** @type {<T>(o: object.Map<T>) => (s: string) => T|null} */
11
+ /** @type {<T>(o: O.Map<T>) => (s: string) => T|null} */
10
12
  const i = o => s => at(s)(o)
11
13
 
12
- /** @type {(g: json.Unknown) => string} */
14
+ /** @type {(g: jsonT.Unknown) => string} */
13
15
  const stringify = json.stringify(identity)
14
16
 
15
- module.exports = {
17
+ export default {
16
18
  0: () => {
17
19
  const result = _.parseLocal('')('./a')
18
20
  if (stringify(result) !== '{"external":false,"dir":false,"items":["a"]}') { throw result }
@@ -68,7 +70,7 @@ module.exports = {
68
70
  },
69
71
  },
70
72
  9: () => {
71
- /** @type {object.Map<package_.Package>} */
73
+ /** @type {O.Map<packageT.Package>} */
72
74
  const packages = {
73
75
  '': {
74
76
  dependency: () => todo(),
@@ -79,7 +81,7 @@ module.exports = {
79
81
  if (result !== '{"id":{"package":"","path":["a","c"]},"source":"return \\"a/c\\""}') { throw result }
80
82
  },
81
83
  10: () => {
82
- /** @type {object.Map<package_.Package>} */
84
+ /** @type {O.Map<packageT.Package>} */
83
85
  const packages = {
84
86
  '': {
85
87
  dependency: x => {
@@ -129,7 +131,7 @@ module.exports = {
129
131
  }
130
132
  },
131
133
  11: () => {
132
- /** @type {object.Map<package_.Package>} */
134
+ /** @type {O.Map<packageT.Package>} */
133
135
  const packages = {
134
136
  '': {
135
137
  dependency: x => {
@@ -156,7 +158,7 @@ module.exports = {
156
158
  }
157
159
  },
158
160
  12: () => {
159
- /** @type {object.Map<package_.Package>} */
161
+ /** @type {O.Map<packageT.Package>} */
160
162
  const packages = {
161
163
  '': {
162
164
  dependency: x => {
@@ -1,7 +1,7 @@
1
- const _ = require('./module.cjs')
2
- const run = require('./module/function/module.f.cjs')
1
+ import _ from './module.mjs'
2
+ import run, * as runT from './module/function/module.f.mjs'
3
3
 
4
- module.exports = {
4
+ export default {
5
5
  ok: () => {
6
6
  const source = 'module.exports = "Hello world!"'
7
7
  const m = _.compile(source)
@@ -32,7 +32,7 @@ module.exports = {
32
32
  const d = _.compile(depSource)
33
33
  if (d[0] !== 'ok') { throw d }
34
34
 
35
- /** @type {run.Require<number>} */
35
+ /** @type {runT.Require<number>} */
36
36
  const req = path => prior => {
37
37
  if (path !== 'm') { throw path }
38
38
  return d[1](req)(prior + 1)
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  /** @readonly */
3
3
  todo: () => { throw 'not implemented' },
4
4
  }
package/dev/module.mjs CHANGED
@@ -86,7 +86,7 @@ export const loadModuleMap = async () => {
86
86
  const file = `${p}/${name}`
87
87
  if (i.isDirectory()) {
88
88
  await f(file)
89
- } else if (name.endsWith('.f.cjs')) {
89
+ } else if (name.endsWith('.f.cjs') || name.endsWith('.f.mjs')) {
90
90
  const source = await import(`../${file}`)
91
91
  map.push([file, source.default])
92
92
  }
@@ -183,8 +183,10 @@ export const index = async() => {
183
183
  let m = {}
184
184
  for (const k in await loadModuleMap()) {
185
185
  const [, ...s] = k.split('/')
186
- if (s[s.length - 1] === 'module.f.cjs') {
187
- m = folderMapAdd(m)(s)
186
+ switch (s[s.length - 1]) {
187
+ case 'module.f.cjs': case 'module.f.mjs':
188
+ m = folderMapAdd(m)(s)
189
+ break
188
190
  }
189
191
  }
190
192
  const [e, i] = codeAdd(indent)('')(m)