functionalscript 0.6.6 → 0.6.8

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.
package/README.md CHANGED
@@ -21,6 +21,31 @@ Learn more about
21
21
 
22
22
  This repository is a [monorepo](https://en.wikipedia.org/wiki/Monorepo) and distributted under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.en.html#license-text). Let us know if you need another license by sending an [email](mailto:sergey.oss@proton.me).
23
23
 
24
+ ## Getting Started
25
+
26
+ Install FunctionalScript via npm:
27
+
28
+ ```bash
29
+ npm install functionalscript
30
+ ```
31
+
32
+ The FunctionalScript compiler (`fsc`) currently supports:
33
+
34
+ * `import` statements
35
+ * `const` declarations
36
+
37
+ It does **not** yet support functions or complex expressions.
38
+
39
+ Example usage with `fsc`:
40
+
41
+ ```bash
42
+ npx fsc example.f.js output.json
43
+ # or
44
+ npx fsc example.f.js output.f.js
45
+ ```
46
+
47
+ FunctionalScript code can be compiled directly into either JSON or JavaScript without imports.
48
+
24
49
  ## Vision
25
50
 
26
51
  We aim to create a safe, cross-platform programming language that can work in any JS platform without any build step. There are thousands of programming languages, and we don't want to create another one that others must learn. Instead, we take the opposite approach: we remove everything that makes the most popular and cross-platform language unsafe, insecure, or less portable.
package/djs/ast/test.f.js CHANGED
@@ -1,39 +1,39 @@
1
1
  import * as list from "../../types/object/module.f.js";
2
2
  const { sort } = list;
3
3
  import * as shared from "./module.f.js";
4
- import { stringify } from "../serializer/module.f.js";
4
+ import { stringifyAsTree } from "../serializer/module.f.js";
5
5
  export default {
6
6
  test: () => {
7
7
  const djs = shared.run([1])([]);
8
- const result = stringify(sort)(djs);
8
+ const result = stringifyAsTree(sort)(djs);
9
9
  if (result !== '1') {
10
10
  throw result;
11
11
  }
12
12
  },
13
13
  testCref: () => {
14
14
  const djs = shared.run([1, 2, 3, 4, 5, ['cref', 3]])([11, 12, 13, 14, 15]);
15
- const result = stringify(sort)(djs);
15
+ const result = stringifyAsTree(sort)(djs);
16
16
  if (result !== '4') {
17
17
  throw result;
18
18
  }
19
19
  },
20
20
  testAref: () => {
21
21
  const djs = shared.run([1, 2, 3, 4, 5, ['aref', 3]])([11, 12, 13, 14, 15]);
22
- const result = stringify(sort)(djs);
22
+ const result = stringifyAsTree(sort)(djs);
23
23
  if (result !== '14') {
24
24
  throw result;
25
25
  }
26
26
  },
27
27
  testArray: () => {
28
28
  const djs = shared.run([1, 2, 3, 4, 5, ['array', [['aref', 3], ['cref', 3]]]])([11, 12, 13, 14, 15]);
29
- const result = stringify(sort)(djs);
29
+ const result = stringifyAsTree(sort)(djs);
30
30
  if (result !== '[14,4]') {
31
31
  throw result;
32
32
  }
33
33
  },
34
34
  testObj: () => {
35
35
  const djs = shared.run([1, 2, 3, 4, 5, { "key": { "key2": ['array', [['aref', 3], ['cref', 3]]] } }])([11, 12, 13, 14, 15]);
36
- const result = stringify(sort)(djs);
36
+ const result = stringifyAsTree(sort)(djs);
37
37
  if (result !== '{"key":{"key2":[14,4]}}') {
38
38
  throw result;
39
39
  }
package/djs/module.f.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { transpile } from "./transpiler/module.f.js";
2
- import { stringify } from "./serializer/module.f.js";
2
+ import { stringify, stringifyAsTree } from "./serializer/module.f.js";
3
3
  import { sort } from "../types/object/module.f.js";
4
- const stringifyUnknown = stringify(sort);
5
4
  export const compile = ({ console: { error }, fs, process: { argv } }) => {
6
5
  const args = argv.slice(2);
7
6
  if (args.length < 2) {
@@ -13,7 +12,12 @@ export const compile = ({ console: { error }, fs, process: { argv } }) => {
13
12
  const result = transpile(fs)(inputFileName);
14
13
  switch (result[0]) {
15
14
  case 'ok': {
16
- const output = stringifyUnknown(result[1]);
15
+ if (outputFileName.endsWith('.json')) {
16
+ const output = stringifyAsTree(sort)(result[1]);
17
+ fs.writeFileSync(outputFileName, output);
18
+ break;
19
+ }
20
+ const output = stringify(sort)(result[1]);
17
21
  fs.writeFileSync(outputFileName, output);
18
22
  break;
19
23
  }
@@ -16,7 +16,7 @@ const parseInitialOp = token => state => {
16
16
  }
17
17
  }
18
18
  }
19
- return { state: 'error', message: 'unexpected token' };
19
+ return foldOp(token)({ ...state, state: 'exportValue', valueState: '', top: null, stack: null });
20
20
  };
21
21
  const parseNewLineRequiredOp = token => state => {
22
22
  switch (token.kind) {
@@ -2,6 +2,7 @@ declare const _default: {
2
2
  valid: (() => void)[];
3
3
  invalid: (() => void)[];
4
4
  validWhiteSpaces: (() => void)[];
5
+ validJson: (() => void)[];
5
6
  invalidModule: (() => void)[];
6
7
  validWithConst: (() => void)[];
7
8
  invalidWithConst: (() => void)[];
@@ -3,9 +3,9 @@ import * as tokenizer from "../tokenizer/module.f.js";
3
3
  import { toArray } from "../../types/list/module.f.js";
4
4
  import { sort } from "../../types/object/module.f.js";
5
5
  import * as encoding from "../../text/utf16/module.f.js";
6
- import { stringify } from "../serializer/module.f.js";
6
+ import { stringifyAsTree } from "../serializer/module.f.js";
7
7
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)));
8
- const stringifyDjsModule = stringify(sort);
8
+ const stringifyDjsModule = stringifyAsTree(sort);
9
9
  export default {
10
10
  valid: [
11
11
  () => {
@@ -484,24 +484,60 @@ export default {
484
484
  }
485
485
  },
486
486
  ],
487
- invalidModule: [
487
+ validJson: [
488
488
  () => {
489
489
  const tokenList = tokenizeString('null');
490
490
  const obj = parser.parseFromTokens(tokenList);
491
- if (obj[0] !== 'error') {
491
+ if (obj[0] !== 'ok') {
492
492
  throw obj;
493
493
  }
494
- if (obj[1] !== 'unexpected token') {
494
+ const result = stringifyDjsModule(obj[1]);
495
+ if (result !== '[[],[null]]') {
496
+ throw result;
497
+ }
498
+ },
499
+ () => {
500
+ const tokenList = tokenizeString('1');
501
+ const obj = parser.parseFromTokens(tokenList);
502
+ if (obj[0] !== 'ok') {
495
503
  throw obj;
496
504
  }
505
+ const result = stringifyDjsModule(obj[1]);
506
+ if (result !== '[[],[1]]') {
507
+ throw result;
508
+ }
497
509
  },
510
+ () => {
511
+ const tokenList = tokenizeString('[]');
512
+ const obj = parser.parseFromTokens(tokenList);
513
+ if (obj[0] !== 'ok') {
514
+ throw obj;
515
+ }
516
+ const result = stringifyDjsModule(obj[1]);
517
+ if (result !== '[[],[["array",[]]]]') {
518
+ throw result;
519
+ }
520
+ },
521
+ () => {
522
+ const tokenList = tokenizeString('{"valid":"json"}');
523
+ const obj = parser.parseFromTokens(tokenList);
524
+ if (obj[0] !== 'ok') {
525
+ throw obj;
526
+ }
527
+ const result = stringifyDjsModule(obj[1]);
528
+ if (result !== '[[],[{"valid":"json"}]]') {
529
+ throw result;
530
+ }
531
+ }
532
+ ],
533
+ invalidModule: [
498
534
  () => {
499
535
  const tokenList = tokenizeString('module=null');
500
536
  const obj = parser.parseFromTokens(tokenList);
501
537
  if (obj[0] !== 'error') {
502
538
  throw obj;
503
539
  }
504
- if (obj[1] !== 'unexpected token') {
540
+ if (obj[1] !== 'const not found') {
505
541
  throw obj;
506
542
  }
507
543
  },
@@ -1,13 +1,14 @@
1
- import * as list from '../../types/list/module.f.ts';
1
+ import type * as djs from '../module.f.ts';
2
2
  import type * as O from '../../types/object/module.f.ts';
3
- import type { Unknown } from '../module.f.ts';
4
- type Entry = O.Entry<Unknown>;
5
- type Entries = list.List<Entry>;
3
+ import { type List } from '../../types/list/module.f.ts';
4
+ export declare const undefinedSerialize: string[];
5
+ type RefCounter = [number, number, boolean];
6
+ type Entry = O.Entry<djs.Unknown>;
7
+ type Entries = List<Entry>;
6
8
  type MapEntries = (entries: Entries) => Entries;
7
- export declare const serialize: (mapEntries: MapEntries) => (value: Unknown) => list.List<string>;
8
- /**
9
- * The standard `JSON.stringify` rules determined by
10
- * https://262.ecma-international.org/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
11
- */
12
- export declare const stringify: (mapEntries: MapEntries) => (value: Unknown) => string;
9
+ type Refs = Map<djs.Unknown, RefCounter>;
10
+ export declare const serializeWithoutConst: (mapEntries: MapEntries) => (value: djs.Unknown) => List<string>;
11
+ export declare const stringify: (sort: MapEntries) => (djs: djs.Unknown) => string;
12
+ export declare const stringifyAsTree: (mapEntries: MapEntries) => (value: djs.Unknown) => string;
13
+ export declare const countRefs: (djs: djs.Unknown) => Refs;
13
14
  export {};
@@ -1,17 +1,54 @@
1
- import * as list from "../../types/list/module.f.js";
2
- const { flat, map } = list;
1
+ import { fold } from "../../types/list/module.f.js";
3
2
  import * as string from "../../types/string/module.f.js";
4
3
  const { concat } = string;
4
+ import { flat, flatMap, map, concat as listConcat } from "../../types/list/module.f.js";
5
+ const { entries } = Object;
5
6
  import * as f from "../../types/function/module.f.js";
6
7
  const { compose, fn } = f;
7
- const { entries } = Object;
8
- import * as bi from "../../types/bigint/module.f.js";
9
- const { serialize: bigintSerialize } = bi;
10
- import * as j from "../../json/serializer/module.f.js";
11
- const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = j;
8
+ import { serialize as bigintSerialize } from "../../types/bigint/module.f.js";
9
+ import * as serializer from "../../json/serializer/module.f.js";
10
+ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = serializer;
12
11
  const colon = [':'];
13
- const undefinedSerialize = ['undefined'];
14
- export const serialize = sort => {
12
+ export const undefinedSerialize = ['undefined'];
13
+ const getConstantsOp = djs => state => {
14
+ switch (typeof djs) {
15
+ case 'boolean': {
16
+ return state;
17
+ }
18
+ case 'number':
19
+ case 'string':
20
+ case 'bigint': {
21
+ return getConstantSelf(djs)(state);
22
+ }
23
+ default: {
24
+ if (djs === null) {
25
+ return state;
26
+ }
27
+ if (djs === undefined) {
28
+ return state;
29
+ }
30
+ if (djs instanceof Array) {
31
+ return getConstantSelf(djs)(fold(getConstantsOp)(state)(djs));
32
+ }
33
+ return getConstantSelf(djs)(fold(getConstantsOp)(state)(map(entryValue)(entries(djs))));
34
+ }
35
+ }
36
+ };
37
+ const getConstantSelf = djs => state => {
38
+ const refs = state.refs;
39
+ const refCounter = refs.get(djs);
40
+ if (refCounter !== undefined && refCounter[1] > 1 && !refCounter[2]) {
41
+ refCounter[2] = true;
42
+ refs.set(djs, refCounter);
43
+ return { refs, consts: { head: state.consts, tail: [djs] } };
44
+ }
45
+ return state;
46
+ };
47
+ const getConstants = djs => refs => {
48
+ return getConstantsOp(djs)(refs);
49
+ };
50
+ const entryValue = kv => kv[1];
51
+ export const serializeWithoutConst = sort => {
15
52
  const propertySerialize = ([k, v]) => flat([
16
53
  stringSerialize(k),
17
54
  colon,
@@ -54,8 +91,105 @@ export const serialize = sort => {
54
91
  const arraySerialize = compose(map(f))(arrayWrap);
55
92
  return f;
56
93
  };
57
- /**
58
- * The standard `JSON.stringify` rules determined by
59
- * https://262.ecma-international.org/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
60
- */
61
- export const stringify = sort => compose(serialize(sort))(concat);
94
+ const serializeWithConst = sort => refs => root => {
95
+ const propertySerialize = ([k, v]) => flat([
96
+ stringSerialize(k),
97
+ colon,
98
+ f(v)
99
+ ]);
100
+ const mapPropertySerialize = map(propertySerialize);
101
+ const objectSerialize = fn(entries)
102
+ .then(sort)
103
+ .then(mapPropertySerialize)
104
+ .then(objectWrap)
105
+ .result;
106
+ const f = value => {
107
+ if (value !== root) {
108
+ const refCounter = refs.get(value);
109
+ if (refCounter !== undefined && refCounter[1] > 1) {
110
+ return [`c${refCounter[0]}`];
111
+ }
112
+ }
113
+ switch (typeof value) {
114
+ case 'boolean': {
115
+ return boolSerialize(value);
116
+ }
117
+ case 'number': {
118
+ return numberSerialize(value);
119
+ }
120
+ case 'string': {
121
+ return stringSerialize(value);
122
+ }
123
+ case 'bigint': {
124
+ return [bigintSerialize(value)];
125
+ }
126
+ default: {
127
+ if (value === null) {
128
+ return nullSerialize;
129
+ }
130
+ if (value === undefined) {
131
+ return undefinedSerialize;
132
+ }
133
+ if (value instanceof Array) {
134
+ return arraySerialize(value);
135
+ }
136
+ return objectSerialize(value);
137
+ }
138
+ }
139
+ };
140
+ const arraySerialize = compose(map(f))(arrayWrap);
141
+ return f;
142
+ };
143
+ const countRefsOp = djs => refs => {
144
+ switch (typeof djs) {
145
+ case 'boolean':
146
+ case 'number': {
147
+ return refs;
148
+ }
149
+ case 'string':
150
+ case 'bigint': {
151
+ return addRef(djs)(refs);
152
+ }
153
+ default: {
154
+ switch (djs) {
155
+ case null:
156
+ case undefined: {
157
+ return refs;
158
+ }
159
+ }
160
+ if (djs instanceof Array) {
161
+ if (refs.has(djs))
162
+ return addRef(djs)(refs);
163
+ return addRef(djs)(fold(countRefsOp)(refs)(djs));
164
+ }
165
+ if (refs.has(djs))
166
+ return addRef(djs)(refs);
167
+ return addRef(djs)(fold(countRefsOp)(refs)(map(entryValue)(entries(djs))));
168
+ }
169
+ }
170
+ };
171
+ const addRef = djs => refs => {
172
+ const refCounter = refs.get(djs);
173
+ if (refCounter === undefined) {
174
+ return refs.set(djs, [refs.size, 1, false]);
175
+ }
176
+ return refs.set(djs, [refCounter[0], refCounter[1] + 1, false]);
177
+ };
178
+ export const stringify = sort => djs => {
179
+ const refs = countRefs(djs);
180
+ const consts = getConstants(djs)({ refs, consts: [] }).consts;
181
+ const constSerialize = entry => {
182
+ const refCounter = refs.get(entry);
183
+ if (refCounter === undefined) {
184
+ throw 'unexpected behaviour';
185
+ }
186
+ return flat([['const c'], numberSerialize(refCounter[0]), [' = '], serializeWithConst(sort)(refs)(entry)(entry), ['\n']]);
187
+ };
188
+ const constStrings = flatMap(constSerialize)(consts);
189
+ const rootStrings = listConcat(['export default '])(serializeWithConst(sort)(refs)(djs)(djs));
190
+ return concat(listConcat(constStrings)(rootStrings));
191
+ };
192
+ export const stringifyAsTree = sort => compose(serializeWithoutConst(sort))(concat);
193
+ export const countRefs = djs => {
194
+ return countRefsOp(djs)(new Map());
195
+ };
@@ -1,5 +1,18 @@
1
1
  declare const _default: {
2
2
  stringify: ({
3
+ testPrimitives: () => void;
4
+ testArray: () => void;
5
+ testObj: () => void;
6
+ testSort?: never;
7
+ testIdentity?: never;
8
+ } | {
9
+ testSort: () => void;
10
+ testIdentity: () => void;
11
+ testPrimitives?: never;
12
+ testArray?: never;
13
+ testObj?: never;
14
+ })[];
15
+ stringifyAsTree: ({
3
16
  sort: () => void;
4
17
  identity: () => void;
5
18
  stringify?: never;
@@ -1,21 +1,96 @@
1
- import * as json from "../../json/module.f.js";
1
+ import { countRefs, stringify, stringifyAsTree } from "./module.f.js";
2
2
  import * as list from "../../types/object/module.f.js";
3
3
  const { sort } = list;
4
- import * as f from "../../types/function/module.f.js";
5
- const { identity } = f;
6
- import * as serializer from "./module.f.js";
4
+ import { identity } from "../../types/function/module.f.js";
5
+ import * as json from "../../json/module.f.js";
7
6
  export default {
8
7
  stringify: [
8
+ {
9
+ testPrimitives: () => {
10
+ const djs = [1, 2, 2, 2, true, false, undefined, null, 3n, "str"];
11
+ const refs = countRefs(djs);
12
+ if (refs.size !== 3) {
13
+ throw refs.size;
14
+ }
15
+ const refsBigInt = stringifyAsTree(sort)(refs.get(3n));
16
+ if (refsBigInt !== '[0,1,false]') {
17
+ throw refsBigInt;
18
+ }
19
+ const refsString = stringifyAsTree(sort)(refs.get("str"));
20
+ if (refsString !== '[1,1,false]') {
21
+ throw refsString;
22
+ }
23
+ const refsRoot = stringifyAsTree(sort)(refs.get(djs));
24
+ if (refsRoot !== '[2,1,false]') {
25
+ throw refsRoot;
26
+ }
27
+ if (refs.get(null) !== undefined) {
28
+ throw refs.get(null);
29
+ }
30
+ },
31
+ testArray: () => {
32
+ const array = [null];
33
+ const djs = [array, array, array];
34
+ const refs = countRefs(djs);
35
+ if (refs.size !== 2) {
36
+ throw refs.size;
37
+ }
38
+ const refsArray = stringifyAsTree(sort)(refs.get(array));
39
+ if (refsArray !== '[0,3,false]') {
40
+ throw refsArray;
41
+ }
42
+ const refsRoot = stringifyAsTree(sort)(refs.get(djs));
43
+ if (refsRoot !== '[1,1,false]') {
44
+ throw refsRoot;
45
+ }
46
+ },
47
+ testObj: () => {
48
+ const obj = { "a": 1, "b": 2 };
49
+ const djs = [obj, obj, 1];
50
+ const refs = countRefs(djs);
51
+ if (refs.size !== 2) {
52
+ throw refs.size;
53
+ }
54
+ const refsObj = stringifyAsTree(sort)(refs.get(obj));
55
+ if (refsObj !== '[0,2,false]') {
56
+ throw refsObj;
57
+ }
58
+ const refsRoot = stringifyAsTree(sort)(refs.get(djs));
59
+ if (refsRoot !== '[1,1,false]') {
60
+ throw refsRoot;
61
+ }
62
+ },
63
+ },
64
+ {
65
+ testSort: () => {
66
+ const obj = { "a": 1, "c": 2n, "b": [undefined, null, true, false] };
67
+ const djs = [obj, obj, 1];
68
+ const res = stringify(sort)(djs);
69
+ if (res !== 'const c2 = {"a":1,"b":[undefined,null,true,false],"c":2n}\nexport default [c2,c2,1]') {
70
+ throw res;
71
+ }
72
+ },
73
+ testIdentity: () => {
74
+ const obj = { "a": 1, "c": 2n, "b": [undefined, null, true, false] };
75
+ const djs = [obj, obj, 1];
76
+ const res = stringify(identity)(djs);
77
+ if (res !== 'const c2 = {"a":1,"c":2n,"b":[undefined,null,true,false]}\nexport default [c2,c2,1]') {
78
+ throw res;
79
+ }
80
+ },
81
+ }
82
+ ],
83
+ stringifyAsTree: [
9
84
  {
10
85
  sort: () => {
11
86
  const r = json.setProperty("Hello")(['a'])({});
12
- const x = serializer.stringify(sort)(r);
87
+ const x = stringifyAsTree(sort)(r);
13
88
  if (x !== '{"a":"Hello"}') {
14
89
  throw x;
15
90
  }
16
91
  },
17
92
  identity: () => {
18
- const x = serializer.stringify(identity)(json.setProperty("Hello")(['a'])({}));
93
+ const x = stringifyAsTree(identity)(json.setProperty("Hello")(['a'])({}));
19
94
  if (x !== '{"a":"Hello"}') {
20
95
  throw x;
21
96
  }
@@ -23,13 +98,13 @@ export default {
23
98
  },
24
99
  {
25
100
  sort: () => {
26
- const x = serializer.stringify(sort)(json.setProperty("Hello")(['a'])({ c: [], b: 12 }));
101
+ const x = stringifyAsTree(sort)(json.setProperty("Hello")(['a'])({ c: [], b: 12 }));
27
102
  if (x !== '{"a":"Hello","b":12,"c":[]}') {
28
103
  throw x;
29
104
  }
30
105
  },
31
106
  identity: () => {
32
- const x = serializer.stringify(identity)(json.setProperty("Hello")(['a'])({ c: [], b: 12 }));
107
+ const x = stringifyAsTree(identity)(json.setProperty("Hello")(['a'])({ c: [], b: 12 }));
33
108
  if (x !== '{"c":[],"b":12,"a":"Hello"}') {
34
109
  throw x;
35
110
  }
@@ -39,7 +114,7 @@ export default {
39
114
  sort: () => {
40
115
  const _0 = { a: { y: [24] }, c: [], b: 12 };
41
116
  const _1 = json.setProperty("Hello")(['a', 'x'])(_0);
42
- const _2 = serializer.stringify(sort)(_1);
117
+ const _2 = stringifyAsTree(sort)(_1);
43
118
  if (_2 !== '{"a":{"x":"Hello","y":[24]},"b":12,"c":[]}') {
44
119
  throw _2;
45
120
  }
@@ -47,7 +122,7 @@ export default {
47
122
  identity: () => {
48
123
  const _0 = { a: { y: [24] }, c: [], b: 12 };
49
124
  const _1 = json.setProperty("Hello")(['a', 'x'])(_0);
50
- const _2 = serializer.stringify(identity)(_1);
125
+ const _2 = stringifyAsTree(identity)(_1);
51
126
  if (_2 !== '{"a":{"y":[24],"x":"Hello"},"c":[],"b":12}') {
52
127
  throw _2;
53
128
  }
@@ -56,7 +131,7 @@ export default {
56
131
  {
57
132
  stringify: () => {
58
133
  const bi = 1234567890n;
59
- const result = serializer.stringify(sort)(bi);
134
+ const result = stringifyAsTree(sort)(bi);
60
135
  if (result !== '1234567890n') {
61
136
  throw result;
62
137
  }
@@ -65,7 +140,7 @@ export default {
65
140
  {
66
141
  stringify: () => {
67
142
  const arr = [0n, 1, 2n];
68
- const result = serializer.stringify(sort)(arr);
143
+ const result = stringifyAsTree(sort)(arr);
69
144
  if (result !== '[0n,1,2n]') {
70
145
  throw result;
71
146
  }
@@ -74,7 +149,7 @@ export default {
74
149
  {
75
150
  stringify: () => {
76
151
  const obj = { "a": 0n, "b": 1, "c": 2n };
77
- const result = serializer.stringify(sort)(obj);
152
+ const result = stringifyAsTree(sort)(obj);
78
153
  if (result !== '{"a":0n,"b":1,"c":2n}') {
79
154
  throw result;
80
155
  }
@@ -1,4 +1,4 @@
1
1
  import c from "./m.f.js";
2
2
  const a = 1;
3
3
  const b = 2;
4
- export default [a, b, c];
4
+ export default [a, a, b, c, c];
@@ -6,7 +6,7 @@ import * as o from "../../types/object/module.f.js";
6
6
  const { sort } = o;
7
7
  import * as encoding from "../../text/utf16/module.f.js";
8
8
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)));
9
- const stringify = serializer.stringify(sort);
9
+ const stringify = serializer.stringifyAsTree(sort);
10
10
  export default {
11
11
  djs: [
12
12
  () => {
@@ -1,7 +1,7 @@
1
1
  import { sort } from "../../types/object/module.f.js";
2
2
  import { setReplace } from "../../types/ordered_map/module.f.js";
3
3
  import { transpile } from "./module.f.js";
4
- import { stringify } from "../serializer/module.f.js";
4
+ import { stringifyAsTree } from "../serializer/module.f.js";
5
5
  import { createVirtualIo } from "../../io/virtual/module.f.js";
6
6
  const virtualFs = map => {
7
7
  return createVirtualIo(map).fs;
@@ -14,7 +14,7 @@ export default {
14
14
  if (result[0] === 'error') {
15
15
  throw result[1];
16
16
  }
17
- const s = stringify(sort)(result[1]);
17
+ const s = stringifyAsTree(sort)(result[1]);
18
18
  if (s !== '1') {
19
19
  throw s;
20
20
  }
@@ -27,7 +27,7 @@ export default {
27
27
  if (result[0] === 'error') {
28
28
  throw result[1];
29
29
  }
30
- const s = stringify(sort)(result[1]);
30
+ const s = stringifyAsTree(sort)(result[1]);
31
31
  if (s !== '2') {
32
32
  throw s;
33
33
  }
@@ -42,7 +42,7 @@ export default {
42
42
  if (result[0] === 'error') {
43
43
  throw result[1];
44
44
  }
45
- const s = stringify(sort)(result[1]);
45
+ const s = stringifyAsTree(sort)(result[1]);
46
46
  if (s !== '[[0,2],[1,2],[0,2]]') {
47
47
  throw s;
48
48
  }
@@ -6,7 +6,7 @@ import * as o from "../../types/object/module.f.js";
6
6
  const { sort } = o;
7
7
  import * as encoding from "../../text/utf16/module.f.js";
8
8
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)));
9
- const stringify = serializer.stringify(sort);
9
+ const stringify = serializer.stringifyAsTree(sort);
10
10
  export default {
11
11
  djs: [
12
12
  () => {
@@ -6,7 +6,7 @@ import * as o from "../../types/object/module.f.js";
6
6
  const { sort } = o;
7
7
  import * as encoding from "../../text/utf16/module.f.js";
8
8
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)));
9
- const stringify = serializer.stringify(sort);
9
+ const stringify = serializer.stringifyAsTree(sort);
10
10
  export default {
11
11
  json: [
12
12
  () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.js",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
48
48
  "devDependencies": {
49
- "@types/node": "^22.14.1",
49
+ "@types/node": "^22.15.17",
50
50
  "typescript": "^5.8.3"
51
51
  }
52
52
  }