functionalscript 0.8.0 → 0.8.1
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/bnf/data/module.f.d.ts +6 -0
- package/bnf/data/module.f.js +57 -4
- package/bnf/data/test.f.d.ts +1 -0
- package/bnf/data/test.f.js +67 -1
- package/ci/module.f.d.ts +3 -0
- package/ci/module.f.js +169 -0
- package/ci/module.js +3 -0
- package/crypto/hmac/module.f.d.ts +5 -4
- package/crypto/hmac/module.f.js +9 -18
- package/crypto/hmac/test.f.d.ts +1 -0
- package/crypto/hmac/test.f.js +16 -8
- package/crypto/prime_field/module.f.d.ts +1 -1
- package/crypto/prime_field/module.f.js +4 -3
- package/crypto/prime_field/test.f.js +13 -13
- package/crypto/rfc6979/module.f.d.ts +15 -0
- package/crypto/rfc6979/module.f.js +98 -0
- package/crypto/rfc6979/test.f.d.ts +10 -0
- package/crypto/rfc6979/test.f.js +490 -0
- package/crypto/secp/module.f.d.ts +4 -4
- package/crypto/secp/module.f.js +1 -1
- package/crypto/secp/test.f.js +8 -8
- package/crypto/sha2/module.f.d.ts +11 -5
- package/crypto/sha2/module.f.js +4 -3
- package/crypto/sha2/test.f.d.ts +4 -1
- package/crypto/sha2/test.f.js +41 -31
- package/crypto/sign/module.f.d.ts +1 -1
- package/crypto/sign/module.f.js +3 -2
- package/dev/tf/all.test.js +9 -1
- package/djs/ast/module.f.d.ts +3 -3
- package/djs/ast/test.f.js +7 -8
- package/djs/parser/module.f.d.ts +3 -3
- package/djs/parser/module.f.js +4 -4
- package/djs/parser/test.f.js +76 -77
- package/djs/serializer/module.f.d.ts +8 -8
- package/djs/serializer/module.f.js +4 -7
- package/djs/serializer/test.f.js +8 -9
- package/djs/tokenizer/module.f.d.ts +2 -2
- package/djs/tokenizer/module.f.js +3 -5
- package/djs/tokenizer/test.f.js +8 -10
- package/djs/transpiler/module.f.d.ts +3 -3
- package/djs/transpiler/module.f.js +2 -0
- package/fsc/bnf.f.d.ts +1 -1
- package/fsc/bnf.f.js +39 -51
- package/fsc/json.f.d.ts +1 -1
- package/fsc/json.f.js +56 -81
- package/fsc/test.f.js +4 -6
- package/fsm/module.f.js +3 -3
- package/fsm/test.f.js +21 -25
- package/html/module.f.js +17 -4
- package/html/test.f.d.ts +7 -0
- package/html/test.f.js +37 -0
- package/issues/031-json.f.d.ts +1 -0
- package/js/tokenizer/module.f.d.ts +4 -4
- package/js/tokenizer/module.f.js +12 -17
- package/js/tokenizer/test.f.js +9 -11
- package/json/module.f.d.ts +6 -6
- package/json/module.f.js +5 -10
- package/json/parser/module.f.d.ts +4 -4
- package/json/parser/module.f.js +7 -4
- package/json/parser/test.f.js +47 -49
- package/json/serializer/module.f.d.ts +6 -6
- package/json/serializer/module.f.js +3 -2
- package/json/serializer/test.f.js +13 -13
- package/json/test.f.js +13 -15
- package/json/tokenizer/module.f.d.ts +4 -4
- package/json/tokenizer/module.f.js +6 -7
- package/json/tokenizer/test.f.js +7 -9
- package/package.json +5 -5
- package/text/ascii/test.f.js +2 -2
- package/text/module.f.d.ts +3 -2
- package/text/module.f.js +2 -2
- package/text/test.f.js +3 -3
- package/text/utf16/test.f.js +2 -2
- package/text/utf8/test.f.js +2 -2
- package/types/array/test.f.js +2 -2
- package/types/bigint/module.f.d.ts +6 -3
- package/types/bigint/module.f.js +12 -11
- package/types/bigint/test.f.d.ts +2 -0
- package/types/bigint/test.f.js +21 -2
- package/types/bit_vec/module.f.d.ts +66 -34
- package/types/bit_vec/module.f.js +97 -32
- package/types/bit_vec/test.f.d.ts +7 -0
- package/types/bit_vec/test.f.js +283 -62
- package/types/btree/find/test.f.js +9 -8
- package/types/btree/remove/test.f.js +4 -4
- package/types/btree/set/test.f.js +4 -4
- package/types/btree/test.f.js +7 -7
- package/types/byte_set/test.f.js +2 -2
- package/types/function/compare/module.f.d.ts +15 -1
- package/types/function/compare/module.f.js +1 -1
- package/types/function/compare/test.f.js +37 -4
- package/types/list/test.f.js +93 -93
- package/types/monoid/module.f.d.ts +4 -4
- package/types/monoid/module.f.js +3 -3
- package/types/monoid/test.f.js +3 -3
- package/types/nominal/module.f.d.ts +5 -0
- package/types/nominal/module.f.js +4 -0
- package/types/nominal/test.f.d.ts +5 -0
- package/types/nominal/test.f.js +53 -0
- package/types/number/module.f.js +2 -2
- package/types/range_map/test.f.js +21 -21
- package/types/sorted_list/test.f.js +10 -10
- package/types/sorted_set/test.f.js +14 -14
- package/types/string/module.f.js +2 -2
- package/types/string_set/module.f.js +3 -3
- package/bnf/func/module.f.d.ts +0 -148
- package/bnf/func/module.f.js +0 -132
- package/bnf/func/test.f.d.ts +0 -12
- package/bnf/func/test.f.js +0 -171
- package/bnf/func/testlib.f.d.ts +0 -25
- package/bnf/func/testlib.f.js +0 -150
- /package/{issues/31-json.f.d.ts → ci/module.d.ts} +0 -0
- /package/issues/{31-json.f.js → 031-json.f.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type
|
|
1
|
+
import { type List } from '../../types/list/module.f.ts';
|
|
2
|
+
import { type BigFloat } from '../../types/bigfloat/module.f.ts';
|
|
3
3
|
export type StringToken = {
|
|
4
4
|
readonly kind: 'string';
|
|
5
5
|
readonly value: string;
|
|
@@ -7,7 +7,7 @@ export type StringToken = {
|
|
|
7
7
|
export type NumberToken = {
|
|
8
8
|
readonly kind: 'number';
|
|
9
9
|
readonly value: string;
|
|
10
|
-
readonly bf:
|
|
10
|
+
readonly bf: BigFloat;
|
|
11
11
|
};
|
|
12
12
|
export type BigIntToken = {
|
|
13
13
|
readonly kind: 'bigint';
|
|
@@ -94,5 +94,5 @@ export type JsTokenWithMetadata = {
|
|
|
94
94
|
};
|
|
95
95
|
type ErrorMessage = '" are missing' | 'unescaped character' | 'invalid hex value' | 'unexpected character' | 'invalid number' | 'invalid token' | '*\/ expected' | 'unterminated string literal' | 'eof';
|
|
96
96
|
export declare const isKeywordToken: (token: JsToken) => boolean;
|
|
97
|
-
export declare const tokenize: (input:
|
|
97
|
+
export declare const tokenize: (input: List<number>) => (path: string) => List<JsTokenWithMetadata>;
|
|
98
98
|
export {};
|
package/js/tokenizer/module.f.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
const { one } = _range;
|
|
9
|
-
const { empty, stateScan, flat, toArray, reduce: listReduce, scan, map: listMap } = list;
|
|
10
|
-
const { fromCharCode } = String;
|
|
11
|
-
import * as ascii from "../../text/ascii/module.f.js";
|
|
12
|
-
const { range } = ascii;
|
|
13
|
-
const {
|
|
1
|
+
import { strictEqual } from "../../types/function/operator/module.f.js";
|
|
2
|
+
import { merge, fromRange, get } from "../../types/range_map/module.f.js";
|
|
3
|
+
import { empty, stateScan, flat, toArray, reduce as listReduce, scan, map as listMap } from "../../types/list/module.f.js";
|
|
4
|
+
import { at, fromEntries } from "../../types/ordered_map/module.f.js";
|
|
5
|
+
import { one } from "../../types/range/module.f.js";
|
|
6
|
+
import {} from "../../types/bigfloat/module.f.js";
|
|
7
|
+
import { range,
|
|
14
8
|
//
|
|
15
9
|
backspace, ht, lf, ff, cr,
|
|
16
10
|
//
|
|
@@ -26,7 +20,8 @@ leftSquareBracket, reverseSolidus, rightSquareBracket, lowLine,
|
|
|
26
20
|
//
|
|
27
21
|
latinSmallLetterRange, latinSmallLetterA, latinSmallLetterB, latinSmallLetterE, latinSmallLetterF, latinSmallLetterN, latinSmallLetterR, latinSmallLetterT, latinSmallLetterU,
|
|
28
22
|
//
|
|
29
|
-
leftCurlyBracket, rightCurlyBracket, dollarSign }
|
|
23
|
+
leftCurlyBracket, rightCurlyBracket, dollarSign } from "../../text/ascii/module.f.js";
|
|
24
|
+
const { fromCharCode } = String;
|
|
30
25
|
const rangeOneNine = range('19');
|
|
31
26
|
const rangeSetNewLine = [
|
|
32
27
|
one(lf),
|
|
@@ -106,7 +101,7 @@ const union = def => a => b => {
|
|
|
106
101
|
};
|
|
107
102
|
const rangeMapMerge = def => merge({
|
|
108
103
|
union: union(def),
|
|
109
|
-
equal:
|
|
104
|
+
equal: strictEqual,
|
|
110
105
|
def,
|
|
111
106
|
});
|
|
112
107
|
const rangeFunc = r => f => def => fromRange(def)(r)(f);
|
|
@@ -194,7 +189,7 @@ const keywordEntries = [
|
|
|
194
189
|
['with', { kind: 'with' }],
|
|
195
190
|
['yield', { kind: 'yield' }],
|
|
196
191
|
];
|
|
197
|
-
const keywordMap =
|
|
192
|
+
const keywordMap = fromEntries(keywordEntries);
|
|
198
193
|
export const isKeywordToken = token => at(token.kind)(keywordMap) !== null;
|
|
199
194
|
/**
|
|
200
195
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators
|
|
@@ -256,7 +251,7 @@ const operatorEntries = [
|
|
|
256
251
|
['}', { kind: '}' }],
|
|
257
252
|
['~', { kind: '~' }]
|
|
258
253
|
];
|
|
259
|
-
const operatorMap =
|
|
254
|
+
const operatorMap = fromEntries(operatorEntries);
|
|
260
255
|
const getOperatorToken = op => at(op)(operatorMap) ?? { kind: 'error', message: 'invalid token' };
|
|
261
256
|
const hasOperatorToken = op => at(op)(operatorMap) !== null;
|
|
262
257
|
const initialStateOp = create((state) => () => [[{ kind: 'error', message: 'unexpected character' }], state])([
|
package/js/tokenizer/test.f.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const stringify = serializer.stringifyAsTree(sort);
|
|
11
|
-
const withoutMetada = tokenWithMetada => { return tokenWithMetada.token; };
|
|
1
|
+
import { tokenize } from "./module.f.js";
|
|
2
|
+
import { map, toArray } from "../../types/list/module.f.js";
|
|
3
|
+
import { stringifyAsTree } from "../../djs/serializer/module.f.js";
|
|
4
|
+
import { sort } from "../../types/object/module.f.js";
|
|
5
|
+
import { stringToList } from "../../text/utf16/module.f.js";
|
|
6
|
+
const tokenizeString = s => toArray(map(withoutMetada)(tokenize(stringToList(s))('')));
|
|
7
|
+
const tokenizeStringWithMetadata = s => toArray(tokenize(stringToList(s))(''));
|
|
8
|
+
const stringify = stringifyAsTree(sort);
|
|
9
|
+
const withoutMetada = tokenWithMetada => tokenWithMetada.token;
|
|
12
10
|
export default {
|
|
13
11
|
djs: [
|
|
14
12
|
() => {
|
package/json/module.f.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { type List } from '../types/list/module.f.ts';
|
|
2
|
+
import { type Entry as ObjectEntry } from '../types/object/module.f.ts';
|
|
3
3
|
type Object = {
|
|
4
4
|
readonly [k in string]: Unknown;
|
|
5
5
|
};
|
|
6
6
|
type Array = readonly Unknown[];
|
|
7
7
|
export type Primitive = boolean | string | number | null;
|
|
8
8
|
export type Unknown = Primitive | Object | Array;
|
|
9
|
-
export declare const setProperty: (value: Unknown) => (path:
|
|
10
|
-
export type Entry =
|
|
11
|
-
type Entries =
|
|
9
|
+
export declare const setProperty: (value: Unknown) => (path: List<string>) => (src: Unknown) => Unknown;
|
|
10
|
+
export type Entry = ObjectEntry<Unknown>;
|
|
11
|
+
type Entries = List<Entry>;
|
|
12
12
|
type MapEntries = (entries: Entries) => Entries;
|
|
13
|
-
export declare const serialize: (mapEntries: MapEntries) => (value: Unknown) =>
|
|
13
|
+
export declare const serialize: (mapEntries: MapEntries) => (value: Unknown) => List<string>;
|
|
14
14
|
/**
|
|
15
15
|
* The standard `JSON.stringify` rules determined by
|
|
16
16
|
* https://262.ecma-international.org/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
|
package/json/module.f.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
const { at } = object;
|
|
7
|
-
import * as f from "../types/function/module.f.js";
|
|
8
|
-
const { compose, fn } = f;
|
|
1
|
+
import { next, flat, map } from "../types/list/module.f.js";
|
|
2
|
+
import { concat } from "../types/string/module.f.js";
|
|
3
|
+
import { at } from "../types/object/module.f.js";
|
|
4
|
+
import { compose, fn } from "../types/function/module.f.js";
|
|
5
|
+
import { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } from "./serializer/module.f.js";
|
|
9
6
|
const { entries } = Object;
|
|
10
|
-
import * as s from "./serializer/module.f.js";
|
|
11
|
-
const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = s;
|
|
12
7
|
export const setProperty = value => {
|
|
13
8
|
const f = path => src => {
|
|
14
9
|
const result = next(path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Result } from '../../types/result/module.f.ts';
|
|
2
2
|
import { type List } from '../../types/list/module.f.ts';
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
export declare const parse: (tokenList: List<
|
|
3
|
+
import { type JsonToken } from '../tokenizer/module.f.ts';
|
|
4
|
+
import { type Unknown } from '../module.f.ts';
|
|
5
|
+
export declare const parse: (tokenList: List<JsonToken>) => Result<Unknown, string>;
|
package/json/parser/module.f.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { error, ok } from "../../types/result/module.f.js";
|
|
2
2
|
import { fold, first, drop, toArray, concat } from "../../types/list/module.f.js";
|
|
3
|
+
import {} from "../../types/function/operator/module.f.js";
|
|
4
|
+
import {} from "../tokenizer/module.f.js";
|
|
3
5
|
import { setReplace } from "../../types/ordered_map/module.f.js";
|
|
6
|
+
import {} from "../module.f.js";
|
|
4
7
|
import { fromMap } from "../../types/object/module.f.js";
|
|
5
8
|
const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key });
|
|
6
9
|
const addValueToObject = obj => value => ({ kind: 'object', values: setReplace(obj.key)(value)(obj.values), key: '' });
|
|
@@ -151,8 +154,8 @@ const foldOp = token => state => {
|
|
|
151
154
|
export const parse = tokenList => {
|
|
152
155
|
const state = fold(foldOp)({ status: '', top: null, stack: null })(tokenList);
|
|
153
156
|
switch (state.status) {
|
|
154
|
-
case 'result': return
|
|
155
|
-
case 'error': return
|
|
156
|
-
default: return
|
|
157
|
+
case 'result': return ok(state.value);
|
|
158
|
+
case 'error': return error(state.message);
|
|
159
|
+
default: return error('unexpected end');
|
|
157
160
|
}
|
|
158
161
|
};
|
package/json/parser/test.f.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)));
|
|
10
|
-
const stringify = json.stringify(sort);
|
|
1
|
+
import { parse } from "./module.f.js";
|
|
2
|
+
import { tokenize } from "../tokenizer/module.f.js";
|
|
3
|
+
import { toArray } from "../../types/list/module.f.js";
|
|
4
|
+
import { stringify as jsonStringify } from "../module.f.js";
|
|
5
|
+
import { sort } from "../../types/object/module.f.js";
|
|
6
|
+
import { stringToList } from "../../text/utf16/module.f.js";
|
|
7
|
+
const tokenizeString = s => toArray(tokenize(stringToList(s)));
|
|
8
|
+
const stringify = jsonStringify(sort);
|
|
11
9
|
export default {
|
|
12
10
|
valid: [
|
|
13
11
|
() => {
|
|
14
12
|
const tokenList = tokenizeString('null');
|
|
15
|
-
const obj =
|
|
13
|
+
const obj = parse(tokenList);
|
|
16
14
|
const result = stringify(obj);
|
|
17
15
|
if (result !== '["ok",null]') {
|
|
18
16
|
throw result;
|
|
@@ -20,7 +18,7 @@ export default {
|
|
|
20
18
|
},
|
|
21
19
|
() => {
|
|
22
20
|
const tokenList = tokenizeString('true');
|
|
23
|
-
const obj =
|
|
21
|
+
const obj = parse(tokenList);
|
|
24
22
|
const result = stringify(obj);
|
|
25
23
|
if (result !== '["ok",true]') {
|
|
26
24
|
throw result;
|
|
@@ -28,7 +26,7 @@ export default {
|
|
|
28
26
|
},
|
|
29
27
|
() => {
|
|
30
28
|
const tokenList = tokenizeString('false');
|
|
31
|
-
const obj =
|
|
29
|
+
const obj = parse(tokenList);
|
|
32
30
|
const result = stringify(obj);
|
|
33
31
|
if (result !== '["ok",false]') {
|
|
34
32
|
throw result;
|
|
@@ -36,7 +34,7 @@ export default {
|
|
|
36
34
|
},
|
|
37
35
|
() => {
|
|
38
36
|
const tokenList = tokenizeString('0.1');
|
|
39
|
-
const obj =
|
|
37
|
+
const obj = parse(tokenList);
|
|
40
38
|
const result = stringify(obj);
|
|
41
39
|
if (result !== '["ok",0.1]') {
|
|
42
40
|
throw result;
|
|
@@ -44,7 +42,7 @@ export default {
|
|
|
44
42
|
},
|
|
45
43
|
() => {
|
|
46
44
|
const tokenList = tokenizeString('1.1e+2');
|
|
47
|
-
const obj =
|
|
45
|
+
const obj = parse(tokenList);
|
|
48
46
|
const result = stringify(obj);
|
|
49
47
|
if (result !== '["ok",110]') {
|
|
50
48
|
throw result;
|
|
@@ -52,7 +50,7 @@ export default {
|
|
|
52
50
|
},
|
|
53
51
|
() => {
|
|
54
52
|
const tokenList = tokenizeString('"abc"');
|
|
55
|
-
const obj =
|
|
53
|
+
const obj = parse(tokenList);
|
|
56
54
|
const result = stringify(obj);
|
|
57
55
|
if (result !== '["ok","abc"]') {
|
|
58
56
|
throw result;
|
|
@@ -60,7 +58,7 @@ export default {
|
|
|
60
58
|
},
|
|
61
59
|
() => {
|
|
62
60
|
const tokenList = tokenizeString('[]');
|
|
63
|
-
const obj =
|
|
61
|
+
const obj = parse(tokenList);
|
|
64
62
|
const result = stringify(obj);
|
|
65
63
|
if (result !== '["ok",[]]') {
|
|
66
64
|
throw result;
|
|
@@ -68,7 +66,7 @@ export default {
|
|
|
68
66
|
},
|
|
69
67
|
() => {
|
|
70
68
|
const tokenList = tokenizeString('[1]');
|
|
71
|
-
const obj =
|
|
69
|
+
const obj = parse(tokenList);
|
|
72
70
|
const result = stringify(obj);
|
|
73
71
|
if (result !== '["ok",[1]]') {
|
|
74
72
|
throw result;
|
|
@@ -76,7 +74,7 @@ export default {
|
|
|
76
74
|
},
|
|
77
75
|
() => {
|
|
78
76
|
const tokenList = tokenizeString('[[]]');
|
|
79
|
-
const obj =
|
|
77
|
+
const obj = parse(tokenList);
|
|
80
78
|
const result = stringify(obj);
|
|
81
79
|
if (result !== '["ok",[[]]]') {
|
|
82
80
|
throw result;
|
|
@@ -84,7 +82,7 @@ export default {
|
|
|
84
82
|
},
|
|
85
83
|
() => {
|
|
86
84
|
const tokenList = tokenizeString('[0,[1,[2,[]]],3]');
|
|
87
|
-
const obj =
|
|
85
|
+
const obj = parse(tokenList);
|
|
88
86
|
const result = stringify(obj);
|
|
89
87
|
if (result !== '["ok",[0,[1,[2,[]]],3]]') {
|
|
90
88
|
throw result;
|
|
@@ -92,7 +90,7 @@ export default {
|
|
|
92
90
|
},
|
|
93
91
|
() => {
|
|
94
92
|
const tokenList = tokenizeString('{}');
|
|
95
|
-
const obj =
|
|
93
|
+
const obj = parse(tokenList);
|
|
96
94
|
const result = stringify(obj);
|
|
97
95
|
if (result !== '["ok",{}]') {
|
|
98
96
|
throw result;
|
|
@@ -100,7 +98,7 @@ export default {
|
|
|
100
98
|
},
|
|
101
99
|
() => {
|
|
102
100
|
const tokenList = tokenizeString('[{}]');
|
|
103
|
-
const obj =
|
|
101
|
+
const obj = parse(tokenList);
|
|
104
102
|
const result = stringify(obj);
|
|
105
103
|
if (result !== '["ok",[{}]]') {
|
|
106
104
|
throw result;
|
|
@@ -108,7 +106,7 @@ export default {
|
|
|
108
106
|
},
|
|
109
107
|
() => {
|
|
110
108
|
const tokenList = tokenizeString('{"a":true,"b":false,"c":null}');
|
|
111
|
-
const obj =
|
|
109
|
+
const obj = parse(tokenList);
|
|
112
110
|
const result = stringify(obj);
|
|
113
111
|
if (result !== '["ok",{"a":true,"b":false,"c":null}]') {
|
|
114
112
|
throw result;
|
|
@@ -116,7 +114,7 @@ export default {
|
|
|
116
114
|
},
|
|
117
115
|
() => {
|
|
118
116
|
const tokenList = tokenizeString('{"a":{"b":{"c":["d"]}}}');
|
|
119
|
-
const obj =
|
|
117
|
+
const obj = parse(tokenList);
|
|
120
118
|
const result = stringify(obj);
|
|
121
119
|
if (result !== '["ok",{"a":{"b":{"c":["d"]}}}]') {
|
|
122
120
|
throw result;
|
|
@@ -124,7 +122,7 @@ export default {
|
|
|
124
122
|
},
|
|
125
123
|
() => {
|
|
126
124
|
const tokenList = tokenizeString('[1,]');
|
|
127
|
-
const obj =
|
|
125
|
+
const obj = parse(tokenList);
|
|
128
126
|
const result = stringify(obj);
|
|
129
127
|
if (result !== '["ok",[1]]') {
|
|
130
128
|
throw result;
|
|
@@ -132,7 +130,7 @@ export default {
|
|
|
132
130
|
},
|
|
133
131
|
() => {
|
|
134
132
|
const tokenList = tokenizeString('{"a":1,}');
|
|
135
|
-
const obj =
|
|
133
|
+
const obj = parse(tokenList);
|
|
136
134
|
const result = stringify(obj);
|
|
137
135
|
if (result !== '["ok",{"a":1}]') {
|
|
138
136
|
throw result;
|
|
@@ -142,7 +140,7 @@ export default {
|
|
|
142
140
|
invalid: [
|
|
143
141
|
() => {
|
|
144
142
|
const tokenList = tokenizeString('');
|
|
145
|
-
const obj =
|
|
143
|
+
const obj = parse(tokenList);
|
|
146
144
|
const result = stringify(obj);
|
|
147
145
|
if (result !== '["error","unexpected end"]') {
|
|
148
146
|
throw result;
|
|
@@ -150,7 +148,7 @@ export default {
|
|
|
150
148
|
},
|
|
151
149
|
() => {
|
|
152
150
|
const tokenList = tokenizeString('"123');
|
|
153
|
-
const obj =
|
|
151
|
+
const obj = parse(tokenList);
|
|
154
152
|
const result = stringify(obj);
|
|
155
153
|
if (result !== '["error","unexpected token"]') {
|
|
156
154
|
throw result;
|
|
@@ -158,7 +156,7 @@ export default {
|
|
|
158
156
|
},
|
|
159
157
|
() => {
|
|
160
158
|
const tokenList = tokenizeString('[,]');
|
|
161
|
-
const obj =
|
|
159
|
+
const obj = parse(tokenList);
|
|
162
160
|
const result = stringify(obj);
|
|
163
161
|
if (result !== '["error","unexpected token"]') {
|
|
164
162
|
throw result;
|
|
@@ -166,7 +164,7 @@ export default {
|
|
|
166
164
|
},
|
|
167
165
|
() => {
|
|
168
166
|
const tokenList = tokenizeString('[1 2]');
|
|
169
|
-
const obj =
|
|
167
|
+
const obj = parse(tokenList);
|
|
170
168
|
const result = stringify(obj);
|
|
171
169
|
if (result !== '["error","unexpected token"]') {
|
|
172
170
|
throw result;
|
|
@@ -174,7 +172,7 @@ export default {
|
|
|
174
172
|
},
|
|
175
173
|
() => {
|
|
176
174
|
const tokenList = tokenizeString('[1,,2]');
|
|
177
|
-
const obj =
|
|
175
|
+
const obj = parse(tokenList);
|
|
178
176
|
const result = stringify(obj);
|
|
179
177
|
if (result !== '["error","unexpected token"]') {
|
|
180
178
|
throw result;
|
|
@@ -182,7 +180,7 @@ export default {
|
|
|
182
180
|
},
|
|
183
181
|
() => {
|
|
184
182
|
const tokenList = tokenizeString('[]]');
|
|
185
|
-
const obj =
|
|
183
|
+
const obj = parse(tokenList);
|
|
186
184
|
const result = stringify(obj);
|
|
187
185
|
if (result !== '["error","unexpected token"]') {
|
|
188
186
|
throw result;
|
|
@@ -190,7 +188,7 @@ export default {
|
|
|
190
188
|
},
|
|
191
189
|
() => {
|
|
192
190
|
const tokenList = tokenizeString('["a"');
|
|
193
|
-
const obj =
|
|
191
|
+
const obj = parse(tokenList);
|
|
194
192
|
const result = stringify(obj);
|
|
195
193
|
if (result !== '["error","unexpected end"]') {
|
|
196
194
|
throw result;
|
|
@@ -198,7 +196,7 @@ export default {
|
|
|
198
196
|
},
|
|
199
197
|
() => {
|
|
200
198
|
const tokenList = tokenizeString('[,1]');
|
|
201
|
-
const obj =
|
|
199
|
+
const obj = parse(tokenList);
|
|
202
200
|
const result = stringify(obj);
|
|
203
201
|
if (result !== '["error","unexpected token"]') {
|
|
204
202
|
throw result;
|
|
@@ -206,7 +204,7 @@ export default {
|
|
|
206
204
|
},
|
|
207
205
|
() => {
|
|
208
206
|
const tokenList = tokenizeString('[:]');
|
|
209
|
-
const obj =
|
|
207
|
+
const obj = parse(tokenList);
|
|
210
208
|
const result = stringify(obj);
|
|
211
209
|
if (result !== '["error","unexpected token"]') {
|
|
212
210
|
throw result;
|
|
@@ -214,7 +212,7 @@ export default {
|
|
|
214
212
|
},
|
|
215
213
|
() => {
|
|
216
214
|
const tokenList = tokenizeString(']');
|
|
217
|
-
const obj =
|
|
215
|
+
const obj = parse(tokenList);
|
|
218
216
|
const result = stringify(obj);
|
|
219
217
|
if (result !== '["error","unexpected token"]') {
|
|
220
218
|
throw result;
|
|
@@ -222,7 +220,7 @@ export default {
|
|
|
222
220
|
},
|
|
223
221
|
() => {
|
|
224
222
|
const tokenList = tokenizeString('{,}');
|
|
225
|
-
const obj =
|
|
223
|
+
const obj = parse(tokenList);
|
|
226
224
|
const result = stringify(obj);
|
|
227
225
|
if (result !== '["error","unexpected token"]') {
|
|
228
226
|
throw result;
|
|
@@ -230,7 +228,7 @@ export default {
|
|
|
230
228
|
},
|
|
231
229
|
() => {
|
|
232
230
|
const tokenList = tokenizeString('{1:2}');
|
|
233
|
-
const obj =
|
|
231
|
+
const obj = parse(tokenList);
|
|
234
232
|
const result = stringify(obj);
|
|
235
233
|
if (result !== '["error","unexpected token"]') {
|
|
236
234
|
throw result;
|
|
@@ -238,7 +236,7 @@ export default {
|
|
|
238
236
|
},
|
|
239
237
|
() => {
|
|
240
238
|
const tokenList = tokenizeString('{"1"2}');
|
|
241
|
-
const obj =
|
|
239
|
+
const obj = parse(tokenList);
|
|
242
240
|
const result = stringify(obj);
|
|
243
241
|
if (result !== '["error","unexpected token"]') {
|
|
244
242
|
throw result;
|
|
@@ -246,7 +244,7 @@ export default {
|
|
|
246
244
|
},
|
|
247
245
|
() => {
|
|
248
246
|
const tokenList = tokenizeString('{"1"::2}');
|
|
249
|
-
const obj =
|
|
247
|
+
const obj = parse(tokenList);
|
|
250
248
|
const result = stringify(obj);
|
|
251
249
|
if (result !== '["error","unexpected token"]') {
|
|
252
250
|
throw result;
|
|
@@ -254,7 +252,7 @@ export default {
|
|
|
254
252
|
},
|
|
255
253
|
() => {
|
|
256
254
|
const tokenList = tokenizeString('{"1":2,,"3":4');
|
|
257
|
-
const obj =
|
|
255
|
+
const obj = parse(tokenList);
|
|
258
256
|
const result = stringify(obj);
|
|
259
257
|
if (result !== '["error","unexpected token"]') {
|
|
260
258
|
throw result;
|
|
@@ -262,7 +260,7 @@ export default {
|
|
|
262
260
|
},
|
|
263
261
|
() => {
|
|
264
262
|
const tokenList = tokenizeString('{}}');
|
|
265
|
-
const obj =
|
|
263
|
+
const obj = parse(tokenList);
|
|
266
264
|
const result = stringify(obj);
|
|
267
265
|
if (result !== '["error","unexpected token"]') {
|
|
268
266
|
throw result;
|
|
@@ -270,7 +268,7 @@ export default {
|
|
|
270
268
|
},
|
|
271
269
|
() => {
|
|
272
270
|
const tokenList = tokenizeString('{"1":2');
|
|
273
|
-
const obj =
|
|
271
|
+
const obj = parse(tokenList);
|
|
274
272
|
const result = stringify(obj);
|
|
275
273
|
if (result !== '["error","unexpected end"]') {
|
|
276
274
|
throw result;
|
|
@@ -278,7 +276,7 @@ export default {
|
|
|
278
276
|
},
|
|
279
277
|
() => {
|
|
280
278
|
const tokenList = tokenizeString('{,"1":2}');
|
|
281
|
-
const obj =
|
|
279
|
+
const obj = parse(tokenList);
|
|
282
280
|
const result = stringify(obj);
|
|
283
281
|
if (result !== '["error","unexpected token"]') {
|
|
284
282
|
throw result;
|
|
@@ -286,7 +284,7 @@ export default {
|
|
|
286
284
|
},
|
|
287
285
|
() => {
|
|
288
286
|
const tokenList = tokenizeString('}');
|
|
289
|
-
const obj =
|
|
287
|
+
const obj = parse(tokenList);
|
|
290
288
|
const result = stringify(obj);
|
|
291
289
|
if (result !== '["error","unexpected token"]') {
|
|
292
290
|
throw result;
|
|
@@ -294,7 +292,7 @@ export default {
|
|
|
294
292
|
},
|
|
295
293
|
() => {
|
|
296
294
|
const tokenList = tokenizeString('[{]}');
|
|
297
|
-
const obj =
|
|
295
|
+
const obj = parse(tokenList);
|
|
298
296
|
const result = stringify(obj);
|
|
299
297
|
if (result !== '["error","unexpected token"]') {
|
|
300
298
|
throw result;
|
|
@@ -302,7 +300,7 @@ export default {
|
|
|
302
300
|
},
|
|
303
301
|
() => {
|
|
304
302
|
const tokenList = tokenizeString('{[}]');
|
|
305
|
-
const obj =
|
|
303
|
+
const obj = parse(tokenList);
|
|
306
304
|
const result = stringify(obj);
|
|
307
305
|
if (result !== '["error","unexpected token"]') {
|
|
308
306
|
throw result;
|
|
@@ -310,7 +308,7 @@ export default {
|
|
|
310
308
|
},
|
|
311
309
|
() => {
|
|
312
310
|
const tokenList = tokenizeString('10-5');
|
|
313
|
-
const obj =
|
|
311
|
+
const obj = parse(tokenList);
|
|
314
312
|
const result = stringify(obj);
|
|
315
313
|
if (result !== '["error","unexpected token"]') {
|
|
316
314
|
throw result;
|
|
@@ -318,7 +316,7 @@ export default {
|
|
|
318
316
|
},
|
|
319
317
|
() => {
|
|
320
318
|
const tokenList = tokenizeString('undefined');
|
|
321
|
-
const obj =
|
|
319
|
+
const obj = parse(tokenList);
|
|
322
320
|
const result = stringify(obj);
|
|
323
321
|
if (result !== '["error","unexpected token"]') {
|
|
324
322
|
throw result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const stringSerialize: (_: string) =>
|
|
3
|
-
export declare const numberSerialize: (_: number) =>
|
|
1
|
+
import { type List } from '../../types/list/module.f.ts';
|
|
2
|
+
export declare const stringSerialize: (_: string) => List<string>;
|
|
3
|
+
export declare const numberSerialize: (_: number) => List<string>;
|
|
4
4
|
export declare const nullSerialize: string[];
|
|
5
|
-
export declare const boolSerialize: (_: boolean) =>
|
|
6
|
-
export declare const objectWrap: (input:
|
|
7
|
-
export declare const arrayWrap: (input:
|
|
5
|
+
export declare const boolSerialize: (_: boolean) => List<string>;
|
|
6
|
+
export declare const objectWrap: (input: List<List<string>>) => List<string>;
|
|
7
|
+
export declare const arrayWrap: (input: List<List<string>>) => List<string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { flat, reduce, empty } from "../../types/list/module.f.js";
|
|
2
|
+
import {} from "../../types/object/module.f.js";
|
|
3
|
+
import {} from "../../types/function/operator/module.f.js";
|
|
3
4
|
const jsonStringify = JSON.stringify;
|
|
4
5
|
export const stringSerialize = input => [jsonStringify(input)];
|
|
5
6
|
export const numberSerialize = input => [jsonStringify(input)];
|