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,18 +1,16 @@
1
- declare namespace _default {
2
- export { parse };
3
- }
4
- export default _default;
1
+ /** @type {(tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>} */
2
+ export const parse: (tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>;
5
3
  export type JsonObject = {
6
4
  readonly kind: "object";
7
- readonly values: Map.Map<Json.Unknown>;
5
+ readonly values: map.Map<Json.Unknown>;
8
6
  readonly key: string;
9
7
  };
10
8
  export type JsonArray = {
11
9
  readonly kind: "array";
12
- readonly values: List.List<Json.Unknown>;
10
+ readonly values: list.List<Json.Unknown>;
13
11
  };
14
12
  export type JsonStackElement = JsonObject | JsonArray;
15
- export type JsonStack = List.List<JsonStackElement>;
13
+ export type JsonStack = list.List<JsonStackElement>;
16
14
  export type StateParse = {
17
15
  readonly status: "" | "[" | "[v" | "[," | "{" | "{k" | "{:" | "{v" | "{,";
18
16
  readonly top: JsonStackElement | null;
@@ -27,10 +25,8 @@ export type StateError = {
27
25
  readonly message: string;
28
26
  };
29
27
  export type JsonState = StateParse | StateResult | StateError;
30
- /** @type {(tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>} */
31
- declare const parse: (tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>;
32
- import * as Map from '../../types/map/module.f.mjs';
33
- import * as Json from '../module.f.mjs';
34
- import * as List from '../../types/list/module.f.mjs';
28
+ import * as list from '../../types/list/module.f.mjs';
35
29
  import * as Tokenizer from '../tokenizer/module.f.mjs';
36
- import * as Result from '../../types/result/module.f.mjs';
30
+ import * as result from '../../types/result/module.f.mjs';
31
+ import * as Json from '../module.f.mjs';
32
+ import * as map from '../../types/map/module.f.mjs';
@@ -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)
@@ -45,12 +45,13 @@ const mapToken = input =>
45
45
  case 'string':
46
46
  case 'number':
47
47
  case 'error': return [input]
48
- case 'ws': return empty
48
+ case 'ws':
49
+ case 'nl': return empty
49
50
  default: return [{ kind: 'error', message: 'invalid token' }]
50
51
  }
51
52
  }
52
53
 
53
- /** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
54
+ /** @type {(input: ScanInput) => readonly [list.List<JsonToken>, ScanState]} */
54
55
  const parseDefaultState = input =>
55
56
  {
56
57
  if (input === null) return [empty, { kind: 'def'}]
@@ -61,7 +62,7 @@ const parseDefaultState = input =>
61
62
  }
62
63
  }
63
64
 
64
- /** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
65
+ /** @type {(input: ScanInput) => readonly [list.List<JsonToken>, ScanState]} */
65
66
  const parseMinusState = input =>
66
67
  {
67
68
  if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
@@ -73,7 +74,7 @@ const parseMinusState = input =>
73
74
  }
74
75
  }
75
76
 
76
- /** @type {Operator.StateScan<ScanInput, ScanState, List.List<JsonToken>>} */
77
+ /** @type {Operator.StateScan<ScanInput, ScanState, list.List<JsonToken>>} */
77
78
  const scanToken = state => input => {
78
79
  switch(state.kind)
79
80
  {
@@ -82,15 +83,10 @@ const scanToken = state => input => {
82
83
  }
83
84
  }
84
85
 
85
- /** @type {(input: List.List<number>) => List.List<JsonToken>} */
86
- const tokenize = input =>
86
+ /** @type {(input: list.List<number>) => list.List<JsonToken>} */
87
+ export const tokenize = input =>
87
88
  {
88
- /** @type {List.List<ScanInput>} */
89
+ /** @type {list.List<ScanInput>} */
89
90
  const jsTokens = jsTokenizer.tokenize(input)
90
91
  return flat(stateScan(scanToken)({ kind: 'def' })(list.concat(jsTokens)([null])))
91
92
  }
92
-
93
- export default {
94
- /** @readonly */
95
- tokenize
96
- }
@@ -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.608",
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",
@@ -0,0 +1,6 @@
1
+ [package]
2
+ name = "nanvm-lib"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
@@ -0,0 +1,119 @@
1
+ use crate::{interface::{Any, Container, Extension, Unpacked}, nullish::Nullish::*, simple::Simple};
2
+
3
+ pub trait AnyExtension: Any {
4
+ fn string(c: &str) -> Self::String16 {
5
+ c.encode_utf16().into_iter().to_complex()
6
+ }
7
+ fn to_string(self) -> Self::String16 {
8
+ match self.unpack() {
9
+ Unpacked::Nullish(v) => Self::string(match v {
10
+ Null => "null",
11
+ Undefined => "undefined",
12
+ }),
13
+ Unpacked::Bool(v) => Self::string(match v {
14
+ true => "true",
15
+ false => "false",
16
+ }),
17
+ Unpacked::Number(_) => todo!(),
18
+ Unpacked::String16(v) => v,
19
+ Unpacked::BigInt(_) => todo!(),
20
+ Unpacked::Array(_) => [].to_complex(),
21
+ Unpacked::Object(_) => Self::string("[object Object"),
22
+ Unpacked::Function(_) => todo!(),
23
+ }
24
+ }
25
+ fn own_property(self, i: Self) -> Self {
26
+ match self.unpack() {
27
+ Unpacked::Nullish(_) => panic!("own_property(\"nullish\")"),
28
+ Unpacked::Bool(_) => Simple::Nullish(Undefined).to_unknown(),
29
+ Unpacked::Number(_) => todo!(),
30
+ Unpacked::String16(_) => todo!(),
31
+ Unpacked::BigInt(_) => todo!(),
32
+ Unpacked::Array(_) => match i.unpack() {
33
+ Unpacked::Nullish(_) => todo!(),
34
+ Unpacked::Bool(_) => todo!(),
35
+ Unpacked::Number(_) => todo!(),
36
+ Unpacked::String16(_) => todo!(),
37
+ Unpacked::BigInt(_) => todo!(),
38
+ Unpacked::Array(_) => todo!(),
39
+ Unpacked::Object(_) => todo!(),
40
+ Unpacked::Function(_) => todo!(),
41
+ },
42
+ Unpacked::Object(_) => todo!(),
43
+ Unpacked::Function(_) => todo!(),
44
+ }
45
+ }
46
+ }
47
+
48
+ impl<T: Any> AnyExtension for T {}
49
+
50
+ #[cfg(test)]
51
+ mod test {
52
+ mod to_string {
53
+ use crate::{
54
+ extension::AnyExtension, interface::{Complex, Extension}, naive::{Any, Array, Object}, nullish::Nullish::*, simple::Simple
55
+ };
56
+
57
+ #[test]
58
+ fn test_string() {
59
+ let s = Any::string("Hello world!");
60
+ let xs: Any = s.clone().to_unknown();
61
+ let sxs = xs.to_string();
62
+ assert_eq!(s, sxs);
63
+ }
64
+
65
+ #[test]
66
+ fn test_nullish() {
67
+ {
68
+ let x: Any = Simple::Nullish(Null).to_unknown();
69
+ assert_eq!(Any::string("null"), x.to_string());
70
+ }
71
+ {
72
+ let x: Any = Simple::Nullish(Undefined).to_unknown();
73
+ assert_eq!(Any::string("undefined"), x.to_string());
74
+ }
75
+ }
76
+
77
+ #[test]
78
+ fn test_boolean() {
79
+ {
80
+ let x: Any = Simple::Boolean(true).to_unknown();
81
+ assert_eq!(Any::string("true"), x.to_string());
82
+ }
83
+ {
84
+ let x: Any = Simple::Boolean(false).to_unknown();
85
+ assert_eq!(Any::string("false"), x.to_string());
86
+ }
87
+ }
88
+
89
+ #[test]
90
+ fn test_object() {
91
+ let x: Any = [].to_object_unknown();
92
+ assert_eq!(Any::string("[object Object"), x.to_string());
93
+ }
94
+
95
+ #[test]
96
+ fn test_array() {
97
+ let x: Any = [].to_array_unknown();
98
+ assert_eq!(Any::string(""), x.to_string());
99
+ }
100
+ }
101
+
102
+ mod own_property {
103
+ use crate::{extension::AnyExtension, interface::Complex, naive::Any, nullish::Nullish::*, simple::Simple};
104
+
105
+ #[test]
106
+ #[should_panic]
107
+ fn test_own_property_null() {
108
+ let x: Any = Simple::Nullish(Null).to_unknown();
109
+ x.own_property(Any::string("hello").to_unknown());
110
+ }
111
+
112
+ #[test]
113
+ fn test_own_property_bool() {
114
+ let x: Any = Simple::Boolean(true).to_unknown();
115
+ let undefined: Any = Simple::Nullish(Undefined).to_unknown();
116
+ assert_eq!(undefined, x.own_property(Any::string("hello").to_unknown()));
117
+ }
118
+ }
119
+ }