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,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 json = 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 json 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.JsonToken[]} */
10
+ /** @type {(s: string) => readonly tokenizerT.JsonToken[]} */
9
11
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
10
12
 
11
13
  const stringify = json.stringify(sort)
12
14
 
13
- module.exports = {
15
+ export default {
14
16
  valid: [
15
17
  () => {
16
18
  const tokenList = tokenizeString('null')
@@ -1,7 +1,7 @@
1
- const list = require('../../types/list/module.f.cjs')
1
+ import list, * as List from '../../types/list/module.f.mjs'
2
2
  const { flat, reduce, empty } = list
3
- const object = require('../../types/object/module.f.cjs')
4
- const operator = require('../../types/function/operator/module.f.cjs')
3
+ import object, * as O from '../../types/object/module.f.mjs'
4
+ import operator, * as Operator from '../../types/function/operator/module.f.mjs'
5
5
 
6
6
  /**
7
7
  * @template T
@@ -36,10 +36,10 @@ const operator = require('../../types/function/operator/module.f.cjs')
36
36
 
37
37
  const jsonStringify = JSON.stringify
38
38
 
39
- /** @type {(_: string) => list.List<string>} */
39
+ /** @type {(_: string) => List.List<string>} */
40
40
  const stringSerialize = input => [jsonStringify(input)]
41
41
 
42
- /** @type {(_: number) => list.List<string>} */
42
+ /** @type {(_: number) => List.List<string>} */
43
43
  const numberSerialize = input => [jsonStringify(input)]
44
44
 
45
45
  const nullSerialize = ['null']
@@ -48,18 +48,18 @@ const trueSerialize = ['true']
48
48
 
49
49
  const falseSerialize = ['false']
50
50
 
51
- /** @type {(_: boolean) => list.List<string>} */
51
+ /** @type {(_: boolean) => List.List<string>} */
52
52
  const boolSerialize = value => value ? trueSerialize : falseSerialize
53
53
 
54
54
  const comma = [',']
55
55
 
56
- /** @type {operator.Reduce<list.List<string>>} */
56
+ /** @type {Operator.Reduce<List.List<string>>} */
57
57
  const joinOp = b => prior => flat([prior, comma, b])
58
58
 
59
- /** @type {(input: list.List<list.List<string>>) => list.List<string>} */
59
+ /** @type {(input: List.List<List.List<string>>) => List.List<string>} */
60
60
  const join = reduce(joinOp)(empty)
61
61
 
62
- /** @type {(open: string) => (close: string) => (input: list.List<list.List<string>>) => list.List<string>} */
62
+ /** @type {(open: string) => (close: string) => (input: List.List<List.List<string>>) => List.List<string>} */
63
63
  const wrap = open => close => {
64
64
  const seqOpen = [open]
65
65
  const seqClose = [close]
@@ -72,12 +72,12 @@ const arrayWrap = wrap('[')(']')
72
72
 
73
73
  /**
74
74
  * @template T
75
- * @typedef {object.Entry<Unknown<T>>} Entry<T>
75
+ * @typedef {O.Entry<Unknown<T>>} Entry<T>
76
76
  */
77
77
 
78
78
  /**
79
79
  * @template T
80
- * @typedef {(list.List<Entry<T>>)} Entries<T>
80
+ * @typedef {(List.List<Entry<T>>)} Entries<T>
81
81
  */
82
82
 
83
83
  /**
@@ -85,7 +85,7 @@ const arrayWrap = wrap('[')(']')
85
85
  * @typedef {(entries: Entries<T>) => Entries<T>} MapEntries<T>
86
86
  */
87
87
 
88
- module.exports = {
88
+ export default {
89
89
  /** @readonly */
90
90
  objectWrap,
91
91
  /** @readonly */
@@ -1,7 +1,8 @@
1
- const _ = require('./module.f.cjs')
2
- const { toArray } = require('../../types/list/module.f.cjs')
1
+ import _, * as T from './module.f.mjs'
2
+ import list from '../../types/list/module.f.mjs'
3
+ const { toArray } = list
3
4
 
4
- module.exports = {
5
+ export default {
5
6
  arrayWrap: [
6
7
  () => {
7
8
  const result = JSON.stringify(toArray(_.arrayWrap(null)))
@@ -1,8 +1,10 @@
1
- const json = require('./module.f.cjs')
2
- const { sort } = require('../types/object/module.f.cjs')
3
- const { identity } = require('../types/function/module.f.cjs')
1
+ import json from './module.f.mjs'
2
+ import o from '../types/object/module.f.mjs'
3
+ const { sort } = o
4
+ import f from '../types/function/module.f.mjs'
5
+ const { identity } = f
4
6
 
5
- module.exports = {
7
+ export default {
6
8
  setProperty: () => {
7
9
  if (json.setProperty("Hello")([])({}) !== "Hello") { throw 'error' }
8
10
  },
@@ -1,16 +1,17 @@
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
12
+ * jsTokenizerT.StringToken |
13
+ * jsTokenizerT.NumberToken |
14
+ * jsTokenizerT.ErrorToken
14
15
  * } JsonToken
15
16
  */
16
17
 
@@ -22,11 +23,11 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
22
23
 
23
24
  /**
24
25
  * @typedef {|
25
- * jsTokenizer.JsToken | null
26
+ * jsTokenizerT.JsToken | null
26
27
  * } ScanInput
27
28
  */
28
29
 
29
- /** @type {(input: jsTokenizer.JsToken) => list.List<JsonToken>} */
30
+ /** @type {(input: jsTokenizerT.JsToken) => List.List<JsonToken>} */
30
31
  const mapToken = input =>
31
32
  {
32
33
  switch(input.kind)
@@ -48,7 +49,7 @@ const mapToken = input =>
48
49
  }
49
50
  }
50
51
 
51
- /** @type {(input: ScanInput) => readonly [list.List<JsonToken>, ScanState]} */
52
+ /** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
52
53
  const parseDefaultState = input =>
53
54
  {
54
55
  if (input === null) return [empty, { kind: 'def'}]
@@ -59,7 +60,7 @@ const parseDefaultState = input =>
59
60
  }
60
61
  }
61
62
 
62
- /** @type {(input: ScanInput) => readonly [list.List<JsonToken>, ScanState]} */
63
+ /** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
63
64
  const parseMinusState = input =>
64
65
  {
65
66
  if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
@@ -71,7 +72,7 @@ const parseMinusState = input =>
71
72
  }
72
73
  }
73
74
 
74
- /** @type {operator.StateScan<ScanInput, ScanState, list.List<JsonToken>>} */
75
+ /** @type {Operator.StateScan<ScanInput, ScanState, List.List<JsonToken>>} */
75
76
  const scanToken = state => input => {
76
77
  switch(state.kind)
77
78
  {
@@ -80,15 +81,15 @@ const scanToken = state => input => {
80
81
  }
81
82
  }
82
83
 
83
- /** @type {(input: list.List<number>) => list.List<JsonToken>} */
84
+ /** @type {(input: List.List<number>) => List.List<JsonToken>} */
84
85
  const tokenize = input =>
85
86
  {
86
- /** @type {list.List<ScanInput>} */
87
+ /** @type {List.List<ScanInput>} */
87
88
  const jsTokens = jsTokenizer.tokenize(input)
88
89
  return flat(stateScan(scanToken)({ kind: 'def' })(list.concat(jsTokens)([null])))
89
90
  }
90
91
 
91
- module.exports = {
92
+ export default {
92
93
  /** @readonly */
93
94
  tokenize
94
95
  }
@@ -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 '../../djs/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.JsonToken[]} */
9
+ /** @type {(s: string) => readonly tokenizerT.JsonToken[]} */
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
  json: [
14
16
  () => {
15
17
  const result = tokenizeString('')
package/jsr.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@functionalscript/functionalscript",
3
- "version": "0.0.592",
3
+ "version": "0.1.594",
4
4
  "exports": "./index.f.mjs"
5
5
  }
@@ -0,0 +1,5 @@
1
+ import _ from './module.f.mjs'
2
+ import child_process from 'node:child_process'
3
+ import fs from 'node:fs'
4
+
5
+ _.version({ child_process, fs })
@@ -26,7 +26,7 @@ const { stringify, parse } = JSON
26
26
 
27
27
  /** @type {<T>(node: Node<T>) => readonly[T, T]} */
28
28
  const version = ({ child_process, fs }) => {
29
- const version = `0.0.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
29
+ const version = `0.1.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
30
30
  const f = (/** @type {string} */jsonFile) => {
31
31
  const file = `${jsonFile}.json`
32
32
  return fs.writeFileSync(
@@ -45,7 +45,7 @@ const version = ({ child_process, fs }) => {
45
45
  ]
46
46
  }
47
47
 
48
- module.exports = {
48
+ export default {
49
49
  /** @readonly */
50
50
  version,
51
51
  }
@@ -1,4 +1,4 @@
1
- const _ = require('./module.f.cjs')
1
+ import _, * as T from './module.f.mjs'
2
2
 
3
3
  const x = {
4
4
  "name": "functionalscript",
@@ -38,7 +38,7 @@ const x = {
38
38
 
39
39
  const e = '{\n' +
40
40
  ' "name": "functionalscript",\n' +
41
- ' "version": "0.0.2",\n' +
41
+ ' "version": "0.1.2",\n' +
42
42
  ' "description": "FunctionalScript is a functional subset of JavaScript",\n' +
43
43
  ' "main": "module.f.cjs",\n' +
44
44
  ' "scripts": {\n' +
@@ -72,13 +72,13 @@ const e = '{\n' +
72
72
  ' }\n' +
73
73
  '}'
74
74
 
75
- /** @type {(s: string) => _.Buffer} */
75
+ /** @type {(s: string) => T.Buffer} */
76
76
  const buffer = s => ({
77
77
  toString: () => s
78
78
  })
79
79
 
80
- module.exports = () => {
81
- /** @type {_.Node<string>} */
80
+ export default () => {
81
+ /** @type {T.Node<string>} */
82
82
  const node = {
83
83
  child_process: { execSync: () => buffer("123\n456\n") },
84
84
  fs: {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.592",
3
+ "version": "0.1.594",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.f.mjs",
6
6
  "scripts": {
7
7
  "tsc": "tsc",
8
8
  "test": "tsc && npm run test-only",
9
9
  "index": "node ./dev/index.mjs",
10
- "version": "node ./nodejs/version/main.cjs",
10
+ "version": "node ./nodejs/version/main.mjs",
11
11
  "test-only": "node --trace-uncaught ./dev/test.mjs",
12
- "comtest": "node ./com/test/build.cjs"
12
+ "comtest": "node ./com/test/build.mjs"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -1,9 +1,10 @@
1
- const op = require('../types/function/operator/module.f.cjs')
2
- const { scalar_mul } = require('../types/bigint/module.f.cjs')
1
+ import * as Operator from '../types/function/operator/module.f.mjs'
2
+ import bi from '../types/bigint/module.f.mjs'
3
+ const { scalar_mul } = bi
3
4
 
4
- /** @typedef {op.Reduce<bigint>} Reduce */
5
+ /** @typedef {Operator.Reduce<bigint>} Reduce */
5
6
 
6
- /** @typedef {op.Unary<bigint, bigint>} Unary*/
7
+ /** @typedef {Operator.Unary<bigint, bigint>} Unary*/
7
8
 
8
9
  /**
9
10
  * @typedef {{
@@ -75,7 +76,7 @@ const prime_field = p => {
75
76
  }
76
77
  }
77
78
 
78
- module.exports = {
79
+ export default {
79
80
  prime_field,
80
81
  /** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
81
82
  sqrt: ({p, mul, pow }) => {
@@ -1,6 +1,7 @@
1
- const { prime_field, sqrt } = require('./module.f.cjs')
1
+ import _ from './module.f.mjs'
2
+ const { prime_field, sqrt } = _
2
3
 
3
- module.exports = {
4
+ export default {
4
5
  prime_field_test: () => {
5
6
  const p = 0xffffffff_ffffffff_ffffffff_ffffffff_ffffffff_ffffffff_fffffffe_fffffc2fn;
6
7
  const f = prime_field(p)
@@ -1,6 +1,7 @@
1
- const op = require('../types/function/operator/module.f.cjs')
2
- const pf = require('../prime_field/module.f.cjs')
3
- const { scalar_mul } = require('../types/bigint/module.f.cjs')
1
+ import * as op from '../types/function/operator/module.f.mjs'
2
+ import pf, * as pfT from '../prime_field/module.f.mjs'
3
+ import bi from '../types/bigint/module.f.mjs'
4
+ const { scalar_mul } = bi
4
5
  const { prime_field, sqrt } = pf
5
6
 
6
7
  /** @typedef {readonly[bigint, bigint]} Point2D */
@@ -18,8 +19,8 @@ const { prime_field, sqrt } = pf
18
19
 
19
20
  /**
20
21
  * @typedef {{
21
- * readonly pf: pf.PrimeField
22
- * readonly nf: pf.PrimeField
22
+ * readonly pf: pfT.PrimeField
23
+ * readonly nf: pfT.PrimeField
23
24
  * readonly y2: (x: bigint) => bigint
24
25
  * readonly y: (x: bigint) => bigint|null
25
26
  * readonly neg: (a: Point) => Point
@@ -83,7 +84,7 @@ const curve = ({ p, a: [a0, a1], n }) => {
83
84
  }
84
85
  }
85
86
 
86
- module.exports = {
87
+ export default {
87
88
  curve,
88
89
  /** @type {(a: Point) => (b: Point) => boolean} */
89
90
  eq: a => b => {
@@ -1,13 +1,13 @@
1
- const m = require('./module.f.cjs')
2
- const { curve, secp256k1, secp192r1, eq } = m
1
+ import mt, * as mT from './module.f.mjs'
2
+ const { curve, secp256k1, secp192r1, eq } = mt
3
3
 
4
- module.exports = {
4
+ export default {
5
5
  test: () => {
6
- /** @type {(c: m.Init) => void} */
6
+ /** @type {(c: mT.Init) => void} */
7
7
  const test_curve = c => {
8
8
  const { g } = c
9
9
  const { mul, neg, pf: { abs }, y: yf, nf: { p: n } } = curve(c)
10
- /** @type {(p: m.Point) => void} */
10
+ /** @type {(p: mT.Point) => void} */
11
11
  const point_check = p => {
12
12
  if (p === null) { throw 'null' }
13
13
  const [x, y] = p
@@ -17,7 +17,7 @@ module.exports = {
17
17
  }
18
18
  point_check(g)
19
19
  point_check(neg(g))
20
- /** @type {(p: m.Point) => void} */
20
+ /** @type {(p: mT.Point) => void} */
21
21
  const test_mul = p => {
22
22
  if (mul(p)(0n) !== null) { throw 'O' }
23
23
  if (mul(p)(1n) !== p) { throw 'p' }
@@ -1,4 +1,4 @@
1
- const array = require('../types/array/module.f.cjs')
1
+ import array, * as arrayT from '../types/array/module.f.mjs'
2
2
 
3
3
  /**
4
4
  * @typedef {{
@@ -7,9 +7,9 @@ const array = require('../types/array/module.f.cjs')
7
7
  * }} HashInput
8
8
  */
9
9
 
10
- /** @typedef {array.Array8<number>} Hash8 */
10
+ /** @typedef {arrayT.Array8<number>} Hash8 */
11
11
 
12
- /** @typedef {array.Array16<number>} Array16 */
12
+ /** @typedef {arrayT.Array16<number>} Array16 */
13
13
 
14
14
  /** @type {(input: number) => (pos: number) => number} */
15
15
  const appendOneWithZeros = input => pos => (input >> pos << pos) | (1 << pos)
@@ -73,7 +73,7 @@ const smallSigma0 = smallSigma(7)(18)(3)
73
73
 
74
74
  const smallSigma1 = smallSigma(17)(19)(10)
75
75
 
76
- /** @type {(a: array.Array4<number>) => number} */
76
+ /** @type {(a: arrayT.Array4<number>) => number} */
77
77
  const wi = ([a0, a1, a2, a3]) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) | 0
78
78
 
79
79
  /** @type {(w: Array16) => Array16} */
@@ -194,7 +194,7 @@ const compress256 = compress(init256)
194
194
 
195
195
  const compress224 = compress(init224)
196
196
 
197
- module.exports = {
197
+ export default {
198
198
  /** @readonly */
199
199
  padding,
200
200
  /** @readonly */
@@ -1,7 +1,8 @@
1
- const _ = 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 _ 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
7
  /** @type {(a: number) => number} */
7
8
  const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
@@ -9,7 +10,7 @@ const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
9
10
  /** @type {(a: number) => string} */
10
11
  const toHexString = x => toU32(x).toString(16).padStart(8, '0')
11
12
 
12
- /** @type {(a: readonly json.Unknown[]) => string} */
13
+ /** @type {(a: readonly jsonT.Unknown[]) => string} */
13
14
  const stringify = a => json.stringify(sort)(a)
14
15
 
15
16
  // {
@@ -32,7 +33,7 @@ const stringify = a => json.stringify(sort)(a)
32
33
  // console.log(result.map(toHexString))
33
34
  // }
34
35
 
35
- module.exports = {
36
+ export default {
36
37
  empty: {
37
38
  sha256: () => {
38
39
  const hash = _.computeSha256([])(0)
@@ -1,4 +1,4 @@
1
- const _range = require('../../types/range/module.f.cjs')
1
+ import _range, * as Range from '../../types/range/module.f.mjs'
2
2
 
3
3
  /** @type {(s: string) => (i: number) => number} */
4
4
  const at = s => i => {
@@ -10,7 +10,7 @@ const at = s => i => {
10
10
  /** @type {(s: string) => number} */
11
11
  const one = s => at(s)(0)
12
12
 
13
- /** @type {(s: string) => _range.Range} */
13
+ /** @type {(s: string) => Range.Range} */
14
14
  const range = s => {
15
15
  const f = at(s)
16
16
  const f0 = f(0)
@@ -18,7 +18,7 @@ const range = s => {
18
18
  return [f0, f(1)]
19
19
  }
20
20
 
21
- module.exports = {
21
+ export default {
22
22
  /** @readonly */
23
23
  one,
24
24
  /** @readonly */
@@ -0,0 +1,14 @@
1
+ import _ from './module.f.mjs'
2
+ const { range } = _
3
+ import json from '../../json/module.f.mjs'
4
+ import o from '../../types/object/module.f.mjs'
5
+ const { sort } = o
6
+
7
+ const stringify = json.stringify(sort)
8
+
9
+ export default {
10
+ range: () => {
11
+ const r = stringify(range("A"))
12
+ if (r !== '[65,65]') { throw r }
13
+ }
14
+ }
@@ -1,20 +1,20 @@
1
- const list = require('../types/list/module.f.cjs')
1
+ import list, * as List from '../types/list/module.f.mjs'
2
2
  const { flatMap } = list
3
3
 
4
4
  /** @typedef {ItemThunk|ItemArray} Block */
5
5
 
6
6
  /** @typedef {readonly Item[]} ItemArray */
7
7
 
8
- /** @typedef {() => list.List<Item>} ItemThunk */
8
+ /** @typedef {() => List.List<Item>} ItemThunk */
9
9
 
10
10
  /** @typedef {string|ItemArray|ItemThunk} Item */
11
11
 
12
- /** @type {(indent: string) => (text: Block) => list.List<string>} */
12
+ /** @type {(indent: string) => (text: Block) => List.List<string>} */
13
13
  const flat = indent => {
14
14
 
15
- /** @type {(prefix: string) => (text: Block) => list.List<string>} */
15
+ /** @type {(prefix: string) => (text: Block) => List.List<string>} */
16
16
  const f = prefix => {
17
- /** @type {(item: Item) => list.List<string>} */
17
+ /** @type {(item: Item) => List.List<string>} */
18
18
  const g = item => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item)
19
19
  return flatMap(g)
20
20
  }
@@ -25,7 +25,7 @@ const flat = indent => {
25
25
  /** @type {(type: string) => (name: string) => (body: Block) => Block} */
26
26
  const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
27
27
 
28
- module.exports = {
28
+ export default {
29
29
  /** @readonly */
30
30
  flat,
31
31
  /** @readonly */
@@ -5,7 +5,7 @@
5
5
  */
6
6
  const sgr = c => `\x1b[${c.toString()}m`
7
7
 
8
- module.exports = {
8
+ export default {
9
9
  /** @readonly */
10
10
  sgr,
11
11
  /** @readonly */
@@ -1,8 +1,9 @@
1
- const _ = require('./module.f.cjs')
2
- const { join } = require('../types/string/module.f.cjs')
1
+ import _, * as T from './module.f.mjs'
2
+ import string from '../types/string/module.f.mjs'
3
+ const { join } = string
3
4
 
4
- module.exports = () => {
5
- /** @type {_.Block} */
5
+ export default () => {
6
+ /** @type {T.Block} */
6
7
  const text = [
7
8
  'a',
8
9
  'b',