functionalscript 0.3.6 → 0.3.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/com/cpp/module.f.js +0 -1
- package/com/cs/module.f.js +5 -6
- package/com/rust/module.f.d.ts +3 -3
- package/com/rust/module.f.js +24 -29
- package/com/test/build.f.js +2 -2
- package/com/types/module.f.d.ts +1 -1
- package/com/types/module.f.js +1 -2
- package/com/types/testlib.f.js +0 -1
- package/commonjs/build/module.f.d.ts +2 -2
- package/commonjs/build/module.f.js +3 -6
- package/commonjs/build/test.f.js +0 -4
- package/commonjs/module/function/module.f.d.ts +1 -1
- package/commonjs/module/function/module.f.js +1 -1
- package/commonjs/module/module.f.d.ts +1 -1
- package/commonjs/module/module.f.js +2 -3
- package/commonjs/path/module.f.d.ts +5 -5
- package/commonjs/path/module.f.js +6 -8
- package/commonjs/path/test.f.js +1 -2
- package/crypto/prime_field/module.f.d.ts +2 -2
- package/crypto/prime_field/module.f.js +3 -4
- package/crypto/secp/module.f.d.ts +2 -2
- package/crypto/secp/module.f.js +4 -5
- package/crypto/sha2/module.f.d.ts +75 -12
- package/crypto/sha2/module.f.js +246 -139
- package/crypto/sha2/test.f.d.ts +22 -3
- package/crypto/sha2/test.f.js +120 -67
- package/dev/test/module.f.d.ts +1 -1
- package/dev/test/module.f.js +4 -5
- package/dev/test.f.js +0 -4
- package/djs/module.f.d.ts +1 -1
- package/djs/module.f.js +0 -1
- package/djs/parser/module.f.d.ts +1 -1
- package/djs/parser/module.f.js +0 -2
- package/djs/serializer/module.f.d.ts +2 -2
- package/djs/serializer/module.f.js +0 -2
- package/djs/tokenizer/module.f.js +0 -1
- package/fsc/test.f.js +0 -1
- package/html/module.f.d.ts +1 -1
- package/html/module.f.js +15 -11
- package/html/test.f.js +7 -7
- package/js/tokenizer/module.f.d.ts +2 -2
- package/js/tokenizer/module.f.js +1 -2
- package/json/parser/module.f.d.ts +2 -2
- package/json/parser/module.f.js +0 -3
- package/json/serializer/module.f.js +0 -2
- package/json/tokenizer/module.f.js +0 -1
- package/nanvm-lib/tests/test.f.d.ts +28 -0
- package/nanvm-lib/tests/test.f.js +45 -0
- package/package.json +1 -1
- package/text/ascii/module.f.d.ts +1 -1
- package/text/ascii/module.f.js +2 -3
- package/text/ascii/test.f.js +2 -4
- package/text/module.f.d.ts +18 -3
- package/text/module.f.js +22 -6
- package/text/sgr/module.f.js +1 -1
- package/text/test.f.d.ts +4 -1
- package/text/test.f.js +24 -16
- package/text/utf16/module.f.d.ts +5 -6
- package/text/utf16/module.f.js +9 -10
- package/text/utf16/test.f.js +29 -30
- package/text/utf8/module.f.d.ts +8 -5
- package/text/utf8/module.f.js +3 -5
- package/text/utf8/test.f.js +34 -35
- package/types/array/module.f.d.ts +12 -9
- package/types/array/module.f.js +10 -11
- package/types/array/test.f.d.ts +1 -0
- package/types/array/test.f.js +18 -17
- package/types/bigfloat/module.f.d.ts +1 -1
- package/types/bigfloat/module.f.js +7 -8
- package/types/bigfloat/test.f.js +1 -2
- package/types/bigint/module.f.d.ts +20 -11
- package/types/bigint/module.f.js +19 -20
- package/types/bigint/test.f.d.ts +1 -0
- package/types/bigint/test.f.js +7 -2
- package/types/bit_vec/module.f.d.ts +103 -83
- package/types/bit_vec/module.f.js +68 -110
- package/types/bit_vec/test.f.d.ts +20 -8
- package/types/bit_vec/test.f.js +110 -117
- package/types/btree/find/test.f.js +3 -4
- package/types/btree/module.f.d.ts +3 -3
- package/types/btree/module.f.js +2 -5
- package/types/btree/remove/test.f.js +2 -3
- package/types/btree/set/test.f.js +3 -6
- package/types/btree/test.f.js +0 -1
- package/types/btree/types/module.f.d.ts +3 -3
- package/types/byte_set/module.f.d.ts +2 -2
- package/types/byte_set/module.f.js +0 -2
- package/types/function/compare/module.f.d.ts +1 -1
- package/types/function/compare/module.f.js +0 -1
- package/types/function/compare/test.f.js +1 -2
- package/types/function/module.f.d.ts +1 -1
- package/types/function/module.f.js +1 -1
- package/types/function/operator/module.f.d.ts +2 -3
- package/types/function/operator/module.f.js +5 -5
- package/types/function/test.f.js +1 -2
- package/types/list/module.f.d.ts +1 -1
- package/types/list/module.f.js +9 -9
- package/types/list/test.f.js +2 -4
- package/types/map/module.f.d.ts +6 -6
- package/types/map/module.f.js +6 -15
- package/types/map/test.f.js +1 -2
- package/types/monoid/module.f.d.ts +73 -0
- package/types/monoid/module.f.js +42 -0
- package/types/monoid/test.f.d.ts +5 -0
- package/types/monoid/test.f.js +27 -0
- package/types/nibble_set/module.f.d.ts +2 -3
- package/types/nibble_set/test.f.js +1 -2
- package/types/number/test.f.js +1 -2
- package/types/object/module.f.d.ts +5 -5
- package/types/object/module.f.js +2 -4
- package/types/range_map/module.f.d.ts +4 -4
- package/types/range_map/module.f.js +3 -9
- package/types/result/module.f.d.ts +2 -3
- package/types/sorted_list/module.f.d.ts +6 -6
- package/types/sorted_list/module.f.js +2 -6
- package/types/sorted_list/test.f.js +4 -9
- package/types/sorted_set/module.f.d.ts +1 -1
- package/types/sorted_set/module.f.js +2 -5
- package/types/sorted_set/test.f.js +4 -9
- package/types/string/module.f.d.ts +3 -3
- package/types/string/module.f.js +1 -2
- package/types/string/test.f.js +2 -4
- package/types/string_set/module.f.d.ts +1 -1
- package/types/string_set/module.f.js +5 -11
package/dev/test.f.js
CHANGED
package/djs/module.f.d.ts
CHANGED
package/djs/module.f.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as list from "../types/list/module.f.js";
|
|
|
2
2
|
const { flat, map } = list;
|
|
3
3
|
import * as string from "../types/string/module.f.js";
|
|
4
4
|
const { concat } = string;
|
|
5
|
-
import * as O from "../types/object/module.f.js";
|
|
6
5
|
import * as f from "../types/function/module.f.js";
|
|
7
6
|
const { compose, fn } = f;
|
|
8
7
|
const { entries } = Object;
|
package/djs/parser/module.f.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as result from '../../types/result/module.f.ts';
|
|
2
2
|
import { type List } from '../../types/list/module.f.ts';
|
|
3
|
-
import * as tokenizerT from '../tokenizer/module.f.ts';
|
|
3
|
+
import type * as tokenizerT from '../tokenizer/module.f.ts';
|
|
4
4
|
export type DjsModule = [readonly string[], readonly DjsConst[]];
|
|
5
5
|
export type DjsConst = boolean | string | number | null | bigint | undefined | DjsModuleRef | DjsArray | DjsObject;
|
|
6
6
|
type DjsModuleRef = ['aref' | 'cref', number];
|
package/djs/parser/module.f.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as result from "../../types/result/module.f.js";
|
|
2
2
|
import { fold, first, drop, toArray, length, concat } from "../../types/list/module.f.js";
|
|
3
|
-
import * as Operator from "../../types/function/operator/module.f.js";
|
|
4
|
-
import * as tokenizerT from "../tokenizer/module.f.js";
|
|
5
3
|
import { setReplace, at } from "../../types/map/module.f.js";
|
|
6
4
|
import * as o from "../../types/object/module.f.js";
|
|
7
5
|
const { fromMap } = o;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as list from '../../types/list/module.f.ts';
|
|
2
|
-
import * as O from '../../types/object/module.f.ts';
|
|
3
|
-
import * as DjsParser from '../parser/module.f.ts';
|
|
2
|
+
import type * as O from '../../types/object/module.f.ts';
|
|
3
|
+
import type * as DjsParser from '../parser/module.f.ts';
|
|
4
4
|
export declare const undefinedSerialize: string[];
|
|
5
5
|
type Entry = O.Entry<DjsParser.DjsConst>;
|
|
6
6
|
type Entries = list.List<Entry>;
|
|
@@ -2,7 +2,6 @@ import * as list from "../../types/list/module.f.js";
|
|
|
2
2
|
const { flat, map, entries: listEntries, concat: listConcat, flatMap } = list;
|
|
3
3
|
import * as string from "../../types/string/module.f.js";
|
|
4
4
|
const { concat } = string;
|
|
5
|
-
import * as O from "../../types/object/module.f.js";
|
|
6
5
|
import * as f from "../../types/function/module.f.js";
|
|
7
6
|
const { compose, fn } = f;
|
|
8
7
|
const { entries } = Object;
|
|
@@ -10,7 +9,6 @@ import * as bi from "../../types/bigint/module.f.js";
|
|
|
10
9
|
const { serialize: bigintSerialize } = bi;
|
|
11
10
|
import * as j from "../../json/serializer/module.f.js";
|
|
12
11
|
const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = j;
|
|
13
|
-
import * as DjsParser from "../parser/module.f.js";
|
|
14
12
|
const colon = [':'];
|
|
15
13
|
export const undefinedSerialize = ['undefined'];
|
|
16
14
|
const djsConstSerialize = sort => {
|
package/fsc/test.f.js
CHANGED
package/html/module.f.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type Attributes = {
|
|
|
7
7
|
readonly [k in string]: string;
|
|
8
8
|
};
|
|
9
9
|
export type Node = Element | string;
|
|
10
|
-
export declare const element: (
|
|
10
|
+
export declare const element: (e: Element) => List<string>;
|
|
11
11
|
export declare const html: (_: Element) => List<string>;
|
|
12
12
|
export declare const htmlToString: (_: Element) => string;
|
|
13
13
|
export {};
|
package/html/module.f.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { map, flatMap, flat, concat as listConcat } from "../types/list/module.f.js";
|
|
2
2
|
import { concat as stringConcat } from "../types/string/module.f.js";
|
|
3
|
-
import * as O from "../types/object/module.f.js";
|
|
4
3
|
import { compose } from "../types/function/module.f.js";
|
|
5
4
|
import * as utf16 from "../text/utf16/module.f.js";
|
|
6
5
|
const { stringToList } = utf16;
|
|
@@ -27,11 +26,10 @@ const voidTagList = [
|
|
|
27
26
|
'track',
|
|
28
27
|
'wbr',
|
|
29
28
|
];
|
|
30
|
-
const isVoid = tag => voidTagList.includes(tag);
|
|
31
29
|
/**
|
|
32
30
|
* https://stackoverflow.com/questions/7381974/which-characters-need-to-be-escaped-in-html
|
|
33
31
|
*/
|
|
34
|
-
const escapeCharCode = code => {
|
|
32
|
+
const escapeCharCode = (code) => {
|
|
35
33
|
switch (code) {
|
|
36
34
|
case 0x22: return '"';
|
|
37
35
|
case 0x26: return '&';
|
|
@@ -41,18 +39,24 @@ const escapeCharCode = code => {
|
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
const escape = compose(stringToList)(map(escapeCharCode));
|
|
44
|
-
const node = n => typeof n === 'string' ? escape(n) : element(n);
|
|
42
|
+
const node = (n) => typeof n === 'string' ? escape(n) : element(n);
|
|
45
43
|
const nodes = flatMap(node);
|
|
46
44
|
const attribute = ([name, value]) => flat([[' ', name, '="'], escape(value), ['"']]);
|
|
47
45
|
const attributes = compose(entries)(flatMap(attribute));
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const parseElement = (e) => {
|
|
47
|
+
const [tag, item1, ...list] = e;
|
|
48
|
+
return item1 === undefined ?
|
|
49
|
+
[tag, {}, []] :
|
|
50
|
+
typeof item1 === 'object' && !(item1 instanceof Array) ?
|
|
51
|
+
[tag, item1, list] :
|
|
52
|
+
[tag, {}, [item1, ...list]];
|
|
52
53
|
};
|
|
53
|
-
export const element = e => {
|
|
54
|
-
const [
|
|
55
|
-
|
|
54
|
+
export const element = (e) => {
|
|
55
|
+
const [tag, a, n] = parseElement(e);
|
|
56
|
+
const open = flat([[`<`, tag], attributes(a), [`>`]]);
|
|
57
|
+
return voidTagList.includes(tag) ?
|
|
58
|
+
open :
|
|
59
|
+
flat([open, nodes(n), ['</', tag, '>']]);
|
|
56
60
|
};
|
|
57
61
|
export const html = compose(element)(listConcat(['<!DOCTYPE html>']));
|
|
58
62
|
export const htmlToString = compose(html)(stringConcat);
|
package/html/test.f.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { htmlToString } from "./module.f.js";
|
|
2
2
|
export default {
|
|
3
3
|
empty: () => {
|
|
4
|
-
const r =
|
|
4
|
+
const r = htmlToString(['html']);
|
|
5
5
|
if (r !== '<!DOCTYPE html><html></html>') {
|
|
6
6
|
throw `empty: ${r}`;
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
9
|
empty2: () => {
|
|
10
|
-
const r =
|
|
10
|
+
const r = htmlToString(['html']);
|
|
11
11
|
if (r !== '<!DOCTYPE html><html></html>') {
|
|
12
12
|
throw r;
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
void: () => {
|
|
16
|
-
const r =
|
|
16
|
+
const r = htmlToString(['area']);
|
|
17
17
|
if (r !== '<!DOCTYPE html><area>') {
|
|
18
18
|
throw r;
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
some: () => {
|
|
22
22
|
const x = ['div', {}, '<div>&</div>', ['a', { href: 'hello"' }]];
|
|
23
|
-
const s =
|
|
23
|
+
const s = htmlToString(x);
|
|
24
24
|
if (s !== '<!DOCTYPE html><div><div>&amp;</div><a href="hello""></a></div>') {
|
|
25
25
|
throw s;
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
some2: () => {
|
|
29
29
|
const x = ['div', '<div>&</div>', ['a', { href: 'hello"' }]];
|
|
30
|
-
const s =
|
|
30
|
+
const s = htmlToString(x);
|
|
31
31
|
if (s !== '<!DOCTYPE html><div><div>&amp;</div><a href="hello""></a></div>') {
|
|
32
32
|
throw s;
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
someVoid: () => {
|
|
36
36
|
const x = ['div', ['br', { id: '5' }], '<div>&</div>', ['a', { href: 'hello"' }]];
|
|
37
|
-
const s =
|
|
37
|
+
const s = htmlToString(x);
|
|
38
38
|
if (s !== '<!DOCTYPE html><div><br id="5"><div>&amp;</div><a href="hello""></a></div>') {
|
|
39
39
|
throw s;
|
|
40
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as list from '../../types/list/module.f.ts';
|
|
2
|
-
import * as bigfloatT from '../../types/bigfloat/module.f.ts';
|
|
2
|
+
import type * as bigfloatT from '../../types/bigfloat/module.f.ts';
|
|
3
3
|
export type StringToken = {
|
|
4
4
|
readonly kind: 'string';
|
|
5
5
|
readonly value: string;
|
|
@@ -81,6 +81,6 @@ export type CommentToken = {
|
|
|
81
81
|
};
|
|
82
82
|
export type JsToken = KeywordToken | TrueToken | FalseToken | NullToken | WhitespaceToken | NewLineToken | StringToken | NumberToken | ErrorToken | IdToken | BigIntToken | UndefinedToken | OperatorToken | CommentToken;
|
|
83
83
|
type ErrorMessage = '" are missing' | 'unescaped character' | 'invalid hex value' | 'unexpected character' | 'invalid number' | 'invalid token' | '*\/ expected' | 'unterminated string literal' | 'eof';
|
|
84
|
-
export declare const isKeywordToken: (token: JsToken) =>
|
|
84
|
+
export declare const isKeywordToken: (token: JsToken) => boolean;
|
|
85
85
|
export declare const tokenize: (input: list.List<number>) => list.List<JsToken>;
|
|
86
86
|
export {};
|
package/js/tokenizer/module.f.js
CHANGED
|
@@ -7,7 +7,6 @@ const { at } = map;
|
|
|
7
7
|
import * as _range from "../../types/range/module.f.js";
|
|
8
8
|
const { one } = _range;
|
|
9
9
|
const { empty, stateScan, flat, toArray, reduce: listReduce, scan } = list;
|
|
10
|
-
import * as bigfloatT from "../../types/bigfloat/module.f.js";
|
|
11
10
|
const { fromCharCode } = String;
|
|
12
11
|
import * as ascii from "../../text/ascii/module.f.js";
|
|
13
12
|
const { range } = ascii;
|
|
@@ -486,8 +485,8 @@ const tokenizeEofOp = state => {
|
|
|
486
485
|
case 'e':
|
|
487
486
|
case 'e+':
|
|
488
487
|
case 'e-': return [[{ kind: 'error', message: 'invalid number' }], { kind: 'eof', }];
|
|
489
|
-
default: return [[bufferToNumberToken(state)], { kind: 'eof' }];
|
|
490
488
|
}
|
|
489
|
+
return [[bufferToNumberToken(state)], { kind: 'eof' }];
|
|
491
490
|
case 'op': return [[getOperatorToken(state.value)], { kind: 'eof' }];
|
|
492
491
|
case '//': return [[{ kind: '//', value: state.value }], { kind: 'eof' }];
|
|
493
492
|
case '/*':
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as result from '../../types/result/module.f.ts';
|
|
2
2
|
import * as list from '../../types/list/module.f.ts';
|
|
3
|
-
import * as Tokenizer from '../tokenizer/module.f.ts';
|
|
4
|
-
import * as Json from '../module.f.ts';
|
|
3
|
+
import type * as Tokenizer from '../tokenizer/module.f.ts';
|
|
4
|
+
import type * as Json from '../module.f.ts';
|
|
5
5
|
export declare const parse: (tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>;
|
package/json/parser/module.f.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import * as result from "../../types/result/module.f.js";
|
|
2
2
|
import * as list from "../../types/list/module.f.js";
|
|
3
3
|
const { fold, first, drop, toArray } = list;
|
|
4
|
-
import * as Operator from "../../types/function/operator/module.f.js";
|
|
5
|
-
import * as Tokenizer from "../tokenizer/module.f.js";
|
|
6
4
|
import * as map from "../../types/map/module.f.js";
|
|
7
5
|
const { setReplace } = map;
|
|
8
|
-
import * as Json from "../module.f.js";
|
|
9
6
|
import * as o from "../../types/object/module.f.js";
|
|
10
7
|
const { fromMap } = o;
|
|
11
8
|
const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key });
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as list from "../../types/list/module.f.js";
|
|
2
2
|
const { flat, reduce, empty } = list;
|
|
3
|
-
import * as O from "../../types/object/module.f.js";
|
|
4
|
-
import * as Operator from "../../types/function/operator/module.f.js";
|
|
5
3
|
const jsonStringify = JSON.stringify;
|
|
6
4
|
export const stringSerialize = input => [jsonStringify(input)];
|
|
7
5
|
export const numberSerialize = input => [jsonStringify(input)];
|
|
@@ -23,5 +23,33 @@ declare const _default: {
|
|
|
23
23
|
object: () => void;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
unary_plus: () => {
|
|
27
|
+
null: () => void;
|
|
28
|
+
undefined: () => void;
|
|
29
|
+
boolean: {
|
|
30
|
+
false: () => void;
|
|
31
|
+
true: () => void;
|
|
32
|
+
};
|
|
33
|
+
number: {
|
|
34
|
+
zero: () => void;
|
|
35
|
+
positive: () => void;
|
|
36
|
+
negative: () => void;
|
|
37
|
+
};
|
|
38
|
+
string: {
|
|
39
|
+
empty: () => void;
|
|
40
|
+
zero: () => void;
|
|
41
|
+
positive: () => void;
|
|
42
|
+
nan: () => void;
|
|
43
|
+
};
|
|
44
|
+
array: {
|
|
45
|
+
empty: () => void;
|
|
46
|
+
single_number: () => void;
|
|
47
|
+
single_string: () => void;
|
|
48
|
+
multiple: () => void;
|
|
49
|
+
};
|
|
50
|
+
object: {
|
|
51
|
+
empty: () => void;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
26
54
|
};
|
|
27
55
|
export default _default;
|
|
@@ -25,6 +25,7 @@ export default {
|
|
|
25
25
|
},
|
|
26
26
|
nullish: () => {
|
|
27
27
|
n(false)(undefined);
|
|
28
|
+
n(false)(null);
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
number: {
|
|
@@ -80,5 +81,49 @@ export default {
|
|
|
80
81
|
n(o)({ '0': '0' });
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
},
|
|
85
|
+
unary_plus: () => {
|
|
86
|
+
const op = (n) => +n;
|
|
87
|
+
const nan = (n) => {
|
|
88
|
+
let result = op(n);
|
|
89
|
+
if (!Number.isNaN(result)) {
|
|
90
|
+
throw result;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
null: () => e(op(null))(0),
|
|
95
|
+
undefined: () => nan(undefined),
|
|
96
|
+
boolean: {
|
|
97
|
+
false: () => e(op(false))(0),
|
|
98
|
+
true: () => e(op(true))(1)
|
|
99
|
+
},
|
|
100
|
+
number: {
|
|
101
|
+
zero: () => e(op(0))(0),
|
|
102
|
+
positive: () => e(op(2.3))(2.3),
|
|
103
|
+
negative: () => e(op(-2.3))(-2.3)
|
|
104
|
+
},
|
|
105
|
+
string: {
|
|
106
|
+
empty: () => e(op(""))(0),
|
|
107
|
+
zero: () => e(op("0"))(0),
|
|
108
|
+
positive: () => e(op("2.3"))(2.3),
|
|
109
|
+
nan: () => nan("a")
|
|
110
|
+
},
|
|
111
|
+
// TODO: bigint - handle TypeError exception for bigint. The test below (that follows
|
|
112
|
+
// current Rust implementation) is incorrect.
|
|
113
|
+
// bigint: {
|
|
114
|
+
// nan: () => u_p_nan(0n)
|
|
115
|
+
// }
|
|
116
|
+
array: {
|
|
117
|
+
empty: () => e(op([]))(0),
|
|
118
|
+
single_number: () => e(op([2.3]))(2.3),
|
|
119
|
+
single_string: () => e(op(["-2.3"]))(-2.3),
|
|
120
|
+
multiple: () => nan([null, null])
|
|
121
|
+
},
|
|
122
|
+
object: {
|
|
123
|
+
empty: () => nan({})
|
|
124
|
+
// TODO: test objects with valueOf, toString functions - when Rust logic is implemented
|
|
125
|
+
}
|
|
126
|
+
// TODO: test Function - when Rust logic is implemented
|
|
127
|
+
};
|
|
83
128
|
}
|
|
84
129
|
};
|
package/package.json
CHANGED
package/text/ascii/module.f.d.ts
CHANGED
package/text/ascii/module.f.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const at = s => i => {
|
|
1
|
+
const at = (s) => (i) => {
|
|
3
2
|
const r = s.codePointAt(i);
|
|
4
3
|
if (r === void 0) {
|
|
5
4
|
throw s;
|
|
@@ -7,7 +6,7 @@ const at = s => i => {
|
|
|
7
6
|
return r;
|
|
8
7
|
};
|
|
9
8
|
export const one = (s) => at(s)(0);
|
|
10
|
-
export const range = s => {
|
|
9
|
+
export const range = (s) => {
|
|
11
10
|
const f = at(s);
|
|
12
11
|
const f0 = f(0);
|
|
13
12
|
if (s.length === 1) {
|
package/text/ascii/test.f.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { range } = _;
|
|
1
|
+
import { range } from "./module.f.js";
|
|
3
2
|
import * as json from "../../json/module.f.js";
|
|
4
|
-
import
|
|
5
|
-
const { sort } = o;
|
|
3
|
+
import { sort } from "../../types/object/module.f.js";
|
|
6
4
|
const stringify = json.stringify(sort);
|
|
7
5
|
export default {
|
|
8
6
|
range: () => {
|
package/text/module.f.d.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Vec } from "../types/bit_vec/module.f.ts";
|
|
2
|
+
import { type List } from '../types/list/module.f.ts';
|
|
2
3
|
export type Block = ItemThunk | ItemArray;
|
|
3
4
|
type ItemArray = readonly Item[];
|
|
4
|
-
type ItemThunk = () =>
|
|
5
|
+
type ItemThunk = () => List<Item>;
|
|
5
6
|
export type Item = string | ItemArray | ItemThunk;
|
|
6
|
-
export declare const flat: (indent: string) => (text: Block) =>
|
|
7
|
+
export declare const flat: (indent: string) => (text: Block) => List<string>;
|
|
7
8
|
export declare const curly: (type: string) => (name: string) => (body: Block) => Block;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a string to an UTF-8, represented as an MSB first bit vector.
|
|
11
|
+
*
|
|
12
|
+
* @param s The input string to be converted.
|
|
13
|
+
* @returns The resulting UTF-8 bit vector, MSB first.
|
|
14
|
+
*/
|
|
15
|
+
export declare const msbUtf8: (s: string) => Vec;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a UTF-8 bit vector with MSB first encoding to a string.
|
|
18
|
+
*
|
|
19
|
+
* @param msbV - The UTF-8 bit vector with MSB first encoding.
|
|
20
|
+
* @returns The resulting string.
|
|
21
|
+
*/
|
|
22
|
+
export declare const msbUtf8ToString: (msbV: Vec) => string;
|
|
8
23
|
export {};
|
package/text/module.f.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { msb, u8List, u8ListToVec } from "../types/bit_vec/module.f.js";
|
|
2
|
+
import { flatMap } from "../types/list/module.f.js";
|
|
3
|
+
import * as utf8 from "./utf8/module.f.js";
|
|
4
|
+
import * as utf16 from "./utf16/module.f.js";
|
|
5
|
+
export const flat = (indent) => {
|
|
6
|
+
const f = (prefix) => {
|
|
7
|
+
const g = (item) => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item);
|
|
6
8
|
return flatMap(g);
|
|
7
9
|
};
|
|
8
10
|
return f('');
|
|
9
11
|
};
|
|
10
|
-
export const curly = type => name => body => [`${type} ${name}`, '{', body, '}'];
|
|
12
|
+
export const curly = (type) => (name) => (body) => [`${type} ${name}`, '{', body, '}'];
|
|
13
|
+
/**
|
|
14
|
+
* Converts a string to an UTF-8, represented as an MSB first bit vector.
|
|
15
|
+
*
|
|
16
|
+
* @param s The input string to be converted.
|
|
17
|
+
* @returns The resulting UTF-8 bit vector, MSB first.
|
|
18
|
+
*/
|
|
19
|
+
export const msbUtf8 = (s) => u8ListToVec(msb)(utf8.fromCodePointList(utf16.toCodePointList(utf16.stringToList(s))));
|
|
20
|
+
/**
|
|
21
|
+
* Converts a UTF-8 bit vector with MSB first encoding to a string.
|
|
22
|
+
*
|
|
23
|
+
* @param msbV - The UTF-8 bit vector with MSB first encoding.
|
|
24
|
+
* @returns The resulting string.
|
|
25
|
+
*/
|
|
26
|
+
export const msbUtf8ToString = (msbV) => utf16.listToString(utf16.fromCodePointList(utf8.toCodePointList(u8List(msb)(msbV))));
|
package/text/sgr/module.f.js
CHANGED
package/text/test.f.d.ts
CHANGED
package/text/test.f.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { flat, msbUtf8, msbUtf8ToString } from "./module.f.js";
|
|
2
|
+
import { join } from "../types/string/module.f.js";
|
|
3
|
+
export default {
|
|
4
|
+
block: () => {
|
|
5
|
+
const text = [
|
|
6
|
+
'a',
|
|
7
|
+
'b',
|
|
8
|
+
() => [
|
|
9
|
+
'c',
|
|
10
|
+
() => ['d'],
|
|
11
|
+
],
|
|
12
|
+
'e',
|
|
13
|
+
];
|
|
14
|
+
const result = join('\n')(flat(':')(text));
|
|
15
|
+
if (result !== 'a\nb\n:c\n::d\ne') {
|
|
16
|
+
throw result;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
encoding: () => {
|
|
20
|
+
const v = msbUtf8('Hello world!');
|
|
21
|
+
const r = msbUtf8ToString(v);
|
|
22
|
+
if (r !== 'Hello world!') {
|
|
23
|
+
throw r;
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
};
|
package/text/utf16/module.f.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type List, type Thunk } from '../../types/list/module.f.ts';
|
|
2
|
-
type
|
|
3
|
-
type
|
|
2
|
+
type U16 = number;
|
|
3
|
+
type I32 = number;
|
|
4
4
|
export declare const fromCodePointList: (input: List<number>) => Thunk<number>;
|
|
5
|
-
declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const listToString: (input: List<u16>) => string;
|
|
5
|
+
export declare const toCodePointList: (input: List<U16>) => List<I32>;
|
|
6
|
+
export declare const stringToList: (s: string) => List<U16>;
|
|
7
|
+
export declare const listToString: (input: List<U16>) => string;
|
|
9
8
|
export {};
|
package/text/utf16/module.f.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { map, flat, stateScan, reduce, flatMap, empty, } from "../../types/list/module.f.js";
|
|
2
|
-
import
|
|
2
|
+
import { concat } from "../../types/function/operator/module.f.js";
|
|
3
3
|
import { contains } from "../../types/range/module.f.js";
|
|
4
|
-
import
|
|
5
|
-
const { fn } = f;
|
|
4
|
+
import { fn } from "../../types/function/module.f.js";
|
|
6
5
|
const lowBmp = contains([0x0000, 0xd7ff]);
|
|
7
6
|
const highBmp = contains([0xe000, 0xffff]);
|
|
8
|
-
const isBmpCodePoint = codePoint => lowBmp(codePoint) || highBmp(codePoint);
|
|
7
|
+
const isBmpCodePoint = (codePoint) => lowBmp(codePoint) || highBmp(codePoint);
|
|
9
8
|
const isHighSurrogate = contains([0xd800, 0xdbff]);
|
|
10
9
|
const isLowSurrogate = contains([0xdc00, 0xdfff]);
|
|
11
10
|
const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000;
|
|
12
11
|
const isSupplementaryPlane = contains([0x01_0000, 0x10_ffff]);
|
|
13
|
-
const codePointToUtf16 = codePoint => {
|
|
12
|
+
const codePointToUtf16 = (codePoint) => {
|
|
14
13
|
if (isBmpCodePoint(codePoint)) {
|
|
15
14
|
return [codePoint];
|
|
16
15
|
}
|
|
@@ -50,17 +49,17 @@ const utf16ByteToCodePointOp = state => word => {
|
|
|
50
49
|
}
|
|
51
50
|
return [[state | errorMask, word | errorMask], null];
|
|
52
51
|
};
|
|
53
|
-
const utf16EofToCodePointOp = state => [state === null ? empty : [state | errorMask], null];
|
|
52
|
+
const utf16EofToCodePointOp = (state) => [state === null ? empty : [state | errorMask], null];
|
|
54
53
|
const utf16ByteOrEofToCodePointOp = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input);
|
|
55
54
|
const eofList = [null];
|
|
56
|
-
export const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])));
|
|
57
|
-
export const stringToList = s => {
|
|
58
|
-
const at = i => {
|
|
55
|
+
export const toCodePointList = (input) => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])));
|
|
56
|
+
export const stringToList = (s) => {
|
|
57
|
+
const at = (i) => {
|
|
59
58
|
const first = s.charCodeAt(i);
|
|
60
59
|
return isNaN(first) ? empty : { first, tail: () => at(i + 1) };
|
|
61
60
|
};
|
|
62
61
|
return at(0);
|
|
63
62
|
};
|
|
64
63
|
export const listToString = fn(map(String.fromCharCode))
|
|
65
|
-
.then(reduce(
|
|
64
|
+
.then(reduce(concat)(''))
|
|
66
65
|
.result;
|