functionalscript 0.1.609 → 0.2.0

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 (175) hide show
  1. package/com/cpp/module.f.d.mts +4 -8
  2. package/com/cpp/module.f.mjs +20 -25
  3. package/com/cpp/testlib.f.mjs +3 -4
  4. package/com/cs/module.f.d.mts +4 -8
  5. package/com/cs/module.f.mjs +18 -23
  6. package/com/cs/testlib.f.mjs +3 -5
  7. package/com/rust/module.f.d.mts +3 -7
  8. package/com/rust/module.f.mjs +25 -30
  9. package/com/rust/testlib.f.mjs +3 -5
  10. package/com/test/build.f.d.mts +2 -2
  11. package/com/test/build.f.mjs +2 -2
  12. package/com/test/build.mjs +4 -4
  13. package/com/types/module.f.d.mts +5 -10
  14. package/com/types/module.f.mjs +5 -12
  15. package/commonjs/build/module.f.d.mts +13 -17
  16. package/commonjs/build/module.f.mjs +23 -28
  17. package/commonjs/build/test.f.mjs +4 -4
  18. package/commonjs/module/function/module.f.d.mts +0 -2
  19. package/commonjs/module/function/module.f.mjs +0 -2
  20. package/commonjs/module/module.f.d.mts +16 -21
  21. package/commonjs/module/module.f.mjs +2 -9
  22. package/commonjs/module.d.mts +1 -5
  23. package/commonjs/module.f.d.mts +0 -2
  24. package/commonjs/module.f.mjs +0 -2
  25. package/commonjs/module.mjs +2 -7
  26. package/commonjs/package/dependencies/module.f.d.mts +3 -7
  27. package/commonjs/package/dependencies/module.f.mjs +5 -10
  28. package/commonjs/package/dependencies/test.f.mjs +1 -1
  29. package/commonjs/package/module.f.d.mts +12 -18
  30. package/commonjs/package/module.f.mjs +6 -13
  31. package/commonjs/package/test.f.mjs +1 -1
  32. package/commonjs/path/module.f.d.mts +25 -32
  33. package/commonjs/path/module.f.mjs +12 -23
  34. package/commonjs/path/test.f.mjs +11 -11
  35. package/commonjs/test.mjs +1 -1
  36. package/dev/module.f.d.mts +1 -4
  37. package/dev/module.f.mjs +1 -4
  38. package/dev/test/module.f.d.mts +2 -3
  39. package/dev/test/module.f.mjs +4 -6
  40. package/djs/module.f.d.mts +13 -18
  41. package/djs/module.f.mjs +12 -19
  42. package/djs/parser/module.f.d.mts +11 -15
  43. package/djs/parser/module.f.mjs +18 -24
  44. package/djs/parser/test.f.mjs +9 -9
  45. package/djs/test.f.mjs +4 -4
  46. package/djs/tokenizer/module.f.d.mts +6 -10
  47. package/djs/tokenizer/module.f.mjs +18 -23
  48. package/djs/tokenizer/test.f.mjs +6 -6
  49. package/fsc/module.f.d.mts +4 -9
  50. package/fsc/module.f.mjs +17 -24
  51. package/fsc/test.f.mjs +3 -3
  52. package/fsm/module.f.d.mts +13 -20
  53. package/fsm/module.f.mjs +27 -38
  54. package/fsm/test.f.mjs +8 -8
  55. package/html/module.f.d.mts +7 -12
  56. package/html/module.f.mjs +14 -23
  57. package/html/test.f.mjs +4 -4
  58. package/js/tokenizer/module.f.d.mts +10 -15
  59. package/js/tokenizer/module.f.mjs +55 -62
  60. package/js/tokenizer/test.f.mjs +6 -6
  61. package/json/module.f.d.mts +18 -26
  62. package/json/module.f.mjs +18 -31
  63. package/json/parser/module.f.d.mts +9 -13
  64. package/json/parser/module.f.mjs +9 -14
  65. package/json/parser/test.f.mjs +7 -7
  66. package/json/serializer/module.f.d.mts +11 -20
  67. package/json/serializer/module.f.mjs +14 -29
  68. package/json/serializer/test.f.mjs +2 -2
  69. package/json/test.f.mjs +3 -3
  70. package/json/tokenizer/module.f.d.mts +6 -10
  71. package/json/tokenizer/module.f.mjs +14 -19
  72. package/json/tokenizer/test.f.mjs +6 -6
  73. package/jsr.json +1 -1
  74. package/nodejs/version/main.mjs +1 -1
  75. package/nodejs/version/module.f.d.mts +4 -9
  76. package/nodejs/version/module.f.mjs +2 -7
  77. package/nodejs/version/test.f.mjs +3 -3
  78. package/package.json +1 -1
  79. package/prime_field/module.f.d.mts +20 -23
  80. package/prime_field/module.f.mjs +9 -12
  81. package/prime_field/test.f.mjs +1 -1
  82. package/secp/module.f.d.mts +27 -28
  83. package/secp/module.f.mjs +38 -39
  84. package/secp/test.f.mjs +4 -4
  85. package/sha2/module.f.d.mts +8 -16
  86. package/sha2/module.f.mjs +7 -20
  87. package/sha2/test.f.mjs +4 -4
  88. package/text/ascii/module.f.d.mts +69 -72
  89. package/text/ascii/module.f.mjs +5 -10
  90. package/text/ascii/test.f.mjs +3 -3
  91. package/text/module.f.d.mts +9 -14
  92. package/text/module.f.mjs +7 -14
  93. package/text/sgr/module.f.d.mts +7 -9
  94. package/text/sgr/module.f.mjs +2 -4
  95. package/text/test.f.mjs +3 -3
  96. package/text/utf16/module.f.d.mts +8 -15
  97. package/text/utf16/module.f.mjs +17 -28
  98. package/text/utf16/test.f.mjs +5 -5
  99. package/text/utf8/module.f.d.mts +4 -9
  100. package/text/utf8/module.f.mjs +9 -16
  101. package/text/utf8/test.f.mjs +4 -4
  102. package/types/array/module.f.d.mts +14 -24
  103. package/types/array/module.f.mjs +8 -25
  104. package/types/array/test.f.mjs +3 -3
  105. package/types/bigfloat/module.f.d.mts +4 -9
  106. package/types/bigfloat/module.f.mjs +3 -10
  107. package/types/bigfloat/test.f.mjs +1 -1
  108. package/types/bigint/module.f.d.mts +16 -64
  109. package/types/bigint/module.f.mjs +11 -30
  110. package/types/bigint/test.f.mjs +1 -1
  111. package/types/btree/find/module.f.d.mts +20 -26
  112. package/types/btree/find/module.f.mjs +8 -17
  113. package/types/btree/find/test.f.mjs +7 -7
  114. package/types/btree/module.f.d.mts +4 -8
  115. package/types/btree/module.f.mjs +6 -11
  116. package/types/btree/remove/module.f.d.mts +7 -12
  117. package/types/btree/remove/module.f.mjs +10 -17
  118. package/types/btree/remove/test.f.mjs +5 -5
  119. package/types/btree/set/module.f.d.mts +3 -7
  120. package/types/btree/set/module.f.mjs +4 -9
  121. package/types/btree/set/test.f.mjs +4 -4
  122. package/types/btree/test.f.mjs +9 -9
  123. package/types/btree/types/module.f.d.mts +0 -2
  124. package/types/btree/types/module.f.mjs +0 -2
  125. package/types/byte_set/module.f.d.mts +16 -29
  126. package/types/byte_set/module.f.mjs +14 -39
  127. package/types/byte_set/test.f.mjs +5 -5
  128. package/types/function/compare/module.f.d.mts +9 -15
  129. package/types/function/compare/module.f.mjs +3 -12
  130. package/types/function/compare/test.f.mjs +1 -1
  131. package/types/function/module.f.d.mts +20 -27
  132. package/types/function/module.f.mjs +4 -15
  133. package/types/function/operator/module.f.d.mts +28 -43
  134. package/types/function/operator/module.f.mjs +14 -41
  135. package/types/function/test.f.mjs +1 -1
  136. package/types/list/module.f.d.mts +56 -91
  137. package/types/list/module.f.mjs +45 -114
  138. package/types/list/test.f.mjs +10 -10
  139. package/types/map/module.f.d.mts +15 -24
  140. package/types/map/module.f.mjs +15 -30
  141. package/types/map/test.f.mjs +2 -2
  142. package/types/nibble_set/module.f.d.mts +10 -20
  143. package/types/nibble_set/module.f.mjs +7 -24
  144. package/types/nibble_set/test.f.mjs +2 -2
  145. package/types/nullable/module.f.d.mts +3 -8
  146. package/types/nullable/module.f.mjs +2 -9
  147. package/types/nullable/test.f.mjs +1 -1
  148. package/types/number/module.f.d.mts +7 -13
  149. package/types/number/module.f.mjs +8 -19
  150. package/types/number/test.f.mjs +1 -1
  151. package/types/object/module.f.d.mts +11 -18
  152. package/types/object/module.f.mjs +9 -20
  153. package/types/object/test.f.mjs +1 -1
  154. package/types/range/module.f.d.mts +3 -8
  155. package/types/range/module.f.mjs +2 -9
  156. package/types/range/test.f.mjs +1 -1
  157. package/types/range_map/module.f.d.mts +9 -15
  158. package/types/range_map/module.f.mjs +9 -18
  159. package/types/range_map/test.f.mjs +32 -32
  160. package/types/result/module.d.mts +3 -3
  161. package/types/result/module.f.d.mts +6 -12
  162. package/types/result/module.f.mjs +3 -12
  163. package/types/result/module.mjs +2 -2
  164. package/types/sorted_list/module.f.d.mts +22 -28
  165. package/types/sorted_list/module.f.mjs +10 -19
  166. package/types/sorted_list/test.f.mjs +7 -7
  167. package/types/sorted_set/module.f.d.mts +6 -12
  168. package/types/sorted_set/module.f.mjs +7 -16
  169. package/types/sorted_set/test.f.mjs +7 -7
  170. package/types/string/module.f.d.mts +8 -14
  171. package/types/string/module.f.mjs +10 -21
  172. package/types/string/test.f.mjs +2 -2
  173. package/types/string_set/module.f.d.mts +8 -16
  174. package/types/string_set/module.f.mjs +12 -27
  175. package/types/string_set/test.f.mjs +1 -1
@@ -1,20 +1,20 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import result, * as Result from '../../types/result/module.f.mjs'
3
- import list, * as List from '../../types/list/module.f.mjs'
2
+ import * as result from '../../types/result/module.f.mjs'
3
+ import * as list from '../../types/list/module.f.mjs'
4
4
  const { fold, first, drop, toArray } = list
5
5
  import * as Operator from '../../types/function/operator/module.f.mjs'
6
6
  import * as Tokenizer from '../tokenizer/module.f.mjs'
7
- import map, * as Map from '../../types/map/module.f.mjs'
7
+ import * as map from '../../types/map/module.f.mjs'
8
8
  const { setReplace } = map
9
9
  import * as Json from '../module.f.mjs'
10
- import o from '../../types/object/module.f.mjs'
10
+ import * as o from '../../types/object/module.f.mjs'
11
11
  const { fromMap } = o
12
12
 
13
13
 
14
14
  /**
15
15
  * @typedef {{
16
16
  * readonly kind: 'object'
17
- * readonly values: Map.Map<Json.Unknown>
17
+ * readonly values: map.Map<Json.Unknown>
18
18
  * readonly key: string
19
19
  * }} JsonObject
20
20
  * */
@@ -22,7 +22,7 @@ const { fromMap } = o
22
22
  /**
23
23
  * @typedef {{
24
24
  * readonly kind: 'array'
25
- * readonly values: List.List<Json.Unknown>
25
+ * readonly values: list.List<Json.Unknown>
26
26
  * }} JsonArray
27
27
  * */
28
28
 
@@ -33,7 +33,7 @@ const { fromMap } = o
33
33
  * } JsonStackElement
34
34
  */
35
35
 
36
- /** @typedef {List.List<JsonStackElement>} JsonStack */
36
+ /** @typedef {list.List<JsonStackElement>} JsonStack */
37
37
 
38
38
  /**
39
39
  * @typedef {{
@@ -206,8 +206,8 @@ const foldOp = token => state => {
206
206
  }
207
207
  }
208
208
 
209
- /** @type {(tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>} */
210
- const parse = tokenList => {
209
+ /** @type {(tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>} */
210
+ export const parse = tokenList => {
211
211
  const state = fold(foldOp)({ status: '', top: null, stack: null })(tokenList)
212
212
  switch (state.status) {
213
213
  case 'result': return result.ok(state.value)
@@ -215,8 +215,3 @@ const parse = tokenList => {
215
215
  default: return result.error('unexpected end')
216
216
  }
217
217
  }
218
-
219
- export default {
220
- /** @readonly */
221
- parse
222
- }
@@ -1,13 +1,13 @@
1
- import parser from './module.f.mjs'
2
- import tokenizer, * as Tokenizer from '../tokenizer/module.f.mjs'
3
- import list from '../../types/list/module.f.mjs'
1
+ import * as parser from './module.f.mjs'
2
+ import * as tokenizer from '../tokenizer/module.f.mjs'
3
+ import * as list from '../../types/list/module.f.mjs'
4
4
  const { toArray } = list
5
- import json from '../module.f.mjs'
6
- import o from '../../types/object/module.f.mjs'
5
+ import * as json from '../module.f.mjs'
6
+ import * as o from '../../types/object/module.f.mjs'
7
7
  const { sort } = o
8
- import encoding from '../../text/utf16/module.f.mjs'
8
+ import * as encoding from '../../text/utf16/module.f.mjs'
9
9
 
10
- /** @type {(s: string) => readonly Tokenizer.JsonToken[]} */
10
+ /** @type {(s: string) => readonly tokenizer.JsonToken[]} */
11
11
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
12
12
 
13
13
  const stringify = json.stringify(sort)
@@ -1,12 +1,12 @@
1
- declare namespace _default {
2
- export { objectWrap };
3
- export { arrayWrap };
4
- export { stringSerialize };
5
- export { numberSerialize };
6
- export { nullSerialize };
7
- export { boolSerialize };
8
- }
9
- export default _default;
1
+ /** @type {(_: string) => list.List<string>} */
2
+ export const stringSerialize: (_: string) => list.List<string>;
3
+ /** @type {(_: number) => list.List<string>} */
4
+ export const numberSerialize: (_: number) => list.List<string>;
5
+ export const nullSerialize: string[];
6
+ /** @type {(_: boolean) => list.List<string>} */
7
+ export const boolSerialize: (_: boolean) => list.List<string>;
8
+ export const objectWrap: (input: list.List<list.List<string>>) => list.List<string>;
9
+ export const arrayWrap: (input: list.List<list.List<string>>) => list.List<string>;
10
10
  /**
11
11
  * <T>
12
12
  */
@@ -27,19 +27,10 @@ export type Entry<T> = O.Entry<Unknown<T>>;
27
27
  /**
28
28
  * <T>
29
29
  */
30
- export type Entries<T> = (List.List<Entry<T>>);
30
+ export type Entries<T> = (list.List<Entry<T>>);
31
31
  /**
32
32
  * <T>
33
33
  */
34
34
  export type MapEntries<T> = (entries: Entries<T>) => Entries<T>;
35
- declare const objectWrap: (input: List.List<List.List<string>>) => List.List<string>;
36
- declare const arrayWrap: (input: List.List<List.List<string>>) => List.List<string>;
37
- /** @type {(_: string) => List.List<string>} */
38
- declare const stringSerialize: (_: string) => List.List<string>;
39
- /** @type {(_: number) => List.List<string>} */
40
- declare const numberSerialize: (_: number) => List.List<string>;
41
- declare const nullSerialize: string[];
42
- /** @type {(_: boolean) => List.List<string>} */
43
- declare const boolSerialize: (_: boolean) => List.List<string>;
35
+ import * as list from '../../types/list/module.f.mjs';
44
36
  import * as O from '../../types/object/module.f.mjs';
45
- import * as List from '../../types/list/module.f.mjs';
@@ -1,5 +1,5 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import list, * as List from '../../types/list/module.f.mjs'
2
+ import * as list from '../../types/list/module.f.mjs'
3
3
  const { flat, reduce, empty } = list
4
4
  import * as O from '../../types/object/module.f.mjs'
5
5
  import * as Operator from '../../types/function/operator/module.f.mjs'
@@ -37,39 +37,39 @@ import * as Operator from '../../types/function/operator/module.f.mjs'
37
37
 
38
38
  const jsonStringify = JSON.stringify
39
39
 
40
- /** @type {(_: string) => List.List<string>} */
41
- const stringSerialize = input => [jsonStringify(input)]
40
+ /** @type {(_: string) => list.List<string>} */
41
+ export const stringSerialize = input => [jsonStringify(input)]
42
42
 
43
- /** @type {(_: number) => List.List<string>} */
44
- const numberSerialize = input => [jsonStringify(input)]
43
+ /** @type {(_: number) => list.List<string>} */
44
+ export const numberSerialize = input => [jsonStringify(input)]
45
45
 
46
- const nullSerialize = ['null']
46
+ export const nullSerialize = ['null']
47
47
 
48
48
  const trueSerialize = ['true']
49
49
 
50
50
  const falseSerialize = ['false']
51
51
 
52
- /** @type {(_: boolean) => List.List<string>} */
53
- const boolSerialize = value => value ? trueSerialize : falseSerialize
52
+ /** @type {(_: boolean) => list.List<string>} */
53
+ export const boolSerialize = value => value ? trueSerialize : falseSerialize
54
54
 
55
55
  const comma = [',']
56
56
 
57
- /** @type {Operator.Reduce<List.List<string>>} */
57
+ /** @type {Operator.Reduce<list.List<string>>} */
58
58
  const joinOp = b => prior => flat([prior, comma, b])
59
59
 
60
- /** @type {(input: List.List<List.List<string>>) => List.List<string>} */
60
+ /** @type {(input: list.List<list.List<string>>) => list.List<string>} */
61
61
  const join = reduce(joinOp)(empty)
62
62
 
63
- /** @type {(open: string) => (close: string) => (input: List.List<List.List<string>>) => List.List<string>} */
63
+ /** @type {(open: string) => (close: string) => (input: list.List<list.List<string>>) => list.List<string>} */
64
64
  const wrap = open => close => {
65
65
  const seqOpen = [open]
66
66
  const seqClose = [close]
67
67
  return input => flat([seqOpen, join(input), seqClose])
68
68
  }
69
69
 
70
- const objectWrap = wrap('{')('}')
70
+ export const objectWrap = wrap('{')('}')
71
71
 
72
- const arrayWrap = wrap('[')(']')
72
+ export const arrayWrap = wrap('[')(']')
73
73
 
74
74
  /**
75
75
  * @template T
@@ -78,25 +78,10 @@ const arrayWrap = wrap('[')(']')
78
78
 
79
79
  /**
80
80
  * @template T
81
- * @typedef {(List.List<Entry<T>>)} Entries<T>
81
+ * @typedef {(list.List<Entry<T>>)} Entries<T>
82
82
  */
83
83
 
84
84
  /**
85
85
  * @template T
86
86
  * @typedef {(entries: Entries<T>) => Entries<T>} MapEntries<T>
87
87
  */
88
-
89
- export default {
90
- /** @readonly */
91
- objectWrap,
92
- /** @readonly */
93
- arrayWrap,
94
- /** @readonly */
95
- stringSerialize,
96
- /** @readonly */
97
- numberSerialize,
98
- /** @readonly */
99
- nullSerialize,
100
- /** @readonly */
101
- boolSerialize,
102
- }
@@ -1,5 +1,5 @@
1
- import _, * as T from './module.f.mjs'
2
- import list from '../../types/list/module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
+ import * as list from '../../types/list/module.f.mjs'
3
3
  const { toArray } = list
4
4
 
5
5
  export default {
package/json/test.f.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import json from './module.f.mjs'
2
- import o from '../types/object/module.f.mjs'
1
+ import * as json from './module.f.mjs'
2
+ import * as o from '../types/object/module.f.mjs'
3
3
  const { sort } = o
4
- import f from '../types/function/module.f.mjs'
4
+ import * as f from '../types/function/module.f.mjs'
5
5
  const { identity } = f
6
6
 
7
7
  export default {
@@ -1,17 +1,13 @@
1
- declare namespace _default {
2
- export { tokenize };
3
- }
4
- export default _default;
1
+ /** @type {(input: list.List<number>) => list.List<JsonToken>} */
2
+ export const tokenize: (input: list.List<number>) => list.List<JsonToken>;
5
3
  export type JsonToken = {
6
4
  readonly kind: "true" | "false" | "null";
7
5
  } | {
8
6
  readonly kind: "{" | "}" | ":" | "," | "[" | "]";
9
- } | JsTokenizer.StringToken | JsTokenizer.NumberToken | JsTokenizer.ErrorToken;
7
+ } | jsTokenizer.StringToken | jsTokenizer.NumberToken | jsTokenizer.ErrorToken;
10
8
  export type ScanState = {
11
9
  readonly kind: "def" | "-";
12
10
  };
13
- export type ScanInput = JsTokenizer.JsToken | null;
14
- /** @type {(input: List.List<number>) => List.List<JsonToken>} */
15
- declare const tokenize: (input: List.List<number>) => List.List<JsonToken>;
16
- import * as JsTokenizer from '../../js/tokenizer/module.f.mjs';
17
- import * as List from '../../types/list/module.f.mjs';
11
+ export type ScanInput = jsTokenizer.JsToken | null;
12
+ import * as list from '../../types/list/module.f.mjs';
13
+ import * as jsTokenizer from '../../js/tokenizer/module.f.mjs';
@@ -1,18 +1,18 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
2
  import * as Operator from '../../types/function/operator/module.f.mjs'
3
- import list, * as List from '../../types/list/module.f.mjs'
3
+ import * as list from '../../types/list/module.f.mjs'
4
4
  const { empty, flat, stateScan } = list
5
- import bf from '../../types/bigfloat/module.f.mjs'
5
+ import * as bf from '../../types/bigfloat/module.f.mjs'
6
6
  const { multiply } = bf
7
- import jsTokenizer, * as JsTokenizer from '../../js/tokenizer/module.f.mjs'
7
+ import * as jsTokenizer from '../../js/tokenizer/module.f.mjs'
8
8
 
9
9
  /**
10
10
  * @typedef {|
11
11
  * {readonly kind: 'true' | 'false' | 'null' } |
12
12
  * {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' } |
13
- * JsTokenizer.StringToken |
14
- * JsTokenizer.NumberToken |
15
- * JsTokenizer.ErrorToken
13
+ * jsTokenizer.StringToken |
14
+ * jsTokenizer.NumberToken |
15
+ * jsTokenizer.ErrorToken
16
16
  * } JsonToken
17
17
  */
18
18
 
@@ -24,11 +24,11 @@ import jsTokenizer, * as JsTokenizer from '../../js/tokenizer/module.f.mjs'
24
24
 
25
25
  /**
26
26
  * @typedef {|
27
- * JsTokenizer.JsToken | null
27
+ * jsTokenizer.JsToken | null
28
28
  * } ScanInput
29
29
  */
30
30
 
31
- /** @type {(input: JsTokenizer.JsToken) => List.List<JsonToken>} */
31
+ /** @type {(input: jsTokenizer.JsToken) => list.List<JsonToken>} */
32
32
  const mapToken = input =>
33
33
  {
34
34
  switch(input.kind)
@@ -51,7 +51,7 @@ const mapToken = input =>
51
51
  }
52
52
  }
53
53
 
54
- /** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
54
+ /** @type {(input: ScanInput) => readonly [list.List<JsonToken>, ScanState]} */
55
55
  const parseDefaultState = input =>
56
56
  {
57
57
  if (input === null) return [empty, { kind: 'def'}]
@@ -62,7 +62,7 @@ const parseDefaultState = input =>
62
62
  }
63
63
  }
64
64
 
65
- /** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
65
+ /** @type {(input: ScanInput) => readonly [list.List<JsonToken>, ScanState]} */
66
66
  const parseMinusState = input =>
67
67
  {
68
68
  if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
@@ -74,7 +74,7 @@ const parseMinusState = input =>
74
74
  }
75
75
  }
76
76
 
77
- /** @type {Operator.StateScan<ScanInput, ScanState, List.List<JsonToken>>} */
77
+ /** @type {Operator.StateScan<ScanInput, ScanState, list.List<JsonToken>>} */
78
78
  const scanToken = state => input => {
79
79
  switch(state.kind)
80
80
  {
@@ -83,15 +83,10 @@ const scanToken = state => input => {
83
83
  }
84
84
  }
85
85
 
86
- /** @type {(input: List.List<number>) => List.List<JsonToken>} */
87
- const tokenize = input =>
86
+ /** @type {(input: list.List<number>) => list.List<JsonToken>} */
87
+ export const tokenize = input =>
88
88
  {
89
- /** @type {List.List<ScanInput>} */
89
+ /** @type {list.List<ScanInput>} */
90
90
  const jsTokens = jsTokenizer.tokenize(input)
91
91
  return flat(stateScan(scanToken)({ kind: 'def' })(list.concat(jsTokens)([null])))
92
92
  }
93
-
94
- export default {
95
- /** @readonly */
96
- tokenize
97
- }
@@ -1,12 +1,12 @@
1
- import tokenizer, * as Tokenizer from './module.f.mjs'
2
- import list from '../../types/list/module.f.mjs'
1
+ import * as tokenizer from './module.f.mjs'
2
+ import * as list from '../../types/list/module.f.mjs'
3
3
  const { toArray } = list
4
- import djs from '../../djs/module.f.mjs'
5
- import o from '../../types/object/module.f.mjs'
4
+ import * as djs from '../../djs/module.f.mjs'
5
+ import * as o from '../../types/object/module.f.mjs'
6
6
  const { sort } = o
7
- import encoding from '../../text/utf16/module.f.mjs'
7
+ import * as encoding from '../../text/utf16/module.f.mjs'
8
8
 
9
- /** @type {(s: string) => readonly Tokenizer.JsonToken[]} */
9
+ /** @type {(s: string) => readonly tokenizer.JsonToken[]} */
10
10
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
11
11
 
12
12
  const stringify = djs.stringify(sort)
package/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalscript/functionalscript",
3
- "version": "0.1.609",
3
+ "version": "0.2.0",
4
4
  "exports": {
5
5
  "./com/cpp": "./com/cpp/module.f.mjs",
6
6
  "./com/cs": "./com/cs/module.f.mjs",
@@ -1,4 +1,4 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
  import fs from 'node:fs'
3
3
 
4
4
  _.updateVersion({ fs })
@@ -1,8 +1,7 @@
1
- declare namespace _default {
2
- export { getVersion };
3
- export { updateVersion };
4
- }
5
- export default _default;
1
+ /** @type {<T>(fs: Fs<T>) => string} */
2
+ export const getVersion: <T>(fs: Fs<T>) => string;
3
+ /** @type {<T>(node: Node<T>) => readonly[T, T]} */
4
+ export const updateVersion: <T>(node: Node<T>) => readonly [T, T];
6
5
  export type Buffer = {};
7
6
  export type Fs<T> = {
8
7
  readonly readFileSync: (name: string) => Buffer;
@@ -11,7 +10,3 @@ export type Fs<T> = {
11
10
  export type Node<T> = {
12
11
  readonly fs: Fs<T>;
13
12
  };
14
- /** @type {<T>(fs: Fs<T>) => string} */
15
- declare const getVersion: <T>(fs: Fs<T>) => string;
16
- /** @type {<T>(node: Node<T>) => readonly[T, T]} */
17
- declare const updateVersion: <T>(node: Node<T>) => readonly [T, T];
@@ -20,7 +20,7 @@
20
20
  const { stringify, parse } = JSON
21
21
 
22
22
  /** @type {<T>(fs: Fs<T>) => string} */
23
- const getVersion = fs => readJson(fs)('package').version
23
+ export const getVersion = fs => readJson(fs)('package').version
24
24
 
25
25
  const jsonFile = (/** @type {string} */jsonFile) => `${jsonFile}.json`
26
26
 
@@ -28,7 +28,7 @@ const jsonFile = (/** @type {string} */jsonFile) => `${jsonFile}.json`
28
28
  const readJson = fs => name => parse(fs.readFileSync(jsonFile(name)).toString())
29
29
 
30
30
  /** @type {<T>(node: Node<T>) => readonly[T, T]} */
31
- const updateVersion = ({ fs }) => {
31
+ export const updateVersion = ({ fs }) => {
32
32
  const f = (/** @type {string} */name) => {
33
33
  return fs.writeFileSync(
34
34
  jsonFile(name),
@@ -45,8 +45,3 @@ const updateVersion = ({ fs }) => {
45
45
  f('jsr')
46
46
  ]
47
47
  }
48
-
49
- export default {
50
- getVersion,
51
- updateVersion,
52
- }
@@ -1,4 +1,4 @@
1
- import _, * as T from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
 
3
3
  const version = '0.3.0'
4
4
 
@@ -82,13 +82,13 @@ const e = '{\n' +
82
82
  ' }\n' +
83
83
  '}'
84
84
 
85
- /** @type {(s: string) => T.Buffer} */
85
+ /** @type {(s: string) => _.Buffer} */
86
86
  const buffer = s => ({
87
87
  toString: () => s
88
88
  })
89
89
 
90
90
  export default () => {
91
- /** @type {T.Node<string>} */
91
+ /** @type {_.Node<string>} */
92
92
  const node = {
93
93
  fs: {
94
94
  readFileSync: n => buffer(JSON.stringify(x[n])),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.1.609",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "FunctionalScript is a functional subset of JavaScript",
6
6
  "scripts": {
@@ -1,25 +1,3 @@
1
- declare namespace _default {
2
- export { prime_field };
3
- export let sqrt: (f: PrimeField) => (a: bigint) => bigint | null;
4
- }
5
- export default _default;
6
- export type Reduce = Operator.Reduce<bigint>;
7
- export type Unary = Operator.Unary<bigint, bigint>;
8
- export type PrimeField = {
9
- readonly p: bigint;
10
- readonly middle: bigint;
11
- readonly max: bigint;
12
- readonly neg: Unary;
13
- readonly sub: Reduce;
14
- readonly add: Reduce;
15
- readonly abs: Unary;
16
- readonly mul: Reduce;
17
- readonly reciprocal: Unary;
18
- readonly div: Reduce;
19
- readonly pow: Reduce;
20
- readonly pow2: Unary;
21
- readonly pow3: Unary;
22
- };
23
1
  /** @typedef {Operator.Reduce<bigint>} Reduce */
24
2
  /** @typedef {Operator.Unary<bigint, bigint>} Unary*/
25
3
  /**
@@ -40,5 +18,24 @@ export type PrimeField = {
40
18
  * }} PrimeField
41
19
  */
42
20
  /** @type {(p: bigint) => PrimeField} */
43
- declare const prime_field: (p: bigint) => PrimeField;
21
+ export const prime_field: (p: bigint) => PrimeField;
22
+ /** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
23
+ export const sqrt: (f: PrimeField) => (a: bigint) => bigint | null;
24
+ export type Reduce = Operator.Reduce<bigint>;
25
+ export type Unary = Operator.Unary<bigint, bigint>;
26
+ export type PrimeField = {
27
+ readonly p: bigint;
28
+ readonly middle: bigint;
29
+ readonly max: bigint;
30
+ readonly neg: Unary;
31
+ readonly sub: Reduce;
32
+ readonly add: Reduce;
33
+ readonly abs: Unary;
34
+ readonly mul: Reduce;
35
+ readonly reciprocal: Unary;
36
+ readonly div: Reduce;
37
+ readonly pow: Reduce;
38
+ readonly pow2: Unary;
39
+ readonly pow3: Unary;
40
+ };
44
41
  import * as Operator from '../types/function/operator/module.f.mjs';
@@ -1,6 +1,6 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
2
  import * as Operator from '../types/function/operator/module.f.mjs'
3
- import bi from '../types/bigint/module.f.mjs'
3
+ import * as bi from '../types/bigint/module.f.mjs'
4
4
  const { scalar_mul } = bi
5
5
 
6
6
  /** @typedef {Operator.Reduce<bigint>} Reduce */
@@ -26,7 +26,7 @@ const { scalar_mul } = bi
26
26
  */
27
27
 
28
28
  /** @type {(p: bigint) => PrimeField} */
29
- const prime_field = p => {
29
+ export const prime_field = p => {
30
30
  /** @type {Reduce} */
31
31
  const sub = a => b => {
32
32
  const r = a - b
@@ -77,15 +77,12 @@ const prime_field = p => {
77
77
  }
78
78
  }
79
79
 
80
- export default {
81
- prime_field,
82
- /** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
83
- sqrt: ({p, mul, pow }) => {
84
- if ((p & 3n) !== 3n) { throw 'sqrt' }
85
- const sqrt_k = (p + 1n) >> 2n
86
- return a => {
87
- const result = pow(a)(sqrt_k)
88
- return mul(result)(result) === a ? result : null
89
- }
80
+ /** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
81
+ export const sqrt = ({p, mul, pow }) => {
82
+ if ((p & 3n) !== 3n) { throw 'sqrt' }
83
+ const sqrt_k = (p + 1n) >> 2n
84
+ return a => {
85
+ const result = pow(a)(sqrt_k)
86
+ return mul(result)(result) === a ? result : null
90
87
  }
91
88
  }
@@ -1,4 +1,4 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
  const { prime_field, sqrt } = _
3
3
 
4
4
  export default {
@@ -1,27 +1,3 @@
1
- declare namespace _default {
2
- export { curve };
3
- export let eq: (a: Point) => (b: Point) => boolean;
4
- export let secp256k1: Init;
5
- export let secp192r1: Init;
6
- }
7
- export default _default;
8
- export type Point2D = readonly [bigint, bigint];
9
- export type Point = Point2D | null;
10
- export type Init = {
11
- readonly p: bigint;
12
- readonly a: readonly [bigint, bigint];
13
- readonly g: readonly [bigint, bigint];
14
- readonly n: bigint;
15
- };
16
- export type Curve = {
17
- readonly pf: Pf.PrimeField;
18
- readonly nf: Pf.PrimeField;
19
- readonly y2: (x: bigint) => bigint;
20
- readonly y: (x: bigint) => bigint | null;
21
- readonly neg: (a: Point) => Point;
22
- readonly add: Operator.Reduce<Point>;
23
- readonly mul: (a: Point) => (n: bigint) => Point;
24
- };
25
1
  /** @typedef {readonly[bigint, bigint]} Point2D */
26
2
  /** @typedef {Point2D|null} Point */
27
3
  /**
@@ -34,8 +10,8 @@ export type Curve = {
34
10
  */
35
11
  /**
36
12
  * @typedef {{
37
- * readonly pf: Pf.PrimeField
38
- * readonly nf: Pf.PrimeField
13
+ * readonly pf: pf.PrimeField
14
+ * readonly nf: pf.PrimeField
39
15
  * readonly y2: (x: bigint) => bigint
40
16
  * readonly y: (x: bigint) => bigint|null
41
17
  * readonly neg: (a: Point) => Point
@@ -44,6 +20,29 @@ export type Curve = {
44
20
  * }} Curve
45
21
  */
46
22
  /** @type {(i: Init) => Curve} */
47
- declare const curve: (i: Init) => Curve;
48
- import * as Pf from '../prime_field/module.f.mjs';
23
+ export const curve: (i: Init) => Curve;
24
+ /** @type {(a: Point) => (b: Point) => boolean} */
25
+ export const eq: (a: Point) => (b: Point) => boolean;
26
+ /** @type {Init} */
27
+ export const secp256k1: Init;
28
+ /** @type {Init} */
29
+ export const secp192r1: Init;
30
+ export type Point2D = readonly [bigint, bigint];
31
+ export type Point = Point2D | null;
32
+ export type Init = {
33
+ readonly p: bigint;
34
+ readonly a: readonly [bigint, bigint];
35
+ readonly g: readonly [bigint, bigint];
36
+ readonly n: bigint;
37
+ };
38
+ export type Curve = {
39
+ readonly pf: pf.PrimeField;
40
+ readonly nf: pf.PrimeField;
41
+ readonly y2: (x: bigint) => bigint;
42
+ readonly y: (x: bigint) => bigint | null;
43
+ readonly neg: (a: Point) => Point;
44
+ readonly add: Operator.Reduce<Point>;
45
+ readonly mul: (a: Point) => (n: bigint) => Point;
46
+ };
47
+ import * as pf from '../prime_field/module.f.mjs';
49
48
  import * as Operator from '../types/function/operator/module.f.mjs';