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
@@ -1,117 +1,82 @@
1
- declare namespace _default {
2
- export let empty: null;
3
- export { concat };
4
- export { next };
5
- export { iterable };
6
- export { toArray };
7
- export { flat };
8
- export { map };
9
- export { flatMap };
10
- export { filter };
11
- export { filterMap };
12
- export { takeWhile };
13
- export { take };
14
- export { dropWhile };
15
- export { drop };
16
- export { first };
17
- export { last };
18
- export { find };
19
- export { some };
20
- export { every };
21
- export { isEmpty };
22
- export { includes };
23
- export { countdown };
24
- export { repeat };
25
- export { cycle };
26
- export { scan };
27
- export { stateScan };
28
- export { foldScan };
29
- export { fold };
30
- export { reduce };
31
- export { length };
32
- export { entries };
33
- export { reverse };
34
- export { zip };
35
- export { equal };
36
- }
37
- export default _default;
38
- export type List<T> = NotLazy<T> | Thunk<T>;
39
- export type NotLazy<T> = Result<T> | Concat<T> | readonly T[];
40
- export type Empty = null;
41
- export type Result<T> = Empty | NonEmpty<T>;
42
- export type Thunk<T> = () => List<T>;
43
- export type NonEmpty<T> = {
44
- readonly first: T;
45
- readonly tail: List<T>;
46
- };
47
- export type Concat<T> = {
48
- readonly head: List<T>;
49
- readonly tail: List<T>;
50
- };
51
- export type Entry<T> = readonly [number, T];
52
1
  /** @type {<T>(head: List<T>) => (tail: List<T>) => List<T>} */
53
- declare const concat: <T>(head: List<T>) => (tail: List<T>) => List<T>;
2
+ export const concat: <T>(head: List<T>) => (tail: List<T>) => List<T>;
54
3
  /** @type {<T>(list: List<T>) => Result<T>} */
55
- declare const next: <T>(list: List<T>) => Result<T>;
4
+ export const next: <T>(list: List<T>) => Result<T>;
56
5
  /** @type {<T>(list: List<T>) => Iterable<T>} */
57
- declare const iterable: <T>(list: List<T>) => Iterable<T>;
6
+ export const iterable: <T>(list: List<T>) => Iterable<T>;
58
7
  /** @type {<T>(list: List<T>) => readonly T[]} */
59
- declare const toArray: <T>(list: List<T>) => readonly T[];
8
+ export const toArray: <T>(list: List<T>) => readonly T[];
60
9
  /** @type {<T>(list: List<List<T>>) => Thunk<T>} */
61
- declare const flat: <T>(list: List<List<T>>) => Thunk<T>;
10
+ export const flat: <T>(list: List<List<T>>) => Thunk<T>;
62
11
  /** @type {<I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>} */
63
- declare const map: <I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>;
12
+ export const map: <I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>;
64
13
  /** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>} */
65
- declare const flatMap: <I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>;
14
+ export const flatMap: <I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>;
66
15
  /** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
67
- declare const filter: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
16
+ export const filter: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
68
17
  /** @type {<I, O>(f: (value: I) => O|null) => (input: List<I>) => Thunk<O>} */
69
- declare const filterMap: <I, O>(f: (value: I) => O | null) => (input: List<I>) => Thunk<O>;
18
+ export const filterMap: <I, O>(f: (value: I) => O | null) => (input: List<I>) => Thunk<O>;
70
19
  /** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
71
- declare const takeWhile: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
20
+ export const takeWhile: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
72
21
  /** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
73
- declare const take: (n: number) => <T>(input: List<T>) => Thunk<T>;
22
+ export const take: (n: number) => <T>(input: List<T>) => Thunk<T>;
74
23
  /** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
75
- declare const dropWhile: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
24
+ export const dropWhile: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
76
25
  /** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
77
- declare const drop: (n: number) => <T>(input: List<T>) => Thunk<T>;
26
+ export const drop: (n: number) => <T>(input: List<T>) => Thunk<T>;
78
27
  /** @type {<D>(def: D) => <T>(input: List<T>) => D|T} */
79
- declare const first: <D>(def: D) => <T>(input: List<T>) => D | T;
28
+ export const first: <D>(def: D) => <T>(input: List<T>) => D | T;
80
29
  /** @type {<D>(first: D) => <T>(tail: List<T>) => D|T} */
81
- declare const last: <D>(first: D) => <T>(tail: List<T>) => D | T;
30
+ export const last: <D>(first: D) => <T>(tail: List<T>) => D | T;
82
31
  /** @type {<D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D|T} */
83
- declare const find: <D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D | T;
32
+ export const find: <D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D | T;
84
33
  /** @type {(input: List<boolean>) => boolean} */
85
- declare const some: (input: List<boolean>) => boolean;
86
- declare const every: import("../function/module.f.mjs").Func<List<boolean>, boolean>;
34
+ export const some: (input: List<boolean>) => boolean;
87
35
  /** @type {<T>(input: List<T>) => boolean} */
88
- declare const isEmpty: <T>(input: List<T>) => boolean;
36
+ export const isEmpty: <T>(input: List<T>) => boolean;
37
+ export const every: function_.Func<List<boolean>, boolean>;
89
38
  /** @type {<T>(value: T) => (sequence: List<T>) => boolean} */
90
- declare const includes: <T>(value: T) => (sequence: List<T>) => boolean;
39
+ export const includes: <T>(value: T) => (sequence: List<T>) => boolean;
91
40
  /** @type {(count: number) => Thunk<number>} */
92
- declare const countdown: (count: number) => Thunk<number>;
41
+ export const countdown: (count: number) => Thunk<number>;
93
42
  /** @type {<T>(v: T) => (c: number) => Thunk<T>} */
94
- declare const repeat: <T>(v: T) => (c: number) => Thunk<T>;
43
+ export const repeat: <T>(v: T) => (c: number) => Thunk<T>;
95
44
  /** @type {<T>(list: List<T>) => List<T>} */
96
- declare const cycle: <T>(list: List<T>) => List<T>;
97
- /** @type {<I, O>(op: Operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
98
- declare const scan: <I, O>(op: Operator.Scan<I, O>) => (input: List<I>) => Thunk<O>;
99
- /** @type {<I, S, O>(op: Operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
100
- declare const stateScan: <I, S, O>(op: Operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>;
101
- /** @type {<I,O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
102
- declare const foldScan: <I, O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>;
103
- /** @type {<I,O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
104
- declare const fold: <I, O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => O;
105
- /** @type {<T>(op: Operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
106
- declare const reduce: <T>(op: Operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D | T;
45
+ export const cycle: <T>(list: List<T>) => List<T>;
46
+ /** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
47
+ export const scan: <I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>;
48
+ /** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
49
+ export const stateScan: <I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>;
50
+ /** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
51
+ export const foldScan: <I, O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>;
52
+ /** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
53
+ export const fold: <I, O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O;
54
+ /** @type {<T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
55
+ export const reduce: <T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D | T;
107
56
  /** @type {<T>(input: List<T>) => number} */
108
- declare const length: <T>(input: List<T>) => number;
57
+ export const length: <T>(input: List<T>) => number;
109
58
  /** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
110
- declare const entries: <T>(input: List<T>) => Thunk<Entry<T>>;
59
+ export const entries: <T>(input: List<T>) => Thunk<Entry<T>>;
111
60
  /** @type {<T>(input: List<T>) => List<T>} */
112
- declare const reverse: <T>(input: List<T>) => List<T>;
61
+ export const reverse: <T>(input: List<T>) => List<T>;
113
62
  /** @type {<A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly[A, B]>} */
114
- declare const zip: <A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly [A, B]>;
115
- /** @type {<T>(e: Operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
116
- declare const equal: <T>(e: Operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean;
117
- import * as Operator from '../function/operator/module.f.mjs';
63
+ export const zip: <A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly [A, B]>;
64
+ /** @type {<T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
65
+ export const equal: <T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean;
66
+ export const empty: null;
67
+ export type List<T> = NotLazy<T> | Thunk<T>;
68
+ export type NotLazy<T> = Result<T> | Concat<T> | readonly T[];
69
+ export type Empty = null;
70
+ export type Result<T> = Empty | NonEmpty<T>;
71
+ export type Thunk<T> = () => List<T>;
72
+ export type NonEmpty<T> = {
73
+ readonly first: T;
74
+ readonly tail: List<T>;
75
+ };
76
+ export type Concat<T> = {
77
+ readonly head: List<T>;
78
+ readonly tail: List<T>;
79
+ };
80
+ export type Entry<T> = readonly [number, T];
81
+ import * as function_ from '../function/module.f.mjs';
82
+ import * as operator from '../function/operator/module.f.mjs';
@@ -1,7 +1,7 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import function_ from '../function/module.f.mjs'
2
+ import * as function_ from '../function/module.f.mjs'
3
3
  const { identity, fn, compose } = function_
4
- import operator, * as Operator from '../function/operator/module.f.mjs'
4
+ import * as operator from '../function/operator/module.f.mjs'
5
5
  const {
6
6
  addition,
7
7
  logicalNot,
@@ -62,7 +62,7 @@ const fromArray = array => {
62
62
  }
63
63
 
64
64
  /** @type {<T>(head: List<T>) => (tail: List<T>) => List<T>} */
65
- const concat = head => tail => tail === null ? head : ({ head, tail })
65
+ export const concat = head => tail => tail === null ? head : ({ head, tail })
66
66
 
67
67
  /** @type {<T>(list: List<T>) => NotLazy<T> } */
68
68
  const trampoline = list => {
@@ -71,7 +71,7 @@ const trampoline = list => {
71
71
  }
72
72
 
73
73
  /** @type {<T>(list: List<T>) => Result<T>} */
74
- const next = head => {
74
+ export const next = head => {
75
75
  /** @type {typeof head} */
76
76
  let tail = null
77
77
  while (true) {
@@ -95,7 +95,7 @@ const next = head => {
95
95
  }
96
96
 
97
97
  /** @type {<T>(list: List<T>) => Iterable<T>} */
98
- const iterable = list => ({
98
+ export const iterable = list => ({
99
99
  *[Symbol.iterator]() {
100
100
  let i = list
101
101
  while (true) {
@@ -110,7 +110,7 @@ const iterable = list => ({
110
110
  const { from } = Array
111
111
 
112
112
  /** @type {<T>(list: List<T>) => readonly T[]} */
113
- const toArray = list => {
113
+ export const toArray = list => {
114
114
  const u = trampoline(list)
115
115
  return u instanceof Array ? u : from(iterable(u))
116
116
  }
@@ -126,16 +126,16 @@ const apply = f => input => () => {
126
126
  const flatStep = ({ first, tail }) => concat(first)(flat(tail))
127
127
 
128
128
  /** @type {<T>(list: List<List<T>>) => Thunk<T>} */
129
- const flat = apply(flatStep)
129
+ export const flat = apply(flatStep)
130
130
 
131
131
  /** @type {<I, O>(f: (value: I) => O) => (n: NonEmpty<I>) => List<O>} */
132
132
  const mapStep = f => ({ first, tail }) => ({ first: f(first), tail: map(f)(tail) })
133
133
 
134
134
  /** @type {<I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>} */
135
- const map = f => apply(mapStep(f))
135
+ export const map = f => apply(mapStep(f))
136
136
 
137
137
  /** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>} */
138
- const flatMap = f => compose(map(f))(flat)
138
+ export const flatMap = f => compose(map(f))(flat)
139
139
 
140
140
  /** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
141
141
  const filterStep = f => ({ first, tail }) => {
@@ -144,7 +144,7 @@ const filterStep = f => ({ first, tail }) => {
144
144
  }
145
145
 
146
146
  /** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
147
- const filter = f => apply(filterStep(f))
147
+ export const filter = f => apply(filterStep(f))
148
148
 
149
149
  /** @type {<I, O>(f: (value: I) => O|null) => (n: NonEmpty<I>) => List<O>} */
150
150
  const filterMapStep = f => n => {
@@ -153,40 +153,40 @@ const filterMapStep = f => n => {
153
153
  }
154
154
 
155
155
  /** @type {<I, O>(f: (value: I) => O|null) => (input: List<I>) => Thunk<O>} */
156
- const filterMap = f => apply(filterMapStep(f))
156
+ export const filterMap = f => apply(filterMapStep(f))
157
157
 
158
158
  /** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
159
159
  const takeWhileStep = f => ({ first, tail }) => f(first) ? { first, tail: takeWhile(f)(tail) } : null
160
160
 
161
161
  /** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
162
- const takeWhile = f => apply(takeWhileStep(f))
162
+ export const takeWhile = f => apply(takeWhileStep(f))
163
163
 
164
164
  /** @type {(n: number) => <T>(result: NonEmpty<T>) => List<T>} */
165
165
  const takeStep = n => ({ first, tail }) => 0 < n ? { first: first, tail: take(n - 1)(tail) } : null
166
166
 
167
167
  /** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
168
- const take = n => apply(takeStep(n))
168
+ export const take = n => apply(takeStep(n))
169
169
 
170
170
  /** @type {<T>(f: (value: T) => boolean) => (ne: NonEmpty<T>) => List<T>} */
171
171
  const dropWhileStep = f => ne => f(ne.first) ? dropWhile(f)(ne.tail) : ne
172
172
 
173
173
  /** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
174
- const dropWhile = f => apply(dropWhileStep(f))
174
+ export const dropWhile = f => apply(dropWhileStep(f))
175
175
 
176
176
  /** @type {(n: number) => <T>(ne: NonEmpty<T>) => List<T>} */
177
177
  const dropStep = n => ne => 0 < n ? drop(n - 1)(ne.tail) : ne
178
178
 
179
179
  /** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
180
- const drop = n => apply(dropStep(n))
180
+ export const drop = n => apply(dropStep(n))
181
181
 
182
182
  /** @type {<D>(def: D) => <T>(input: List<T>) => D|T} */
183
- const first = def => input => {
183
+ export const first = def => input => {
184
184
  const ne = next(input)
185
185
  return ne === null ? def : ne.first
186
186
  }
187
187
 
188
188
  /** @type {<D>(first: D) => <T>(tail: List<T>) => D|T} */
189
- const last = first => tail => {
189
+ export const last = first => tail => {
190
190
  /** @typedef {typeof tail extends List<infer T> ? T : never} T */
191
191
  /** @type {NonEmpty<typeof first|T>} */
192
192
  let i = { first, tail }
@@ -200,61 +200,61 @@ const last = first => tail => {
200
200
  }
201
201
 
202
202
  /** @type {<D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D|T} */
203
- const find = def => f => compose(filter(f))(first(def))
203
+ export const find = def => f => compose(filter(f))(first(def))
204
204
 
205
205
  /** @type {(input: List<boolean>) => boolean} */
206
- const some = find(false)(identity)
206
+ export const some = find(false)(identity)
207
207
 
208
208
  /** @type {<T>(input: List<T>) => boolean} */
209
- const isEmpty = fn(map(() => true))
209
+ export const isEmpty = fn(map(() => true))
210
210
  .then(some)
211
211
  .then(logicalNot)
212
212
  .result
213
213
 
214
- const every = fn(map(logicalNot))
214
+ export const every = fn(map(logicalNot))
215
215
  .then(some)
216
216
  .then(logicalNot)
217
217
  .result
218
218
 
219
219
  /** @type {<T>(value: T) => (sequence: List<T>) => boolean} */
220
- const includes = value => compose(map(strictEqual(value)))(some)
220
+ export const includes = value => compose(map(strictEqual(value)))(some)
221
221
 
222
222
  /** @type {(count: number) => Thunk<number>} */
223
- const countdown = count => () => {
223
+ export const countdown = count => () => {
224
224
  if (count <= 0) { return null }
225
225
  const first = count - 1
226
226
  return { first, tail: countdown(first) }
227
227
  }
228
228
 
229
229
  /** @type {<T>(v: T) => (c: number) => Thunk<T>} */
230
- const repeat = v => compose(countdown)(map(() => v))
230
+ export const repeat = v => compose(countdown)(map(() => v))
231
231
 
232
232
  /** @type {<T>(list: List<T>) => List<T>} */
233
- const cycle = list => () => {
233
+ export const cycle = list => () => {
234
234
  const i = next(list)
235
235
  return i === null ? null : { first: i.first, tail: concat(i.tail)(cycle(list)) }
236
236
  }
237
237
 
238
- /** @type {<I, O>(op: Operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>} */
238
+ /** @type {<I, O>(op: operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>} */
239
239
  const scanStep = op => ne => {
240
240
  const [first, newOp] = op(ne.first)
241
241
  return { first, tail: scan(newOp)(ne.tail) }
242
242
  }
243
243
 
244
- /** @type {<I, O>(op: Operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
245
- const scan = op => apply(scanStep(op))
244
+ /** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
245
+ export const scan = op => apply(scanStep(op))
246
246
 
247
- /** @type {<I, S, O>(op: Operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
248
- const stateScan = op => compose(stateScanToScan(op))(scan)
247
+ /** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
248
+ export const stateScan = op => compose(stateScanToScan(op))(scan)
249
249
 
250
- /** @type {<I,O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
251
- const foldScan = op => compose(foldToScan(op))(scan)
250
+ /** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
251
+ export const foldScan = op => compose(foldToScan(op))(scan)
252
252
 
253
- /** @type {<I,O>(op: Operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
254
- const fold = op => init => compose(foldScan(op)(init))(last(init))
253
+ /** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
254
+ export const fold = op => init => compose(foldScan(op)(init))(last(init))
255
255
 
256
- /** @type {<T>(op: Operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
257
- const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
256
+ /** @type {<T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
257
+ export const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
258
258
 
259
259
  /** @type {<T>(list: List<T>) => Thunk<number>} */
260
260
  const lengthList = list => () => {
@@ -271,7 +271,7 @@ const lengthList = list => () => {
271
271
  const sum = reduce(addition)(0)
272
272
 
273
273
  /** @type {<T>(input: List<T>) => number} */
274
- const length = compose(lengthList)(sum)
274
+ export const length = compose(lengthList)(sum)
275
275
 
276
276
  /**
277
277
  * @template T
@@ -282,9 +282,9 @@ const length = compose(lengthList)(sum)
282
282
  const entryOperator = index => value => [[index, value], index + 1]
283
283
 
284
284
  /** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
285
- const entries = input => {
285
+ export const entries = input => {
286
286
  /** @typedef {typeof input extends List<infer T> ? T : never} T */
287
- /** @type {Operator.StateScan<T, Number, Entry<T>>} */
287
+ /** @type {operator.StateScan<T, Number, Entry<T>>} */
288
288
  const o = entryOperator
289
289
  return stateScan(o)(0)(input)
290
290
  }
@@ -293,10 +293,10 @@ const entries = input => {
293
293
  const reverseOperator = first => tail => ({ first, tail })
294
294
 
295
295
  /** @type {<T>(input: List<T>) => List<T>} */
296
- const reverse = fold(reverseOperator)(null)
296
+ export const reverse = fold(reverseOperator)(null)
297
297
 
298
298
  /** @type {<A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly[A, B]>} */
299
- const zip = a => b => () => {
299
+ export const zip = a => b => () => {
300
300
  const aResult = next(a)
301
301
  if (aResult === null) { return null }
302
302
  const bResult = next(b)
@@ -304,9 +304,9 @@ const zip = a => b => () => {
304
304
  return { first: [aResult.first, bResult.first], tail: zip(aResult.tail)(bResult.tail) }
305
305
  }
306
306
 
307
- /** @type {<T>(e: Operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
308
- const equal = e => {
309
- /** @typedef {typeof e extends Operator.Equal<infer T> ? T : never} T */
307
+ /** @type {<T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
308
+ export const equal = e => {
309
+ /** @typedef {typeof e extends operator.Equal<infer T> ? T : never} T */
310
310
  /** @type {(a: List<T>) => (b: List<T>) => List<boolean>} */
311
311
  const f = a => b => () => {
312
312
  const [aResult, bResult] = [next(a), next(b)]
@@ -317,73 +317,4 @@ const equal = e => {
317
317
  return a => b => every(f(a)(b))
318
318
  }
319
319
 
320
- export default {
321
- /** @readonly */
322
- empty: null,
323
- /** @readonly */
324
- concat,
325
- /** @readonly */
326
- next,
327
- /** @readonly */
328
- iterable,
329
- /** @readonly */
330
- toArray,
331
- /** @readonly */
332
- flat,
333
- /** @readonly */
334
- map,
335
- /** @readonly */
336
- flatMap,
337
- /** @readonly */
338
- filter,
339
- /** @readonly */
340
- filterMap,
341
- /** @readonly */
342
- takeWhile,
343
- /** @readonly */
344
- take,
345
- /** @readonly */
346
- dropWhile,
347
- /** @readonly */
348
- drop,
349
- /** @readonly */
350
- first,
351
- /** @readonly */
352
- last,
353
- /** @readonly */
354
- find,
355
- /** @readonly */
356
- some,
357
- /** @readonly */
358
- every,
359
- /** @readonly */
360
- isEmpty,
361
- /** @readonly */
362
- includes,
363
- /** @readonly */
364
- countdown,
365
- /** @readonly */
366
- repeat,
367
- /** @readonly */
368
- cycle,
369
- /** @readonly */
370
- scan,
371
- /** @readonly */
372
- stateScan,
373
- /** @readonly */
374
- foldScan,
375
- /** @readonly */
376
- fold,
377
- /** @readonly */
378
- reduce,
379
- /** @readonly */
380
- length,
381
- /** @readonly */
382
- entries,
383
- /** @readonly */
384
- reverse,
385
- /** @readonly */
386
- zip,
387
- /** @readonly */
388
- equal
389
- }
320
+ export const empty = null
@@ -1,11 +1,11 @@
1
- import _, * as T from './module.f.mjs'
2
- import json, * as Json from '../../json/module.f.mjs'
3
- import o from '../object/module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
+ import * as json from '../../json/module.f.mjs'
3
+ import * as o from '../object/module.f.mjs'
4
4
  const { sort } = o
5
- import operator from '../function/operator/module.f.mjs'
5
+ import * as operator from '../function/operator/module.f.mjs'
6
6
  const { addition, strictEqual, reduceToScan } = operator
7
7
 
8
- /** @type {(sequence: T.List<Json.Unknown>) => string} */
8
+ /** @type {(sequence: _.List<json.Unknown>) => string} */
9
9
  const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
10
10
 
11
11
  const stringifyTest = () => {
@@ -197,7 +197,7 @@ const stress = () => ({
197
197
  if (first !== n - 1) { throw first }
198
198
  },
199
199
  concatBack: () => {
200
- /** @type {T.List<number>} */
200
+ /** @type {_.List<number>} */
201
201
  let sequence = []
202
202
  // 20_000_000 is too much
203
203
  // 10_000_000 is too much for Deno 1
@@ -207,7 +207,7 @@ const stress = () => ({
207
207
  const r = _.toArray(sequence)
208
208
  },
209
209
  flatToArray: () => {
210
- /** @type {T.List<number>} */
210
+ /** @type {_.List<number>} */
211
211
  let sequence = []
212
212
  // 4_000_000 is too much
213
213
  for (let i = 0; i < 2_000_000; ++i) {
@@ -216,7 +216,7 @@ const stress = () => ({
216
216
  const r = _.toArray(sequence)
217
217
  },
218
218
  flatNext: () => {
219
- /** @type {T.List<number>} */
219
+ /** @type {_.List<number>} */
220
220
  let sequence = []
221
221
  // 4_000_000 is too much
222
222
  for (let i = 0; i < 2_000_000; ++i) {
@@ -225,7 +225,7 @@ const stress = () => ({
225
225
  const a = _.next(sequence)
226
226
  },
227
227
  concatFront: () => {
228
- /** @type {T.List<number>} */
228
+ /** @type {_.List<number>} */
229
229
  let sequence = []
230
230
  // 20_000_000 is too much
231
231
  for (let i = 0; i < 10_000_000; ++i) {
@@ -234,7 +234,7 @@ const stress = () => ({
234
234
  const a = _.next(sequence)
235
235
  },
236
236
  flatFront: () => {
237
- /** @type {T.List<number>} */
237
+ /** @type {_.List<number>} */
238
238
  let sequence = []
239
239
  // 10_000_000 is too much
240
240
  for (let i = 0; i < 5_000_000; ++i) {
@@ -1,30 +1,21 @@
1
- declare namespace _default {
2
- export let empty: null;
3
- export { at };
4
- export { setReduce };
5
- export { setReplace };
6
- export { entries };
7
- export { fromEntries };
8
- export { remove };
9
- }
10
- export default _default;
11
- export type Sign = Compare.Sign;
12
- export type Cmp<T> = Compare.Compare<T>;
13
- export type Entry<T> = readonly [string, T];
14
- export type Map<T> = BtreeTypes.Tree<Entry<T>>;
15
1
  /** @type {(name: string) => <T>(map: Map<T>) => T|null} */
16
- declare const at: (name: string) => <T>(map: Map<T>) => T | null;
2
+ export const at: (name: string) => <T>(map: Map<T>) => T | null;
17
3
  /** @type {<T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>} */
18
- declare const setReduce: <T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>;
4
+ export const setReduce: <T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>;
19
5
  /** @type {(name: string) => <T>(value: T) => (map: Map<T>) => Map<T>} */
20
- declare const setReplace: (name: string) => <T>(value: T) => (map: Map<T>) => Map<T>;
21
- /** @type {<T>(map: Map<T>) => List.List<Entry<T>>} */
22
- declare const entries: <T>(map: Map<T>) => List.List<Entry<T>>;
23
- /** @type {<T>(entries: List.List<Entry<T>>) => Map<T>} */
24
- declare const fromEntries: <T>(entries: List.List<Entry<T>>) => Map<T>;
6
+ export const setReplace: (name: string) => <T>(value: T) => (map: Map<T>) => Map<T>;
7
+ /** @type {<T>(map: Map<T>) => list.List<Entry<T>>} */
8
+ export const entries: <T>(map: Map<T>) => list.List<Entry<T>>;
9
+ /** @type {<T>(entries: list.List<Entry<T>>) => Map<T>} */
10
+ export const fromEntries: <T>(entries: list.List<Entry<T>>) => Map<T>;
25
11
  /** @type {(name: string) => <T>(map: Map<T>) => Map<T>} */
26
- declare const remove: (name: string) => <T>(map: Map<T>) => Map<T>;
12
+ export const remove: (name: string) => <T>(map: Map<T>) => Map<T>;
13
+ export const empty: null;
14
+ export type Sign = Compare.Sign;
15
+ export type Cmp<T> = Compare.Compare<T>;
16
+ export type Entry<T> = readonly [string, T];
17
+ export type Map<T> = BtreeTypes.Tree<Entry<T>>;
18
+ import * as Operator from '../function/operator/module.f.mjs';
19
+ import * as list from '../list/module.f.mjs';
27
20
  import * as Compare from '../function/compare/module.f.mjs';
28
21
  import * as BtreeTypes from '../btree/types/module.f.mjs';
29
- import * as Operator from '../function/operator/module.f.mjs';
30
- import * as List from '../list/module.f.mjs';