functionalscript 0.8.2 → 0.9.2

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 (91) hide show
  1. package/README.md +5 -5
  2. package/bnf/data/module.f.d.ts +10 -1
  3. package/bnf/data/module.f.js +58 -19
  4. package/bnf/data/test.f.d.ts +2 -0
  5. package/bnf/data/test.f.js +244 -3
  6. package/bnf/module.f.d.ts +6 -2
  7. package/bnf/module.f.js +8 -9
  8. package/cas/module.f.d.ts +18 -0
  9. package/cas/module.f.js +95 -0
  10. package/cas/test.f.d.ts +2 -0
  11. package/cas/test.f.js +1 -0
  12. package/ci/module.f.d.ts +3 -2
  13. package/ci/module.f.js +11 -9
  14. package/ci/module.js +3 -3
  15. package/crypto/sha2/module.f.js +0 -1
  16. package/dev/module.f.d.ts +1 -1
  17. package/dev/module.f.js +14 -6
  18. package/dev/version/module.f.d.ts +2 -11
  19. package/dev/version/module.f.js +17 -14
  20. package/dev/version/test.f.d.ts +3 -1
  21. package/dev/version/test.f.js +26 -10
  22. package/djs/module.f.d.ts +1 -1
  23. package/djs/module.f.js +4 -4
  24. package/djs/parser-new/module.f.d.ts +3 -0
  25. package/djs/parser-new/module.f.js +150 -0
  26. package/djs/parser-new/test.f.d.ts +5 -0
  27. package/djs/parser-new/test.f.js +201 -0
  28. package/djs/serializer/module.f.js +6 -6
  29. package/djs/transpiler/module.f.js +3 -2
  30. package/djs/transpiler/test.f.js +12 -11
  31. package/fjs/module.f.d.ts +2 -0
  32. package/fjs/module.f.js +25 -0
  33. package/{dev/tf → fjs}/module.js +1 -1
  34. package/fsc/module.f.js +1 -1
  35. package/io/module.d.ts +4 -0
  36. package/io/module.f.d.ts +14 -13
  37. package/io/module.f.js +21 -0
  38. package/io/module.js +7 -1
  39. package/io/virtual/module.f.d.ts +1 -1
  40. package/io/virtual/module.f.js +3 -3
  41. package/js/tokenizer/module.f.d.ts +1 -1
  42. package/js/tokenizer/module.f.js +0 -1
  43. package/json/module.f.js +3 -3
  44. package/nanvm-lib/tests/test.f.d.ts +1 -1
  45. package/nanvm-lib/tests/test.f.js +114 -104
  46. package/package.json +6 -7
  47. package/path/module.f.d.ts +1 -0
  48. package/path/module.f.js +6 -3
  49. package/text/utf16/module.f.js +1 -1
  50. package/types/bit_vec/module.f.d.ts +1 -0
  51. package/types/bit_vec/module.f.js +1 -0
  52. package/types/btree/find/module.f.d.ts +7 -8
  53. package/types/btree/set/module.f.js +21 -0
  54. package/types/cbase32/module.f.d.ts +6 -0
  55. package/types/cbase32/module.f.js +71 -0
  56. package/types/cbase32/test.f.d.ts +7 -0
  57. package/types/cbase32/test.f.js +74 -0
  58. package/types/effect/mock/module.f.d.ts +5 -0
  59. package/types/effect/mock/module.f.js +14 -0
  60. package/types/effect/module.d.ts +2 -0
  61. package/types/effect/module.f.d.ts +23 -0
  62. package/types/effect/module.f.js +14 -0
  63. package/types/effect/module.js +11 -0
  64. package/types/effect/node/module.f.d.ts +52 -0
  65. package/types/effect/node/module.f.js +7 -0
  66. package/types/effect/node/test.f.d.ts +27 -0
  67. package/types/effect/node/test.f.js +259 -0
  68. package/types/effect/node/virtual/module.f.d.ts +13 -0
  69. package/types/effect/node/virtual/module.f.js +98 -0
  70. package/types/function/module.f.d.ts +1 -1
  71. package/types/function/module.f.js +1 -1
  72. package/types/function/test.f.js +1 -1
  73. package/types/list/module.f.d.ts +1 -0
  74. package/types/list/module.f.js +6 -6
  75. package/types/nullable/module.f.d.ts +2 -0
  76. package/types/nullable/module.f.js +1 -0
  77. package/types/nullable/test.f.d.ts +1 -1
  78. package/types/nullable/test.f.js +23 -11
  79. package/types/option/module.f.d.ts +9 -0
  80. package/types/option/module.f.js +6 -0
  81. package/types/uint8array/module.f.d.ts +11 -0
  82. package/types/uint8array/module.f.js +21 -0
  83. package/types/uint8array/test.f.d.ts +12 -0
  84. package/types/uint8array/test.f.js +58 -0
  85. package/website/module.d.ts +1 -0
  86. package/website/module.f.d.ts +3 -0
  87. package/website/module.f.js +9 -0
  88. package/website/module.js +3 -0
  89. package/fsc/module.d.ts +0 -2
  90. package/fsc/module.js +0 -4
  91. /package/{dev/tf → fjs}/module.d.ts +0 -0
package/ci/module.f.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { utf8 } from "../text/module.f.js";
2
+ import { writeFile } from "../types/effect/node/module.f.js";
1
3
  const os = ['ubuntu', 'macos', 'windows'];
2
4
  const architecture = ['intel', 'arm'];
3
5
  // https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories
@@ -73,7 +75,7 @@ const toSteps = (m) => {
73
75
  ...(rust ? [{
74
76
  // wasm32-wasip1-threads doesn't work on Rust 1.91 in the release mode.
75
77
  // See https://github.com/sergey-shandar/wasmtime-crash
76
- uses: 'dtolnay/rust-toolchain@1.90.0',
78
+ uses: 'dtolnay/rust-toolchain@1.93.0',
77
79
  with: {
78
80
  components: 'rustfmt,clippy',
79
81
  targets
@@ -128,8 +130,8 @@ const steps = (v) => (a) => {
128
130
  // publishing
129
131
  test({ run: 'npm pack' }),
130
132
  test({ run: `npm install -g ${findTgz(v)}` }),
131
- test({ run: 'fsc issues/demo/data/tree.json _tree.f.js' }),
132
- test({ run: 'fst' }),
133
+ test({ run: 'fjs compile issues/demo/data/tree.json _tree.f.js' }),
134
+ test({ run: 'fjs t' }),
133
135
  test({ run: 'npm uninstall functionalscript -g' }),
134
136
  ]),
135
137
  // Deno
@@ -137,14 +139,15 @@ const steps = (v) => (a) => {
137
139
  installDeno(v)(a),
138
140
  test({ run: 'deno install' }),
139
141
  test({ run: 'deno task test' }),
140
- test({ run: 'deno task fst' }),
142
+ test({ run: 'deno task fjs compile issues/demo/data/tree.json _tree.f.js' }),
143
+ test({ run: 'deno task fjs t' }),
141
144
  test({ run: 'deno publish --dry-run' }),
142
145
  ]),
143
146
  // Bun
144
147
  ...clean([
145
148
  installBun(v)(a),
146
149
  test({ run: 'bun test --timeout 20000' }),
147
- test({ run: 'bun ./dev/tf/module.ts' }),
150
+ test({ run: 'bun ./fjs/module.ts t' }),
148
151
  ]),
149
152
  ];
150
153
  return toSteps(result);
@@ -163,7 +166,6 @@ const gha = {
163
166
  on: { pull_request: {} },
164
167
  jobs,
165
168
  };
166
- export default async (io) => {
167
- io.fs.writeFileSync('.github/workflows/ci.yml', JSON.stringify(gha, null, ' '));
168
- return 0;
169
- };
169
+ export const effect = writeFile('.github/workflows/ci.yml', utf8(JSON.stringify(gha, null, ' ')))
170
+ .map(() => 0);
171
+ export default () => effect;
package/ci/module.js CHANGED
@@ -1,3 +1,3 @@
1
- import node from "../io/module.js";
2
- import x from "./module.f.js";
3
- await node(x);
1
+ import { nodeRun } from "../io/module.js";
2
+ import run from "./module.f.js";
3
+ await nodeRun(run);
@@ -1,6 +1,5 @@
1
1
  import { mask } from "../../types/bigint/module.f.js";
2
2
  import { vec, length, empty, msb } from "../../types/bit_vec/module.f.js";
3
- import { flip } from "../../types/function/module.f.js";
4
3
  import { fold } from "../../types/list/module.f.js";
5
4
  const { concat, popFront, front } = msb;
6
5
  const lastOne = vec(1n)(1n);
package/dev/module.f.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Io } from '../io/module.f.ts';
1
+ import { type Io } from '../io/module.f.ts';
2
2
  export declare const todo: () => never;
3
3
  export type Module = {
4
4
  readonly default?: unknown;
package/dev/module.f.js CHANGED
@@ -1,4 +1,9 @@
1
+ import { fromIo } from "../io/module.f.js";
1
2
  import { updateVersion } from "./version/module.f.js";
3
+ import { decodeUtf8, encodeUtf8 } from "../types/uint8array/module.f.js";
4
+ import { readFile } from "../types/effect/node/module.f.js";
5
+ import { utf8ToString } from "../text/module.f.js";
6
+ import { unwrap } from "../types/result/module.f.js";
2
7
  export const todo = () => { throw 'not implemented'; };
3
8
  const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
4
9
  export const env = ({ process: { env } }) => a => {
@@ -8,7 +13,7 @@ export const env = ({ process: { env } }) => a => {
8
13
  r.value;
9
14
  };
10
15
  export const allFiles = (io) => (s) => {
11
- const { fs: { promises: { readdir } }, process: { cwd } } = io;
16
+ const { fs: { promises: { readdir } } } = io;
12
17
  const load = async (p) => {
13
18
  let result = [];
14
19
  for (const i of await readdir(p, { withFileTypes: true })) {
@@ -46,18 +51,21 @@ export const loadModuleMap = async (io) => {
46
51
  }
47
52
  return Object.fromEntries(map.toSorted(cmp));
48
53
  };
54
+ const denoJson = './deno.json';
55
+ const index2 = updateVersion
56
+ .pipe(() => readFile(denoJson))
57
+ .map(v => JSON.parse(utf8ToString(unwrap(v))));
49
58
  export const index = async (io) => {
50
- updateVersion(io);
51
- const jj = './deno.json';
52
- const jsr_json = JSON.parse(await io.fs.promises.readFile(jj, 'utf8'));
59
+ const runner = fromIo(io);
60
+ const jsr_json = await runner(index2);
53
61
  const list = (await allFiles(io)('.')).filter(v => v.endsWith('/module.f.ts') || v.endsWith('/module.ts'));
54
- //console.log(list)
62
+ // console.log(list)
55
63
  const exportsA = list.map(v => [v, `./${v.substring(2)}`]);
56
64
  // console.log(exportsA)
57
65
  const exports = Object.fromEntries(exportsA);
58
66
  // console.log(exports)
59
67
  const json = JSON.stringify({ ...jsr_json, exports }, null, 2);
60
68
  // console.log(json)
61
- await io.fs.promises.writeFile(jj, json, 'utf8');
69
+ await io.fs.promises.writeFile(denoJson, encodeUtf8(json));
62
70
  return 0;
63
71
  };
@@ -1,11 +1,2 @@
1
- export type Buffer = object;
2
- type Fs<T> = {
3
- readonly readFileSync: (name: string, encoding: 'utf8') => string;
4
- readonly writeFileSync: (name: string, content: string) => T;
5
- };
6
- export type Node<T> = {
7
- readonly fs: Fs<T>;
8
- };
9
- export declare const getVersion: <T>(fs: Fs<T>) => string;
10
- export declare const updateVersion: <T>(node: Node<T>) => readonly [T, T];
11
- export {};
1
+ import { type NodeEffect } from "../../types/effect/node/module.f.ts";
2
+ export declare const updateVersion: NodeEffect<number>;
@@ -1,16 +1,19 @@
1
+ import { utf8, utf8ToString } from "../../text/module.f.js";
2
+ import { all } from "../../types/effect/module.f.js";
3
+ import { readFile, writeFile } from "../../types/effect/node/module.f.js";
4
+ import { unwrap } from "../../types/result/module.f.js";
1
5
  const { stringify, parse } = JSON;
2
- export const getVersion = fs => readJson(fs)('package').version;
3
6
  const jsonFile = (jsonFile) => `${jsonFile}.json`;
4
- const readJson = fs => name => parse(fs.readFileSync(jsonFile(name), 'utf8'));
5
- export const updateVersion = ({ fs }) => {
6
- const f = (name) => {
7
- return fs.writeFileSync(jsonFile(name), stringify({
8
- ...readJson(fs)(name),
9
- version: getVersion(fs)
10
- }, null, 2));
11
- };
12
- return [
13
- f('package'),
14
- f('deno')
15
- ];
16
- };
7
+ const readJson = (name) => readFile(jsonFile(name))
8
+ .map(v => parse(utf8ToString(unwrap(v))));
9
+ const writeVersion = (version) => (name) => readJson(name)
10
+ .pipe(json => writeFile(jsonFile(name), utf8(stringify({
11
+ ...json,
12
+ version,
13
+ }, null, 2))));
14
+ export const updateVersion = readJson('package')
15
+ .pipe(p => {
16
+ const w = writeVersion(p.version);
17
+ return all([w('package'), w('deno')]);
18
+ })
19
+ .map(() => 0);
@@ -1,2 +1,4 @@
1
- declare const _default: () => void;
1
+ declare const _default: {
2
+ new: () => void;
3
+ };
2
4
  export default _default;
@@ -1,4 +1,10 @@
1
- import * as _ from "./module.f.js";
1
+ import { utf8, utf8ToString } from "../../text/module.f.js";
2
+ import { isVec } from "../../types/bit_vec/module.f.js";
3
+ import { run } from "../../types/effect/mock/module.f.js";
4
+ import { all } from "../../types/effect/module.f.js";
5
+ import { writeFile } from "../../types/effect/node/module.f.js";
6
+ import { emptyState, virtual } from "../../types/effect/node/virtual/module.f.js";
7
+ import { updateVersion } from "./module.f.js";
2
8
  const version = '0.3.0';
3
9
  const x = {
4
10
  'package.json': {
@@ -73,15 +79,25 @@ const e = '{\n' +
73
79
  ' "typescript": "^4.7.4"\n' +
74
80
  ' }\n' +
75
81
  '}';
76
- export default () => {
77
- const node = {
78
- fs: {
79
- readFileSync: n => JSON.stringify(x[n]),
80
- writeFileSync: (_, content) => content
82
+ export default {
83
+ new: () => {
84
+ const rv = run(virtual);
85
+ const w = (name) => {
86
+ const fn = `${name}.json`;
87
+ return writeFile(fn, utf8(JSON.stringify(x[fn])));
88
+ };
89
+ const [state] = rv(emptyState)(all([w('package'), w('deno')]));
90
+ const [newState, result] = rv(state)(updateVersion);
91
+ if (result !== 0) {
92
+ throw result;
93
+ }
94
+ const vec = newState.root['package.json'];
95
+ if (!isVec(vec)) {
96
+ throw vec;
97
+ }
98
+ const n = utf8ToString(vec);
99
+ if (n !== e) {
100
+ throw [n, e];
81
101
  }
82
- };
83
- const [n, d] = _.updateVersion(node);
84
- if (n !== e) {
85
- throw [n, e];
86
102
  }
87
103
  };
package/djs/module.f.d.ts CHANGED
@@ -6,4 +6,4 @@ export type Object = {
6
6
  export type Array = readonly Unknown[];
7
7
  export type Primitive = JsonPrimitive | bigint | undefined;
8
8
  export type Unknown = Primitive | Object | Array;
9
- export declare const compile: ({ console: { error }, fs, process: { argv } }: Io) => Promise<number>;
9
+ export declare const compile: ({ console: { error }, fs }: Io) => (args: readonly string[]) => Promise<number>;
package/djs/module.f.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { transpile } from "./transpiler/module.f.js";
2
2
  import { stringify, stringifyAsTree } from "./serializer/module.f.js";
3
3
  import { sort } from "../types/object/module.f.js";
4
- export const compile = ({ console: { error }, fs, process: { argv } }) => {
5
- const args = argv.slice(2);
4
+ import { encodeUtf8 } from "../types/uint8array/module.f.js";
5
+ export const compile = ({ console: { error }, fs }) => (args) => {
6
6
  if (args.length < 2) {
7
7
  error('Error: Requires 2 or more arguments');
8
8
  return Promise.resolve(1);
@@ -14,11 +14,11 @@ export const compile = ({ console: { error }, fs, process: { argv } }) => {
14
14
  case 'ok': {
15
15
  if (outputFileName.endsWith('.json')) {
16
16
  const output = stringifyAsTree(sort)(result[1]);
17
- fs.writeFileSync(outputFileName, output);
17
+ fs.writeFileSync(outputFileName, encodeUtf8(output));
18
18
  break;
19
19
  }
20
20
  const output = stringify(sort)(result[1]);
21
- fs.writeFileSync(outputFileName, output);
21
+ fs.writeFileSync(outputFileName, encodeUtf8(output));
22
22
  break;
23
23
  }
24
24
  case 'error': {
@@ -0,0 +1,3 @@
1
+ import { type Rule } from "../../bnf/module.f.ts";
2
+ export declare const parse: (input: string) => boolean;
3
+ export declare const jsGrammar: () => Rule;
@@ -0,0 +1,150 @@
1
+ import { descentParser } from "../../bnf/data/module.f.js";
2
+ import { eof, join0Plus, max, none, not, notSet, oneEncode, option, range, remove, repeat, repeat0Plus, repeat1Plus, set, unicodeRange } from "../../bnf/module.f.js";
3
+ import { todo } from "../../dev/module.f.js";
4
+ export const parse = (input) => {
5
+ const m = descentParser(jsGrammar());
6
+ return todo();
7
+ };
8
+ export const jsGrammar = () => {
9
+ const onenine = range('19');
10
+ const digit = range('09');
11
+ const string = [
12
+ '"',
13
+ repeat0Plus({
14
+ ...remove(range(` ${max}`), set('"\\')),
15
+ escape: [
16
+ '\\',
17
+ {
18
+ ...set('"\\/bfnrt'),
19
+ u: [
20
+ 'u',
21
+ ...repeat(4)({
22
+ digit,
23
+ AF: range('AF'),
24
+ af: range('af'),
25
+ })
26
+ ],
27
+ }
28
+ ],
29
+ }),
30
+ '"'
31
+ ];
32
+ const digits0 = repeat0Plus(digit);
33
+ const digits = [digit, digits0];
34
+ const number = [
35
+ {
36
+ 0: '0',
37
+ onenine: [onenine, digits0],
38
+ },
39
+ option({
40
+ bigint: 'n',
41
+ frac: [
42
+ option(['.', digits]),
43
+ option([set('Ee'), option(set('+-')), digits])
44
+ ]
45
+ })
46
+ ];
47
+ const ws = set(' \t');
48
+ const newLine = set('\n\r');
49
+ const idStart = {
50
+ smallLetter: range('az'),
51
+ bigLetter: range('AZ'),
52
+ lowLine: '_',
53
+ dollarSign: '$'
54
+ };
55
+ const idChar = {
56
+ ...idStart,
57
+ digit
58
+ };
59
+ const id = [idStart, repeat0Plus(idChar)];
60
+ const operator = {
61
+ '.': '.',
62
+ '=>': '=>',
63
+ '===': '===',
64
+ '==': '==',
65
+ '=': '=',
66
+ '!==': '!==',
67
+ '!=': '!=',
68
+ '!': '!',
69
+ '>>>=': '>>>=',
70
+ '>>>': '>>>',
71
+ '>>=': '>>=',
72
+ '>>': '>>',
73
+ '>=': '>=',
74
+ '>': '>',
75
+ '<<<<=': '<<<=',
76
+ '<<<': '<<<',
77
+ '<<=': '<<=',
78
+ '<<': '<<',
79
+ '<=': '<=',
80
+ '<': '<',
81
+ '+=': '+=',
82
+ '++': '++',
83
+ '+': '+',
84
+ '-=': '-=',
85
+ '--': '--',
86
+ '-': '-',
87
+ '**=': '**=',
88
+ '**': '**',
89
+ '*=': '*=',
90
+ '*': '*',
91
+ '/=': '/=',
92
+ '/': '/',
93
+ '%=': '%=',
94
+ '%': '%',
95
+ '&&=': '&&=',
96
+ '&&': '&&',
97
+ '&=': '&=',
98
+ '&': '&',
99
+ '||=': '||=',
100
+ '||': '||',
101
+ '|=': '|=',
102
+ '|': '|',
103
+ '^=': '^=',
104
+ '^': '^',
105
+ '~': '~',
106
+ '??=': '??=',
107
+ '??': '??',
108
+ '?.': '?.',
109
+ '?': '?',
110
+ '[': '[',
111
+ ']': ']',
112
+ '{': '{',
113
+ '}': '}',
114
+ '(': '(',
115
+ ')': ')',
116
+ ',': ',',
117
+ ':': ':'
118
+ };
119
+ const commentEnd = {
120
+ ...newLine,
121
+ eof
122
+ };
123
+ const comment = ['/', {
124
+ // TODO: investigate why `not(commentEnd)` instead of `remove(unicodeRange, newLine)` fail tests.
125
+ // TODO: should it be `repeat0Plus(not(commentEnd))` instead of `option(remove(unicodeRange, newLine))`.
126
+ oneline: ['/', option(remove(unicodeRange, newLine)), commentEnd],
127
+ multiline: [
128
+ '*',
129
+ repeat0Plus({
130
+ na: notSet('*'),
131
+ a: ['*', notSet('/')]
132
+ }),
133
+ '*/'
134
+ ]
135
+ }
136
+ ];
137
+ const endOfFile = oneEncode(eof);
138
+ const token = {
139
+ number,
140
+ string,
141
+ id,
142
+ comment,
143
+ operator,
144
+ ws,
145
+ newLine,
146
+ //endOfFile
147
+ };
148
+ const tokens = repeat0Plus(token);
149
+ return tokens;
150
+ };
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ isValid: (() => void)[];
3
+ parser: (() => void)[];
4
+ };
5
+ export default _default;
@@ -0,0 +1,201 @@
1
+ import { descentParser } from "../../bnf/data/module.f.js";
2
+ import { stringToCodePointList } from "../../text/utf16/module.f.js";
3
+ import { map, toArray } from "../../types/list/module.f.js";
4
+ import { jsGrammar } from "./module.f.js";
5
+ const mapCodePoint = (cp) => [cp, undefined];
6
+ const descentParserCpOnly = (m, name, cp) => {
7
+ const cpm = toArray(map(mapCodePoint)(cp));
8
+ return m(name, cpm);
9
+ };
10
+ export default {
11
+ isValid: [() => {
12
+ const m = descentParser(jsGrammar());
13
+ const expect = (s, expected) => {
14
+ const cp = toArray(stringToCodePointList(s));
15
+ const mr = descentParserCpOnly(m, '', cp);
16
+ const success = mr[1] && mr[2] === cp.length;
17
+ if (success !== expected) {
18
+ throw mr;
19
+ }
20
+ };
21
+ expect(' true ', true);
22
+ expect(' tr2ue ', true);
23
+ expect(' 2true ', true);
24
+ expect(' true" ', false);
25
+ expect(' "Hello" ', true);
26
+ expect(' "Hello ', false);
27
+ expect(' "Hello\\n\\r\\"" ', true);
28
+ expect(' 56.7e+5 ', true);
29
+ expect(' -56.7e+5 ', true);
30
+ expect(' h-56.7e+5 ', true);
31
+ expect(' -56.7e+5 3', true);
32
+ expect(' [] ', true);
33
+ expect(' {} ', true);
34
+ expect(' [[[]]] ', true);
35
+ expect(' [1] ', true);
36
+ expect(' [ 12, false, "a"] ', true);
37
+ expect(' [ 12, false2, "a"] ', true);
38
+ expect(' { "q": [ 12, false, [{"b" : "c"}], "a"] } ', true);
39
+ expect(' { "q": [ 12, false, [{}], "a"] } ', true);
40
+ expect(' { "q": [ 12, false, [}], "a"] } ', true);
41
+ expect(' [{ "q": [ 12, false, [{}], "a"] }] ', true);
42
+ expect(' [{ "q": [ 12, false, [}], "a"] }] ', true);
43
+ expect('. + ++ +=', true);
44
+ expect('//12\n', true);
45
+ expect('/*12*/', true);
46
+ expect('/* 1*2 */', true);
47
+ }
48
+ ],
49
+ parser: [
50
+ () => {
51
+ const m = descentParser(jsGrammar());
52
+ const cp = toArray(stringToCodePointList('tr'));
53
+ const mr = descentParserCpOnly(m, '', cp);
54
+ const seq = mr[0].sequence[0];
55
+ if (seq instanceof Array)
56
+ throw JSON.stringify(mr);
57
+ if (seq.tag !== 'id')
58
+ throw JSON.stringify(mr);
59
+ },
60
+ () => {
61
+ const m = descentParser(jsGrammar());
62
+ const cp = toArray(stringToCodePointList('"tr"'));
63
+ const mr = descentParserCpOnly(m, '', cp);
64
+ const seq = mr[0].sequence[0];
65
+ if (seq instanceof Array)
66
+ throw JSON.stringify(mr);
67
+ if (seq.tag !== 'string')
68
+ throw JSON.stringify(mr);
69
+ },
70
+ () => {
71
+ const m = descentParser(jsGrammar());
72
+ const cp = toArray(stringToCodePointList('56.7e+5'));
73
+ const mr = descentParserCpOnly(m, '', cp);
74
+ const seq = mr[0].sequence[0];
75
+ if (seq instanceof Array)
76
+ throw JSON.stringify(mr);
77
+ if (seq.tag !== 'number')
78
+ throw JSON.stringify(mr);
79
+ },
80
+ () => {
81
+ const m = descentParser(jsGrammar());
82
+ const cp = toArray(stringToCodePointList('56n'));
83
+ const mr = descentParserCpOnly(m, '', cp);
84
+ const seq = mr[0].sequence[0];
85
+ if (seq instanceof Array)
86
+ throw JSON.stringify(mr);
87
+ if (seq.tag !== 'number')
88
+ throw JSON.stringify(mr);
89
+ },
90
+ () => {
91
+ const m = descentParser(jsGrammar());
92
+ const cp = toArray(stringToCodePointList('*'));
93
+ const mr = descentParserCpOnly(m, '', cp);
94
+ const seq = mr[0].sequence[0];
95
+ if (seq instanceof Array)
96
+ throw JSON.stringify(mr);
97
+ if (seq.tag !== '*')
98
+ throw JSON.stringify(mr);
99
+ },
100
+ () => {
101
+ const m = descentParser(jsGrammar());
102
+ const cp = toArray(stringToCodePointList('**'));
103
+ const mr = descentParserCpOnly(m, '', cp);
104
+ const seq = mr[0].sequence[0];
105
+ if (seq instanceof Array)
106
+ throw JSON.stringify(mr);
107
+ if (seq.tag !== '**')
108
+ throw JSON.stringify(mr);
109
+ },
110
+ () => {
111
+ const m = descentParser(jsGrammar());
112
+ const cp = toArray(stringToCodePointList('=>'));
113
+ const mr = descentParserCpOnly(m, '', cp);
114
+ const seq = mr[0].sequence[0];
115
+ if (seq instanceof Array)
116
+ throw JSON.stringify(mr);
117
+ if (seq.tag !== '=>')
118
+ throw JSON.stringify(mr);
119
+ },
120
+ () => {
121
+ const m = descentParser(jsGrammar());
122
+ const cp = toArray(stringToCodePointList('=='));
123
+ const mr = descentParserCpOnly(m, '', cp);
124
+ const seq = mr[0].sequence[0];
125
+ if (seq instanceof Array)
126
+ throw JSON.stringify(mr);
127
+ if (seq.tag !== '==')
128
+ throw JSON.stringify(mr);
129
+ },
130
+ () => {
131
+ const m = descentParser(jsGrammar());
132
+ const cp = toArray(stringToCodePointList('==='));
133
+ const mr = descentParserCpOnly(m, '', cp);
134
+ const seq = mr[0].sequence[0];
135
+ if (seq instanceof Array)
136
+ throw JSON.stringify(mr);
137
+ if (seq.tag !== '===')
138
+ throw JSON.stringify(mr);
139
+ },
140
+ () => {
141
+ const m = descentParser(jsGrammar());
142
+ const cp = toArray(stringToCodePointList('='));
143
+ const mr = descentParserCpOnly(m, '', cp);
144
+ const seq = mr[0].sequence[0];
145
+ if (seq instanceof Array)
146
+ throw JSON.stringify(mr);
147
+ if (seq.tag !== '=')
148
+ throw JSON.stringify(mr);
149
+ },
150
+ () => {
151
+ const m = descentParser(jsGrammar());
152
+ const cp = toArray(stringToCodePointList(' '));
153
+ const mr = descentParserCpOnly(m, '', cp);
154
+ const seq = mr[0].sequence[0];
155
+ if (seq instanceof Array)
156
+ throw JSON.stringify(mr);
157
+ if (seq.tag !== ' ')
158
+ throw JSON.stringify(mr);
159
+ },
160
+ () => {
161
+ const m = descentParser(jsGrammar());
162
+ const cp = toArray(stringToCodePointList('\n'));
163
+ const mr = descentParserCpOnly(m, '', cp);
164
+ const seq = mr[0].sequence[0];
165
+ if (seq instanceof Array)
166
+ throw JSON.stringify(mr);
167
+ if (seq.tag !== '\n')
168
+ throw JSON.stringify(mr);
169
+ },
170
+ () => {
171
+ const m = descentParser(jsGrammar());
172
+ const cp = toArray(stringToCodePointList('/\n'));
173
+ const mr = descentParserCpOnly(m, '', cp);
174
+ const seq = mr[0].sequence[0];
175
+ if (seq instanceof Array)
176
+ throw JSON.stringify(mr);
177
+ if (seq.tag !== '/')
178
+ throw JSON.stringify(mr);
179
+ },
180
+ () => {
181
+ const m = descentParser(jsGrammar());
182
+ const cp = toArray(stringToCodePointList('//\n'));
183
+ const mr = descentParserCpOnly(m, '', cp);
184
+ const seq = mr[0].sequence[0];
185
+ if (seq instanceof Array)
186
+ throw JSON.stringify(mr);
187
+ if (seq.tag !== 'comment')
188
+ throw JSON.stringify(mr);
189
+ },
190
+ () => {
191
+ const m = descentParser(jsGrammar());
192
+ const cp = toArray(stringToCodePointList('/*1*/'));
193
+ const mr = descentParserCpOnly(m, '', cp);
194
+ const seq = mr[0].sequence[0];
195
+ if (seq instanceof Array)
196
+ throw JSON.stringify(mr);
197
+ if (seq.tag !== 'comment')
198
+ throw JSON.stringify(mr);
199
+ }
200
+ ]
201
+ };
@@ -53,9 +53,9 @@ export const serializeWithoutConst = sort => {
53
53
  ]);
54
54
  const mapPropertySerialize = map(propertySerialize);
55
55
  const objectSerialize = fn(entries)
56
- .then(sort)
57
- .then(mapPropertySerialize)
58
- .then(objectWrap)
56
+ .map(sort)
57
+ .map(mapPropertySerialize)
58
+ .map(objectWrap)
59
59
  .result;
60
60
  const f = value => {
61
61
  switch (typeof value) {
@@ -96,9 +96,9 @@ const serializeWithConst = sort => refs => root => {
96
96
  ]);
97
97
  const mapPropertySerialize = map(propertySerialize);
98
98
  const objectSerialize = fn(entries)
99
- .then(sort)
100
- .then(mapPropertySerialize)
101
- .then(objectWrap)
99
+ .map(sort)
100
+ .map(mapPropertySerialize)
101
+ .map(objectWrap)
102
102
  .result;
103
103
  const f = value => {
104
104
  if (value !== root) {