functionalscript 0.1.608 → 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 (222) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/Cargo.lock +4 -0
  3. package/Cargo.toml +4 -2
  4. package/README.md +1 -1
  5. package/com/cpp/module.f.d.mts +4 -8
  6. package/com/cpp/module.f.mjs +20 -25
  7. package/com/cpp/testlib.f.mjs +3 -4
  8. package/com/cs/module.f.d.mts +4 -8
  9. package/com/cs/module.f.mjs +18 -23
  10. package/com/cs/testlib.f.mjs +3 -5
  11. package/com/rust/module.f.d.mts +3 -7
  12. package/com/rust/module.f.mjs +25 -30
  13. package/com/rust/nanocom/src/cobject.rs +1 -1
  14. package/com/rust/testlib.f.mjs +3 -5
  15. package/com/test/build.f.d.mts +2 -2
  16. package/com/test/build.f.mjs +2 -2
  17. package/com/test/build.mjs +4 -4
  18. package/com/test/rust/src/lib.rs +4 -4
  19. package/com/types/module.f.d.mts +5 -10
  20. package/com/types/module.f.mjs +5 -12
  21. package/commonjs/build/module.f.d.mts +13 -17
  22. package/commonjs/build/module.f.mjs +23 -28
  23. package/commonjs/build/test.f.mjs +4 -4
  24. package/commonjs/module/function/module.f.d.mts +0 -2
  25. package/commonjs/module/function/module.f.mjs +0 -2
  26. package/commonjs/module/module.f.d.mts +16 -21
  27. package/commonjs/module/module.f.mjs +2 -9
  28. package/commonjs/module.d.mts +1 -5
  29. package/commonjs/module.f.d.mts +0 -2
  30. package/commonjs/module.f.mjs +0 -2
  31. package/commonjs/module.mjs +2 -7
  32. package/commonjs/package/dependencies/module.f.d.mts +3 -7
  33. package/commonjs/package/dependencies/module.f.mjs +5 -10
  34. package/commonjs/package/dependencies/test.f.mjs +1 -1
  35. package/commonjs/package/module.f.d.mts +12 -18
  36. package/commonjs/package/module.f.mjs +6 -13
  37. package/commonjs/package/test.f.mjs +1 -1
  38. package/commonjs/path/module.f.d.mts +25 -32
  39. package/commonjs/path/module.f.mjs +12 -23
  40. package/commonjs/path/test.f.mjs +11 -11
  41. package/commonjs/test.mjs +1 -1
  42. package/dev/module.f.d.mts +1 -4
  43. package/dev/module.f.mjs +1 -4
  44. package/dev/module.mjs +1 -1
  45. package/dev/test/module.f.d.mts +2 -3
  46. package/dev/test/module.f.mjs +5 -7
  47. package/djs/module.f.d.mts +13 -18
  48. package/djs/module.f.mjs +12 -19
  49. package/djs/parser/module.f.d.mts +53 -37
  50. package/djs/parser/module.f.mjs +278 -131
  51. package/djs/parser/test.f.d.mts +4 -0
  52. package/djs/parser/test.f.mjs +186 -70
  53. package/djs/test.f.mjs +4 -4
  54. package/djs/tokenizer/module.f.d.mts +6 -10
  55. package/djs/tokenizer/module.f.mjs +19 -22
  56. package/djs/tokenizer/test.f.mjs +7 -7
  57. package/doc/LANGUAGE.md +17 -16
  58. package/doc/README.md +14 -50
  59. package/fsc/README.md +0 -3
  60. package/fsc/module.f.d.mts +4 -9
  61. package/fsc/module.f.mjs +17 -24
  62. package/fsc/test.f.mjs +3 -3
  63. package/fsm/README.md +1 -1
  64. package/fsm/module.f.d.mts +13 -20
  65. package/fsm/module.f.mjs +27 -38
  66. package/fsm/test.f.mjs +8 -8
  67. package/html/README.md +24 -0
  68. package/html/module.f.d.mts +7 -12
  69. package/html/module.f.mjs +14 -23
  70. package/html/test.f.mjs +4 -4
  71. package/issues/01-test-debug.md +3 -0
  72. package/issues/{publish.md → 05-publish.md} +8 -8
  73. package/issues/17-djs-extension.md +6 -0
  74. package/issues/README.md +20 -13
  75. package/issues/lang/1000-json.md +38 -0
  76. package/issues/lang/2110-default-export.md +2 -2
  77. package/issues/lang/2310-undefined.md +1 -1
  78. package/issues/lang/2330-property-accessor.md +225 -0
  79. package/issues/lang/2360-built-in.md +54 -47
  80. package/issues/lang/3240-export.md +44 -0
  81. package/issues/lang/README.md +64 -22
  82. package/issues/test.f.d.mts +16 -0
  83. package/issues/test.f.mjs +57 -0
  84. package/js/tokenizer/module.f.d.mts +18 -17
  85. package/js/tokenizer/module.f.mjs +80 -61
  86. package/js/tokenizer/test.f.mjs +15 -12
  87. package/json/module.f.d.mts +18 -26
  88. package/json/module.f.mjs +18 -31
  89. package/json/parser/module.f.d.mts +9 -13
  90. package/json/parser/module.f.mjs +9 -14
  91. package/json/parser/test.f.mjs +7 -7
  92. package/json/serializer/module.f.d.mts +11 -20
  93. package/json/serializer/module.f.mjs +14 -29
  94. package/json/serializer/test.f.mjs +2 -2
  95. package/json/test.f.mjs +3 -3
  96. package/json/tokenizer/module.f.d.mts +6 -10
  97. package/json/tokenizer/module.f.mjs +16 -20
  98. package/json/tokenizer/test.f.mjs +6 -6
  99. package/jsr.json +1 -1
  100. package/nanvm-lib/Cargo.toml +6 -0
  101. package/nanvm-lib/src/extension.rs +119 -0
  102. package/nanvm-lib/src/interface.rs +136 -0
  103. package/nanvm-lib/src/lib.rs +7 -0
  104. package/nanvm-lib/src/naive.rs +229 -0
  105. package/nanvm-lib/src/nanenum.rs +230 -0
  106. package/nanvm-lib/src/nullish.rs +7 -0
  107. package/nanvm-lib/src/sign.rs +5 -0
  108. package/nanvm-lib/src/simple.rs +32 -0
  109. package/nanvm-lib/tests/test.f.d.mts +36 -0
  110. package/nanvm-lib/tests/test.f.mjs +79 -0
  111. package/nanvm-lib/tests/test.rs +108 -0
  112. package/nodejs/version/main.mjs +1 -1
  113. package/nodejs/version/module.f.d.mts +4 -9
  114. package/nodejs/version/module.f.mjs +2 -7
  115. package/nodejs/version/test.f.mjs +3 -3
  116. package/package.json +1 -1
  117. package/prime_field/module.f.d.mts +20 -23
  118. package/prime_field/module.f.mjs +9 -12
  119. package/prime_field/test.f.mjs +1 -1
  120. package/secp/module.f.d.mts +27 -28
  121. package/secp/module.f.mjs +38 -39
  122. package/secp/test.f.mjs +4 -4
  123. package/sha2/module.f.d.mts +8 -16
  124. package/sha2/module.f.mjs +7 -20
  125. package/sha2/test.f.mjs +4 -4
  126. package/text/README.md +2 -2
  127. package/text/ascii/module.f.d.mts +69 -72
  128. package/text/ascii/module.f.mjs +5 -10
  129. package/text/ascii/test.f.mjs +3 -3
  130. package/text/module.f.d.mts +9 -14
  131. package/text/module.f.mjs +7 -14
  132. package/text/sgr/module.f.d.mts +7 -9
  133. package/text/sgr/module.f.mjs +2 -4
  134. package/text/test.f.mjs +3 -3
  135. package/text/utf16/module.f.d.mts +8 -15
  136. package/text/utf16/module.f.mjs +17 -28
  137. package/text/utf16/test.f.mjs +5 -5
  138. package/text/utf8/module.f.d.mts +4 -9
  139. package/text/utf8/module.f.mjs +9 -16
  140. package/text/utf8/test.f.mjs +4 -4
  141. package/types/array/module.f.d.mts +14 -24
  142. package/types/array/module.f.mjs +8 -25
  143. package/types/array/test.f.mjs +3 -3
  144. package/types/bigfloat/module.f.d.mts +4 -9
  145. package/types/bigfloat/module.f.mjs +3 -10
  146. package/types/bigfloat/test.f.mjs +1 -1
  147. package/types/bigint/module.f.d.mts +16 -64
  148. package/types/bigint/module.f.mjs +11 -30
  149. package/types/bigint/test.f.mjs +1 -1
  150. package/types/btree/find/module.f.d.mts +20 -26
  151. package/types/btree/find/module.f.mjs +8 -17
  152. package/types/btree/find/test.f.mjs +7 -7
  153. package/types/btree/module.f.d.mts +4 -8
  154. package/types/btree/module.f.mjs +6 -11
  155. package/types/btree/remove/module.f.d.mts +7 -12
  156. package/types/btree/remove/module.f.mjs +10 -17
  157. package/types/btree/remove/test.f.mjs +5 -5
  158. package/types/btree/set/module.f.d.mts +3 -7
  159. package/types/btree/set/module.f.mjs +4 -9
  160. package/types/btree/set/test.f.mjs +4 -4
  161. package/types/btree/test.f.mjs +9 -9
  162. package/types/btree/types/module.f.d.mts +0 -2
  163. package/types/btree/types/module.f.mjs +0 -2
  164. package/types/byte_set/module.f.d.mts +16 -29
  165. package/types/byte_set/module.f.mjs +14 -39
  166. package/types/byte_set/test.f.mjs +5 -5
  167. package/types/function/compare/module.f.d.mts +9 -15
  168. package/types/function/compare/module.f.mjs +3 -12
  169. package/types/function/compare/test.f.mjs +1 -1
  170. package/types/function/module.f.d.mts +20 -27
  171. package/types/function/module.f.mjs +4 -15
  172. package/types/function/operator/module.f.d.mts +28 -43
  173. package/types/function/operator/module.f.mjs +14 -41
  174. package/types/function/test.f.mjs +1 -1
  175. package/types/list/module.f.d.mts +56 -91
  176. package/types/list/module.f.mjs +45 -114
  177. package/types/list/test.f.mjs +10 -10
  178. package/types/map/module.f.d.mts +15 -24
  179. package/types/map/module.f.mjs +15 -30
  180. package/types/map/test.f.mjs +2 -2
  181. package/types/nibble_set/module.f.d.mts +10 -20
  182. package/types/nibble_set/module.f.mjs +7 -24
  183. package/types/nibble_set/test.f.mjs +2 -2
  184. package/types/nullable/module.f.d.mts +3 -8
  185. package/types/nullable/module.f.mjs +2 -9
  186. package/types/nullable/test.f.mjs +1 -1
  187. package/types/number/module.f.d.mts +7 -13
  188. package/types/number/module.f.mjs +8 -19
  189. package/types/number/test.f.mjs +1 -1
  190. package/types/object/module.f.d.mts +11 -18
  191. package/types/object/module.f.mjs +9 -20
  192. package/types/object/test.f.mjs +1 -1
  193. package/types/range/module.f.d.mts +3 -8
  194. package/types/range/module.f.mjs +2 -9
  195. package/types/range/test.f.mjs +1 -1
  196. package/types/range_map/module.f.d.mts +9 -15
  197. package/types/range_map/module.f.mjs +9 -18
  198. package/types/range_map/test.f.mjs +32 -32
  199. package/types/result/module.d.mts +3 -3
  200. package/types/result/module.f.d.mts +6 -12
  201. package/types/result/module.f.mjs +3 -12
  202. package/types/result/module.mjs +2 -2
  203. package/types/sorted_list/module.f.d.mts +22 -28
  204. package/types/sorted_list/module.f.mjs +10 -19
  205. package/types/sorted_list/test.f.mjs +7 -7
  206. package/types/sorted_set/module.f.d.mts +6 -12
  207. package/types/sorted_set/module.f.mjs +7 -16
  208. package/types/sorted_set/test.f.mjs +7 -7
  209. package/types/string/module.f.d.mts +8 -14
  210. package/types/string/module.f.mjs +10 -21
  211. package/types/string/test.f.mjs +2 -2
  212. package/types/string_set/module.f.d.mts +8 -16
  213. package/types/string_set/module.f.mjs +12 -27
  214. package/types/string_set/test.f.mjs +1 -1
  215. package/issues/lang/2351-property-accessor.md +0 -44
  216. package/issues/lang/2352-property-call.md +0 -43
  217. package/issues/lang/2353-property-at.md +0 -19
  218. package/issues/test-debug.md +0 -12
  219. /package/issues/{esm.md → 02-esm.md} +0 -0
  220. /package/issues/{djs.md → 03-djs.md} +0 -0
  221. /package/issues/{fs-load.md → 11-fs-load.md} +0 -0
  222. /package/issues/lang/{2330-grouping.md → 2350-grouping.md} +0 -0
package/text/README.md CHANGED
@@ -34,7 +34,7 @@ Total error states:
34
34
  - 34_432
35
35
  - < 2^16
36
36
 
37
- ### utf8/module.f.cjs
37
+ ### utf8/module.f.mjs
38
38
 
39
39
  ```js
40
40
  /** @type {(input: List<u8|null>) => List<i32>} */
@@ -69,7 +69,7 @@ Requirement: no loss for UTF16 => codepoint => UTF16
69
69
 
70
70
  Total error states: 11 bit
71
71
 
72
- ### utf16/module.f.cjs
72
+ ### utf16/module.f.mjs
73
73
 
74
74
  ```js
75
75
  /** @type {(input: List<u16|null>) => List<i32>} */
@@ -1,73 +1,70 @@
1
- declare namespace _default {
2
- export { one };
3
- export { range };
4
- export let backspace: number;
5
- export let ht: number;
6
- export let lf: number;
7
- export let ff: number;
8
- export let cr: number;
9
- export let space: number;
10
- export let exclamationMark: number;
11
- export let quotationMark: number;
12
- export let numberSign: number;
13
- export let dollarSign: number;
14
- export let percentSign: number;
15
- export let ampersand: number;
16
- export let apostrophe: number;
17
- export let leftParenthesis: number;
18
- export let rightParenthesis: number;
19
- export let asterisk: number;
20
- export let plusSign: number;
21
- export let comma: number;
22
- export let hyphenMinus: number;
23
- export let fullStop: number;
24
- export let solidus: number;
25
- export let digitRange: Range.Range;
26
- export let digit0: number;
27
- export let digit1: number;
28
- export let digit2: number;
29
- export let digit3: number;
30
- export let digit4: number;
31
- export let digit5: number;
32
- export let digit6: number;
33
- export let digit7: number;
34
- export let digit8: number;
35
- export let digit9: number;
36
- export let colon: number;
37
- export let semicolon: number;
38
- export let lessThanSign: number;
39
- export let equalsSign: number;
40
- export let greaterThanSign: number;
41
- export let questionMark: number;
42
- export let commercialAt: number;
43
- export let latinCapitalLetterRange: Range.Range;
44
- export let latinCapitalLetterA: number;
45
- export let latinCapitalLetterE: number;
46
- export let latinCapitalLetterF: number;
47
- export let leftSquareBracket: number;
48
- export let reverseSolidus: number;
49
- export let rightSquareBracket: number;
50
- export let circumflexAccent: number;
51
- export let lowLine: number;
52
- export let graveAccent: number;
53
- export let latinSmallLetterRange: Range.Range;
54
- export let latinSmallLetterA: number;
55
- export let latinSmallLetterB: number;
56
- export let latinSmallLetterE: number;
57
- export let latinSmallLetterF: number;
58
- export let latinSmallLetterN: number;
59
- export let latinSmallLetterR: number;
60
- export let latinSmallLetterT: number;
61
- export let latinSmallLetterU: number;
62
- export let latinSmallLetterZ: number;
63
- export let leftCurlyBracket: number;
64
- export let verticalLine: number;
65
- export let rightCurlyBracket: number;
66
- export let tilde: number;
67
- }
68
- export default _default;
69
1
  /** @type {(s: string) => number} */
70
- declare const one: (s: string) => number;
71
- /** @type {(s: string) => Range.Range} */
72
- declare const range: (s: string) => Range.Range;
73
- import * as Range from '../../types/range/module.f.mjs';
2
+ export const one: (s: string) => number;
3
+ /** @type {(s: string) => _range.Range} */
4
+ export const range: (s: string) => _range.Range;
5
+ export namespace ascii {
6
+ let backspace: number;
7
+ let ht: number;
8
+ let lf: number;
9
+ let ff: number;
10
+ let cr: number;
11
+ let space: number;
12
+ let exclamationMark: number;
13
+ let quotationMark: number;
14
+ let numberSign: number;
15
+ let dollarSign: number;
16
+ let percentSign: number;
17
+ let ampersand: number;
18
+ let apostrophe: number;
19
+ let leftParenthesis: number;
20
+ let rightParenthesis: number;
21
+ let asterisk: number;
22
+ let plusSign: number;
23
+ let comma: number;
24
+ let hyphenMinus: number;
25
+ let fullStop: number;
26
+ let solidus: number;
27
+ let digitRange: _range.Range;
28
+ let digit0: number;
29
+ let digit1: number;
30
+ let digit2: number;
31
+ let digit3: number;
32
+ let digit4: number;
33
+ let digit5: number;
34
+ let digit6: number;
35
+ let digit7: number;
36
+ let digit8: number;
37
+ let digit9: number;
38
+ let colon: number;
39
+ let semicolon: number;
40
+ let lessThanSign: number;
41
+ let equalsSign: number;
42
+ let greaterThanSign: number;
43
+ let questionMark: number;
44
+ let commercialAt: number;
45
+ let latinCapitalLetterRange: _range.Range;
46
+ let latinCapitalLetterA: number;
47
+ let latinCapitalLetterE: number;
48
+ let latinCapitalLetterF: number;
49
+ let leftSquareBracket: number;
50
+ let reverseSolidus: number;
51
+ let rightSquareBracket: number;
52
+ let circumflexAccent: number;
53
+ let lowLine: number;
54
+ let graveAccent: number;
55
+ let latinSmallLetterRange: _range.Range;
56
+ let latinSmallLetterA: number;
57
+ let latinSmallLetterB: number;
58
+ let latinSmallLetterE: number;
59
+ let latinSmallLetterF: number;
60
+ let latinSmallLetterN: number;
61
+ let latinSmallLetterR: number;
62
+ let latinSmallLetterT: number;
63
+ let latinSmallLetterU: number;
64
+ let latinSmallLetterZ: number;
65
+ let leftCurlyBracket: number;
66
+ let verticalLine: number;
67
+ let rightCurlyBracket: number;
68
+ let tilde: number;
69
+ }
70
+ import * as _range from '../../types/range/module.f.mjs';
@@ -1,5 +1,5 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import _range, * as Range from '../../types/range/module.f.mjs'
2
+ import * as _range from '../../types/range/module.f.mjs'
3
3
 
4
4
  /** @type {(s: string) => (i: number) => number} */
5
5
  const at = s => i => {
@@ -9,22 +9,17 @@ const at = s => i => {
9
9
  }
10
10
 
11
11
  /** @type {(s: string) => number} */
12
- const one = s => at(s)(0)
12
+ export const one = s => at(s)(0)
13
13
 
14
- /** @type {(s: string) => Range.Range} */
15
- const range = s => {
14
+ /** @type {(s: string) => _range.Range} */
15
+ export const range = s => {
16
16
  const f = at(s)
17
17
  const f0 = f(0)
18
18
  if (s.length === 1) { return [f0, f0] }
19
19
  return [f0, f(1)]
20
20
  }
21
21
 
22
- export default {
23
- /** @readonly */
24
- one,
25
- /** @readonly */
26
- range,
27
-
22
+ export const ascii = {
28
23
  // 0x00..
29
24
 
30
25
  /** @readonly 0x08 */
@@ -1,7 +1,7 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
  const { range } = _
3
- import json from '../../json/module.f.mjs'
4
- import o from '../../types/object/module.f.mjs'
3
+ import * as json from '../../json/module.f.mjs'
4
+ import * as o from '../../types/object/module.f.mjs'
5
5
  const { sort } = o
6
6
 
7
7
  const stringify = json.stringify(sort)
@@ -1,18 +1,13 @@
1
- declare namespace _default {
2
- export { flat };
3
- export { curly };
4
- }
5
- export default _default;
6
- export type Block = ItemThunk | ItemArray;
7
- export type ItemArray = readonly Item[];
8
- export type ItemThunk = () => List.List<Item>;
9
- export type Item = string | ItemArray | ItemThunk;
10
1
  /** @typedef {ItemThunk|ItemArray} Block */
11
2
  /** @typedef {readonly Item[]} ItemArray */
12
- /** @typedef {() => List.List<Item>} ItemThunk */
3
+ /** @typedef {() => list.List<Item>} ItemThunk */
13
4
  /** @typedef {string|ItemArray|ItemThunk} Item */
14
- /** @type {(indent: string) => (text: Block) => List.List<string>} */
15
- declare const flat: (indent: string) => (text: Block) => List.List<string>;
5
+ /** @type {(indent: string) => (text: Block) => list.List<string>} */
6
+ export const flat: (indent: string) => (text: Block) => list.List<string>;
16
7
  /** @type {(type: string) => (name: string) => (body: Block) => Block} */
17
- declare const curly: (type: string) => (name: string) => (body: Block) => Block;
18
- import * as List from '../types/list/module.f.mjs';
8
+ export const curly: (type: string) => (name: string) => (body: Block) => Block;
9
+ export type Block = ItemThunk | ItemArray;
10
+ export type ItemArray = readonly Item[];
11
+ export type ItemThunk = () => list.List<Item>;
12
+ export type Item = string | ItemArray | ItemThunk;
13
+ import * as list from '../types/list/module.f.mjs';
package/text/module.f.mjs CHANGED
@@ -1,21 +1,21 @@
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 { flatMap } = list
4
4
 
5
5
  /** @typedef {ItemThunk|ItemArray} Block */
6
6
 
7
7
  /** @typedef {readonly Item[]} ItemArray */
8
8
 
9
- /** @typedef {() => List.List<Item>} ItemThunk */
9
+ /** @typedef {() => list.List<Item>} ItemThunk */
10
10
 
11
11
  /** @typedef {string|ItemArray|ItemThunk} Item */
12
12
 
13
- /** @type {(indent: string) => (text: Block) => List.List<string>} */
14
- const flat = indent => {
13
+ /** @type {(indent: string) => (text: Block) => list.List<string>} */
14
+ export const flat = indent => {
15
15
 
16
- /** @type {(prefix: string) => (text: Block) => List.List<string>} */
16
+ /** @type {(prefix: string) => (text: Block) => list.List<string>} */
17
17
  const f = prefix => {
18
- /** @type {(item: Item) => List.List<string>} */
18
+ /** @type {(item: Item) => list.List<string>} */
19
19
  const g = item => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item)
20
20
  return flatMap(g)
21
21
  }
@@ -24,11 +24,4 @@ const flat = indent => {
24
24
  }
25
25
 
26
26
  /** @type {(type: string) => (name: string) => (body: Block) => Block} */
27
- const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
28
-
29
- export default {
30
- /** @readonly */
31
- flat,
32
- /** @readonly */
33
- curly,
34
- }
27
+ export const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
@@ -1,14 +1,12 @@
1
- declare namespace _default {
2
- export { sgr };
3
- export let reset: string;
4
- export let bold: string;
5
- export let fgRed: string;
6
- export let fgGreen: string;
7
- }
8
- export default _default;
9
1
  /**
10
2
  * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR
11
3
  *
12
4
  * @type {(c: number) => string}
13
5
  */
14
- declare const sgr: (c: number) => string;
6
+ export const sgr: (c: number) => string;
7
+ export namespace codes {
8
+ let reset: string;
9
+ let bold: string;
10
+ let fgRed: string;
11
+ let fgGreen: string;
12
+ }
@@ -5,11 +5,9 @@
5
5
  *
6
6
  * @type {(c: number) => string}
7
7
  */
8
- const sgr = c => `\x1b[${c.toString()}m`
8
+ export const sgr = c => `\x1b[${c.toString()}m`
9
9
 
10
- export default {
11
- /** @readonly */
12
- sgr,
10
+ export const codes = {
13
11
  /** @readonly */
14
12
  reset: sgr(0),
15
13
  /** @readonly */
package/text/test.f.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import _, * as T from './module.f.mjs'
2
- import string from '../types/string/module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
+ import * as string from '../types/string/module.f.mjs'
3
3
  const { join } = string
4
4
 
5
5
  export default () => {
6
- /** @type {T.Block} */
6
+ /** @type {_.Block} */
7
7
  const text = [
8
8
  'a',
9
9
  'b',
@@ -1,19 +1,12 @@
1
- declare namespace _default {
2
- export { fromCodePointList };
3
- export { toCodePointList };
4
- export { stringToList };
5
- export { listToString };
6
- }
7
- export default _default;
1
+ export const fromCodePointList: (input: list.List<number>) => list.Thunk<number>;
2
+ /** @type {(input: list.List<u16>) => list.List<i32>} */
3
+ export const toCodePointList: (input: list.List<u16>) => list.List<i32>;
4
+ /** @type {(s: string) => list.List<u16>} */
5
+ export const stringToList: (s: string) => list.List<u16>;
6
+ /** @type {(input: list.List<u16>) => string} */
7
+ export const listToString: (input: list.List<u16>) => string;
8
8
  export type WordOrEof = u16 | null;
9
9
  export type Utf16State = number | null;
10
10
  export type u16 = number;
11
11
  export type i32 = number;
12
- declare const fromCodePointList: (input: List.List<number>) => List.Thunk<number>;
13
- /** @type {(input: List.List<u16>) => List.List<i32>} */
14
- declare const toCodePointList: (input: List.List<u16>) => List.List<i32>;
15
- /** @type {(s: string) => List.List<u16>} */
16
- declare const stringToList: (s: string) => List.List<u16>;
17
- /** @type {(input: List.List<u16>) => string} */
18
- declare const listToString: (input: List.List<u16>) => string;
19
- import * as List from '../../types/list/module.f.mjs';
12
+ import * as list from '../../types/list/module.f.mjs';
@@ -1,9 +1,9 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import list, * as List from '../../types/list/module.f.mjs'
3
- import operator, * as Operator from '../../types/function/operator/module.f.mjs'
4
- import range from '../../types/range/module.f.mjs'
2
+ import * as list from '../../types/list/module.f.mjs'
3
+ import * as operator from '../../types/function/operator/module.f.mjs'
4
+ import * as range from '../../types/range/module.f.mjs'
5
5
  const { contains } = range
6
- import f from '../../types/function/module.f.mjs'
6
+ import * as f from '../../types/function/module.f.mjs'
7
7
  const { fn } = f
8
8
  const { map, flat, stateScan, reduce, flatMap, empty } = list
9
9
 
@@ -32,7 +32,7 @@ const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
32
32
  /** @type {(a: i32) => boolean} */
33
33
  const isSupplementaryPlane = contains([0x01_0000, 0x10_ffff])
34
34
 
35
- /** @type {(input: i32) => List.List<u16>} */
35
+ /** @type {(input: i32) => list.List<u16>} */
36
36
  const codePointToUtf16 = codePoint => {
37
37
  if (isBmpCodePoint(codePoint)) { return [codePoint] }
38
38
  if (isSupplementaryPlane(codePoint)) {
@@ -44,11 +44,11 @@ const codePointToUtf16 = codePoint => {
44
44
  return [codePoint & 0xffff]
45
45
  }
46
46
 
47
- const fromCodePointList = flatMap(codePointToUtf16)
47
+ export const fromCodePointList = flatMap(codePointToUtf16)
48
48
 
49
49
  const u16 = contains([0x0000, 0xFFFF])
50
50
 
51
- /** @type {Operator.StateScan<u16, Utf16State, List.List<i32>>} */
51
+ /** @type {operator.StateScan<u16, Utf16State, list.List<i32>>} */
52
52
  const utf16ByteToCodePointOp = state => word => {
53
53
  if (!u16(word)) {
54
54
  return [[0xffffffff], state]
@@ -68,21 +68,21 @@ const utf16ByteToCodePointOp = state => word => {
68
68
  return [[state | errorMask, word | errorMask], null]
69
69
  }
70
70
 
71
- /** @type {(state: Utf16State) => readonly[List.List<i32>, Utf16State]} */
71
+ /** @type {(state: Utf16State) => readonly[list.List<i32>, Utf16State]} */
72
72
  const utf16EofToCodePointOp = state => [state === null ? empty : [state | errorMask], null]
73
73
 
74
- /** @type {Operator.StateScan<WordOrEof, Utf16State, List.List<i32>>} */
74
+ /** @type {operator.StateScan<WordOrEof, Utf16State, list.List<i32>>} */
75
75
  const utf16ByteOrEofToCodePointOp = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
76
76
 
77
- /** @type {List.List<WordOrEof>} */
77
+ /** @type {list.List<WordOrEof>} */
78
78
  const eofList = [null]
79
79
 
80
- /** @type {(input: List.List<u16>) => List.List<i32>} */
81
- const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
80
+ /** @type {(input: list.List<u16>) => list.List<i32>} */
81
+ export const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
82
82
 
83
- /** @type {(s: string) => List.List<u16>} */
84
- const stringToList = s => {
85
- /** @type {(i: number) => List.Result<number>} */
83
+ /** @type {(s: string) => list.List<u16>} */
84
+ export const stringToList = s => {
85
+ /** @type {(i: number) => list.Result<number>} */
86
86
  const at = i => {
87
87
  const first = s.charCodeAt(i)
88
88
  return isNaN(first) ? empty : { first, tail: () => at(i + 1) }
@@ -90,18 +90,7 @@ const stringToList = s => {
90
90
  return at(0)
91
91
  }
92
92
 
93
- /** @type {(input: List.List<u16>) => string} */
94
- const listToString = fn(map(String.fromCharCode))
93
+ /** @type {(input: list.List<u16>) => string} */
94
+ export const listToString = fn(map(String.fromCharCode))
95
95
  .then(reduce(operator.concat)(''))
96
96
  .result
97
-
98
- export default {
99
- /** @readonly */
100
- fromCodePointList,
101
- /** @readonly */
102
- toCodePointList,
103
- /** @readonly */
104
- stringToList,
105
- /** @readonly */
106
- listToString
107
- }
@@ -1,10 +1,10 @@
1
- import encoding from './module.f.mjs'
2
- import json, * as Json from '../../json/module.f.mjs'
3
- import o from '../../types/object/module.f.mjs'
1
+ import * as encoding from './module.f.mjs'
2
+ import * as json from '../../json/module.f.mjs'
3
+ import * as o from '../../types/object/module.f.mjs'
4
4
  const { sort } = o
5
- import list from '../../types/list/module.f.mjs'
5
+ import * as list from '../../types/list/module.f.mjs'
6
6
 
7
- /** @type {(a: readonly Json.Unknown[]) => string} */
7
+ /** @type {(a: readonly json.Unknown[]) => string} */
8
8
  const stringify = a => json.stringify(sort)(a)
9
9
 
10
10
  export default {
@@ -1,15 +1,10 @@
1
- declare namespace _default {
2
- export { fromCodePointList };
3
- export { toCodePointList };
4
- }
5
- export default _default;
1
+ export const fromCodePointList: (input: list.List<number>) => list.Thunk<number>;
2
+ /** @type {(input: list.List<u8>) => list.List<i32>} */
3
+ export const toCodePointList: (input: list.List<u8>) => list.List<i32>;
6
4
  export type ByteOrEof = u8 | null;
7
5
  export type Utf8NonEmptyState = Array.Array1<number> | Array.Array2<number> | Array.Array3<number>;
8
6
  export type Utf8State = null | Utf8NonEmptyState;
9
7
  export type u8 = number;
10
8
  export type i32 = number;
11
- declare const fromCodePointList: (input: List.List<number>) => List.Thunk<number>;
12
- /** @type {(input: List.List<u8>) => List.List<i32>} */
13
- declare const toCodePointList: (input: List.List<u8>) => List.List<i32>;
9
+ import * as list from '../../types/list/module.f.mjs';
14
10
  import * as Array from '../../types/array/module.f.mjs';
15
- 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
  import * as operator from '../../types/function/operator/module.f.mjs'
4
4
  import * as Array from '../../types/array/module.f.mjs'
5
5
  const { flatMap, flat, stateScan } = list
@@ -16,7 +16,7 @@ const { flatMap, flat, stateScan } = list
16
16
 
17
17
  const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
18
18
 
19
- /** @type {(input:number) => List.List<u8>} */
19
+ /** @type {(input:number) => list.List<u8>} */
20
20
  const codePointToUtf8 = input => {
21
21
  if (input >= 0x0000 && input <= 0x007f) { return [input & 0b01111_1111] }
22
22
  if (input >= 0x0080 && input <= 0x07ff) { return [input >> 6 | 0b1100_0000, input & 0b0011_1111 | 0b1000_0000] }
@@ -31,7 +31,7 @@ const codePointToUtf8 = input => {
31
31
  return [errorMask]
32
32
  }
33
33
 
34
- const fromCodePointList = flatMap(codePointToUtf8)
34
+ export const fromCodePointList = flatMap(codePointToUtf8)
35
35
 
36
36
  /** @type {(state: Utf8NonEmptyState) => i32}*/
37
37
  const utf8StateToError = state => {
@@ -59,7 +59,7 @@ const utf8StateToError = state => {
59
59
  return x | errorMask
60
60
  }
61
61
 
62
- /** @type {operator.StateScan<number, Utf8State, List.List<i32>>} */
62
+ /** @type {operator.StateScan<number, Utf8State, list.List<i32>>} */
63
63
  const utf8ByteToCodePointOp = state => byte => {
64
64
  if (byte < 0x00 || byte > 0xff) {
65
65
  return [[errorMask], state]
@@ -95,22 +95,15 @@ const utf8ByteToCodePointOp = state => byte => {
95
95
  return [[error, byte | errorMask], null]
96
96
  }
97
97
 
98
- /** @type {(state: Utf8State) => readonly[List.List<i32>, Utf8State]} */
98
+ /** @type {(state: Utf8State) => readonly[list.List<i32>, Utf8State]} */
99
99
  const utf8EofToCodePointOp = state =>
100
100
  [state === null ? null : [utf8StateToError(state)], null]
101
101
 
102
- /** @type {operator.StateScan<ByteOrEof, Utf8State, List.List<i32>>} */
102
+ /** @type {operator.StateScan<ByteOrEof, Utf8State, list.List<i32>>} */
103
103
  const utf8ByteOrEofToCodePointOp = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
104
104
 
105
- /** @type {List.List<ByteOrEof>} */
105
+ /** @type {list.List<ByteOrEof>} */
106
106
  const eofList = [null]
107
107
 
108
- /** @type {(input: List.List<u8>) => List.List<i32>} */
109
- const toCodePointList = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
110
-
111
- export default {
112
- /** @readonly */
113
- fromCodePointList,
114
- /** @readonly */
115
- toCodePointList
116
- }
108
+ /** @type {(input: list.List<u8>) => list.List<i32>} */
109
+ export const toCodePointList = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
@@ -1,8 +1,8 @@
1
- import encoding from './module.f.mjs'
2
- import json from '../../json/module.f.mjs'
3
- import o from '../../types/object/module.f.mjs'
1
+ import * as encoding from './module.f.mjs'
2
+ import * as json from '../../json/module.f.mjs'
3
+ import * as o from '../../types/object/module.f.mjs'
4
4
  const { sort } = o
5
- import list from '../../types/list/module.f.mjs'
5
+ import * as list from '../../types/list/module.f.mjs'
6
6
 
7
7
  const stringify = json.stringify(sort)
8
8
 
@@ -1,13 +1,17 @@
1
- declare namespace _default {
2
- export { at };
3
- export { first };
4
- export { last };
5
- export { head };
6
- export { tail };
7
- export { splitFirst };
8
- export { splitLast };
9
- }
10
- export default _default;
1
+ /** @type {(index: number) => <T>(a: readonly T[]) => T|null} */
2
+ export const at: (index: number) => <T>(a: readonly T[]) => T | null;
3
+ /** @type {<T>(_: readonly T[]) => T|null} */
4
+ export const first: <T>(_: readonly T[]) => T | null;
5
+ /** @type {<T>(_: readonly T[]) => T|null} */
6
+ export const last: <T>(_: readonly T[]) => T | null;
7
+ /** @type {<T>(_: readonly T[]) => readonly T[] | null} */
8
+ export const tail: <T>(_: readonly T[]) => readonly T[] | null;
9
+ /** @type {<T>(_: readonly T[]) => readonly[T, readonly T[]]|null} */
10
+ export const splitFirst: <T>(_: readonly T[]) => readonly [T, readonly T[]] | null;
11
+ /** @type {<T>(_: readonly T[]) => readonly T[]|null} */
12
+ export const head: <T>(_: readonly T[]) => readonly T[] | null;
13
+ /** @type {<T>(_: readonly T[]) => readonly[readonly T[], T]|null} */
14
+ export const splitLast: <T>(_: readonly T[]) => readonly [readonly T[], T] | null;
11
15
  export type Array1<T> = readonly [T];
12
16
  export type Index1 = 0;
13
17
  export type Array2<T> = readonly [T, T];
@@ -25,17 +29,3 @@ export type Index16 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
25
29
  export type Array1_5<T> = Array1<T> | Array2<T> | Array3<T> | Array4<T> | Array5<T>;
26
30
  export type Index5 = 0 | 1 | 2 | 3 | 4;
27
31
  export type KeyOf<T> = T extends Array1<infer _> ? Index1 : T extends Array2<infer _> ? Index2 : T extends Array3<infer _> ? Index3 : T extends Array4<infer _> ? Index4 : T extends Array5<infer _> ? Index5 : T extends readonly (infer _)[] ? number : never;
28
- /** @type {(index: number) => <T>(a: readonly T[]) => T|null} */
29
- declare const at: (index: number) => <T>(a: readonly T[]) => T | null;
30
- /** @type {<T>(_: readonly T[]) => T|null} */
31
- declare const first: <T>(_: readonly T[]) => T | null;
32
- /** @type {<T>(_: readonly T[]) => T|null} */
33
- declare const last: <T>(_: readonly T[]) => T | null;
34
- /** @type {<T>(_: readonly T[]) => readonly T[]|null} */
35
- declare const head: <T>(_: readonly T[]) => readonly T[] | null;
36
- /** @type {<T>(_: readonly T[]) => readonly T[] | null} */
37
- declare const tail: <T>(_: readonly T[]) => readonly T[] | null;
38
- /** @type {<T>(_: readonly T[]) => readonly[T, readonly T[]]|null} */
39
- declare const splitFirst: <T>(_: readonly T[]) => readonly [T, readonly T[]] | null;
40
- /** @type {<T>(_: readonly T[]) => readonly[readonly T[], T]|null} */
41
- declare const splitLast: <T>(_: readonly T[]) => readonly [readonly T[], T] | null;