functionalscript 0.8.1 → 0.9.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/README.md +4 -4
- package/bnf/data/module.f.d.ts +10 -1
- package/bnf/data/module.f.js +58 -19
- package/bnf/data/test.f.d.ts +2 -0
- package/bnf/data/test.f.js +244 -3
- package/cas/module.f.d.ts +17 -0
- package/cas/module.f.js +77 -0
- package/cas/test.f.d.ts +2 -0
- package/cas/test.f.js +1 -0
- package/ci/module.f.js +8 -6
- package/crypto/secp/module.f.d.ts +10 -7
- package/crypto/secp/module.f.js +32 -12
- package/crypto/secp/test.f.js +4 -5
- package/crypto/sha2/module.f.js +0 -1
- package/crypto/sign/module.f.d.ts +17 -4
- package/crypto/sign/module.f.js +141 -47
- package/crypto/sign/test.f.d.ts +11 -1
- package/crypto/sign/test.f.js +631 -1
- package/dev/module.f.js +3 -2
- package/dev/version/module.f.d.ts +2 -2
- package/dev/version/module.f.js +4 -3
- package/dev/version/test.f.js +3 -2
- package/djs/module.f.d.ts +1 -1
- package/djs/module.f.js +4 -4
- package/djs/transpiler/module.f.js +3 -2
- package/djs/transpiler/test.f.js +12 -11
- package/fjs/module.f.d.ts +2 -0
- package/fjs/module.f.js +24 -0
- package/{dev/tf → fjs}/module.js +1 -1
- package/io/module.f.d.ts +4 -9
- package/io/virtual/module.f.d.ts +1 -1
- package/io/virtual/module.f.js +3 -3
- package/js/tokenizer/module.f.d.ts +1 -1
- package/js/tokenizer/module.f.js +0 -1
- package/nanvm-lib/tests/test.f.d.ts +1 -1
- package/nanvm-lib/tests/test.f.js +114 -104
- package/nanvm-lib/tests/vm/test.f.js +1 -1
- package/package.json +5 -7
- package/path/module.f.d.ts +3 -2
- package/types/btree/find/module.f.d.ts +7 -8
- package/types/btree/set/module.f.js +21 -0
- package/types/cbase32/module.f.d.ts +6 -0
- package/types/cbase32/module.f.js +71 -0
- package/types/cbase32/test.f.d.ts +7 -0
- package/types/cbase32/test.f.js +74 -0
- package/types/list/module.f.d.ts +1 -0
- package/types/list/module.f.js +2 -2
- package/types/nullable/module.f.d.ts +2 -0
- package/types/nullable/module.f.js +1 -0
- package/types/nullable/test.f.d.ts +1 -1
- package/types/nullable/test.f.js +23 -11
- package/types/option/module.f.d.ts +9 -0
- package/types/option/module.f.js +6 -0
- package/{crypto → types}/prime_field/module.f.d.ts +1 -1
- package/{crypto → types}/prime_field/module.f.js +1 -1
- package/types/uint8array/module.f.d.ts +11 -0
- package/types/uint8array/module.f.js +21 -0
- package/types/uint8array/test.f.d.ts +12 -0
- package/types/uint8array/test.f.js +58 -0
- package/crypto/rfc6979/module.f.d.ts +0 -15
- package/crypto/rfc6979/module.f.js +0 -98
- package/crypto/rfc6979/test.f.d.ts +0 -10
- package/crypto/rfc6979/test.f.js +0 -490
- package/fsc/module.d.ts +0 -2
- package/fsc/module.js +0 -4
- /package/{dev/tf → fjs}/module.d.ts +0 -0
- /package/{crypto → types}/prime_field/test.f.d.ts +0 -0
- /package/{crypto → types}/prime_field/test.f.js +0 -0
package/dev/version/module.f.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { decodeUtf8, encodeUtf8 } from "../../types/uint8array/module.f.js";
|
|
1
2
|
const { stringify, parse } = JSON;
|
|
2
3
|
export const getVersion = fs => readJson(fs)('package').version;
|
|
3
4
|
const jsonFile = (jsonFile) => `${jsonFile}.json`;
|
|
4
|
-
const readJson = fs => name => parse(fs.readFileSync(jsonFile(name)
|
|
5
|
+
const readJson = fs => name => parse(decodeUtf8(fs.readFileSync(jsonFile(name))));
|
|
5
6
|
export const updateVersion = ({ fs }) => {
|
|
6
7
|
const f = (name) => {
|
|
7
|
-
return fs.writeFileSync(jsonFile(name), stringify({
|
|
8
|
+
return fs.writeFileSync(jsonFile(name), encodeUtf8(stringify({
|
|
8
9
|
...readJson(fs)(name),
|
|
9
10
|
version: getVersion(fs)
|
|
10
|
-
}, null, 2));
|
|
11
|
+
}, null, 2)));
|
|
11
12
|
};
|
|
12
13
|
return [
|
|
13
14
|
f('package'),
|
package/dev/version/test.f.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeUtf8, encodeUtf8 } from "../../types/uint8array/module.f.js";
|
|
1
2
|
import * as _ from "./module.f.js";
|
|
2
3
|
const version = '0.3.0';
|
|
3
4
|
const x = {
|
|
@@ -76,8 +77,8 @@ const e = '{\n' +
|
|
|
76
77
|
export default () => {
|
|
77
78
|
const node = {
|
|
78
79
|
fs: {
|
|
79
|
-
readFileSync: n => JSON.stringify(x[n]),
|
|
80
|
-
writeFileSync: (_, content) => content
|
|
80
|
+
readFileSync: n => encodeUtf8(JSON.stringify(x[n])),
|
|
81
|
+
writeFileSync: (_, content) => decodeUtf8(content)
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
const [n, d] = _.updateVersion(node);
|
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
|
|
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
|
-
|
|
5
|
-
|
|
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': {
|
|
@@ -8,6 +8,7 @@ import { stringToList } from "../../text/utf16/module.f.js";
|
|
|
8
8
|
import { concat as pathConcat } from "../../path/module.f.js";
|
|
9
9
|
import { parseFromTokens } from "../parser/module.f.js";
|
|
10
10
|
import { run } from "../ast/module.f.js";
|
|
11
|
+
import { decodeUtf8 } from "../../types/uint8array/module.f.js";
|
|
11
12
|
const mapDjs = context => path => {
|
|
12
13
|
const res = at(path)(context.complete);
|
|
13
14
|
if (res === null) {
|
|
@@ -30,11 +31,11 @@ const transpileWithImports = path => parseModuleResult => context => {
|
|
|
30
31
|
return { ...context, error: parseModuleResult[1] };
|
|
31
32
|
};
|
|
32
33
|
const parseModule = path => context => {
|
|
33
|
-
const content = context.fs.readFileSync(path
|
|
34
|
+
const content = context.fs.readFileSync(path);
|
|
34
35
|
if (content === null) {
|
|
35
36
|
return error({ message: 'file not found', metadata: null });
|
|
36
37
|
}
|
|
37
|
-
const tokens = tokenize(stringToList(content))(path);
|
|
38
|
+
const tokens = tokenize(stringToList(decodeUtf8(content)))(path);
|
|
38
39
|
return parseFromTokens(tokens);
|
|
39
40
|
};
|
|
40
41
|
const foldNextModuleOp = path => context => {
|
package/djs/transpiler/test.f.js
CHANGED
|
@@ -3,12 +3,13 @@ import { setReplace } from "../../types/ordered_map/module.f.js";
|
|
|
3
3
|
import { transpile } from "./module.f.js";
|
|
4
4
|
import { stringifyAsTree } from "../serializer/module.f.js";
|
|
5
5
|
import { createVirtualIo } from "../../io/virtual/module.f.js";
|
|
6
|
+
import { encodeUtf8 } from "../../types/uint8array/module.f.js";
|
|
6
7
|
const virtualFs = map => {
|
|
7
8
|
return createVirtualIo(map).fs;
|
|
8
9
|
};
|
|
9
10
|
export default {
|
|
10
11
|
parse: () => {
|
|
11
|
-
const map = setReplace('a')('export default 1')(null);
|
|
12
|
+
const map = setReplace('a')(encodeUtf8('export default 1'))(null);
|
|
12
13
|
const fs = virtualFs(map);
|
|
13
14
|
const result = transpile(fs)('a');
|
|
14
15
|
if (result[0] === 'error') {
|
|
@@ -20,8 +21,8 @@ export default {
|
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
parseWithSubModule: () => {
|
|
23
|
-
const map = setReplace('a/b')('import c from "c"\nexport default c')(null);
|
|
24
|
-
const map2 = setReplace('a/c')('export default 2')(map);
|
|
24
|
+
const map = setReplace('a/b')(encodeUtf8('import c from "c"\nexport default c'))(null);
|
|
25
|
+
const map2 = setReplace('a/c')(encodeUtf8('export default 2'))(map);
|
|
25
26
|
const fs = virtualFs(map2);
|
|
26
27
|
const result = transpile(fs)('a/b');
|
|
27
28
|
if (result[0] === 'error') {
|
|
@@ -33,10 +34,10 @@ export default {
|
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
parseWithSubModules: () => {
|
|
36
|
-
const map = setReplace('a')('import b from "b"\nimport c from "c"\nexport default [b,c,b]')(null);
|
|
37
|
-
const map2 = setReplace('b')('import d from "d"\nexport default [0,d]')(map);
|
|
38
|
-
const map3 = setReplace('c')('import d from "d"\nexport default [1,d]')(map2);
|
|
39
|
-
const map4 = setReplace('d')('export default 2')(map3);
|
|
37
|
+
const map = setReplace('a')(encodeUtf8('import b from "b"\nimport c from "c"\nexport default [b,c,b]'))(null);
|
|
38
|
+
const map2 = setReplace('b')(encodeUtf8('import d from "d"\nexport default [0,d]'))(map);
|
|
39
|
+
const map3 = setReplace('c')(encodeUtf8('import d from "d"\nexport default [1,d]'))(map2);
|
|
40
|
+
const map4 = setReplace('d')(encodeUtf8('export default 2'))(map3);
|
|
40
41
|
const fs = virtualFs(map4);
|
|
41
42
|
const result = transpile(fs)('a');
|
|
42
43
|
if (result[0] === 'error') {
|
|
@@ -48,7 +49,7 @@ export default {
|
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
51
|
parseWithFileNotFoundError: () => {
|
|
51
|
-
const map = setReplace('a')('import b from "b"\nexport default b')(null);
|
|
52
|
+
const map = setReplace('a')(encodeUtf8('import b from "b"\nexport default b'))(null);
|
|
52
53
|
const fs = virtualFs(map);
|
|
53
54
|
const result = transpile(fs)('a');
|
|
54
55
|
if (result[0] !== 'error') {
|
|
@@ -59,9 +60,9 @@ export default {
|
|
|
59
60
|
}
|
|
60
61
|
},
|
|
61
62
|
parseWithCycleError: () => {
|
|
62
|
-
const map = setReplace('a')('import b from "b"\nimport c from "c"\nexport default [b,c,b]')(null);
|
|
63
|
-
const map2 = setReplace('b')('import c from "c"\nexport default c')(map);
|
|
64
|
-
const map3 = setReplace('c')('import b from "b"\nexport default b')(map2);
|
|
63
|
+
const map = setReplace('a')(encodeUtf8('import b from "b"\nimport c from "c"\nexport default [b,c,b]'))(null);
|
|
64
|
+
const map2 = setReplace('b')(encodeUtf8('import c from "c"\nexport default c'))(map);
|
|
65
|
+
const map3 = setReplace('c')(encodeUtf8('import b from "b"\nexport default b'))(map2);
|
|
65
66
|
const fs = virtualFs(map3);
|
|
66
67
|
const result = transpile(fs)('a');
|
|
67
68
|
if (result[0] !== 'error') {
|
package/fjs/module.f.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { compile } from "../djs/module.f.js";
|
|
2
|
+
import { main as testMain } from "../dev/tf/module.f.js";
|
|
3
|
+
export const main = (io) => {
|
|
4
|
+
const { error } = io.console;
|
|
5
|
+
const [command, ...rest] = io.process.argv.slice(2);
|
|
6
|
+
switch (command) {
|
|
7
|
+
case 'test':
|
|
8
|
+
case 't':
|
|
9
|
+
return testMain(io);
|
|
10
|
+
case 'compile':
|
|
11
|
+
case 'c':
|
|
12
|
+
return compile(io)(rest);
|
|
13
|
+
case 'cas':
|
|
14
|
+
case 's':
|
|
15
|
+
error('cas command is not implemented yet');
|
|
16
|
+
return Promise.resolve(1);
|
|
17
|
+
case undefined:
|
|
18
|
+
error('Error: command is required');
|
|
19
|
+
return Promise.resolve(1);
|
|
20
|
+
default:
|
|
21
|
+
error(`Error: Unknown command "${command}"`);
|
|
22
|
+
return Promise.resolve(1);
|
|
23
|
+
}
|
|
24
|
+
};
|
package/{dev/tf → fjs}/module.js
RENAMED
package/io/module.f.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { Result } from '../types/result/module.f.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Standard Node.js buffer encoding type
|
|
4
|
-
* @see https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
|
|
5
|
-
*/
|
|
6
|
-
export type BufferEncoding = 'utf8';
|
|
7
2
|
/**
|
|
8
3
|
* Represents a directory entry (file or directory) in the filesystem
|
|
9
4
|
* @see https://nodejs.org/api/fs.html#class-fsdirent
|
|
@@ -26,12 +21,12 @@ export type MakeDirectoryOptions = {
|
|
|
26
21
|
*/
|
|
27
22
|
export type Fs = {
|
|
28
23
|
readonly writeSync: (fd: number, s: string) => void;
|
|
29
|
-
readonly writeFileSync: (file: string, data:
|
|
30
|
-
readonly readFileSync: (path: string
|
|
24
|
+
readonly writeFileSync: (file: string, data: Uint8Array) => void;
|
|
25
|
+
readonly readFileSync: (path: string) => Uint8Array | null;
|
|
31
26
|
readonly existsSync: (path: string) => boolean;
|
|
32
27
|
readonly promises: {
|
|
33
|
-
readonly readFile: (path: string
|
|
34
|
-
readonly writeFile: (path: string, data:
|
|
28
|
+
readonly readFile: (path: string) => Promise<Uint8Array>;
|
|
29
|
+
readonly writeFile: (path: string, data: Uint8Array) => Promise<void>;
|
|
35
30
|
readonly readdir: (path: string, options: {
|
|
36
31
|
withFileTypes: true;
|
|
37
32
|
}) => Promise<Dirent[]>;
|
package/io/virtual/module.f.d.ts
CHANGED
package/io/virtual/module.f.js
CHANGED
|
@@ -7,12 +7,12 @@ export const createVirtualIo = (files) => ({
|
|
|
7
7
|
fs: {
|
|
8
8
|
writeSync: (fd, s) => { },
|
|
9
9
|
writeFileSync: (_file, _data) => { },
|
|
10
|
-
readFileSync: (path
|
|
10
|
+
readFileSync: (path) => { return at(path)(files); },
|
|
11
11
|
existsSync: (path) => { return at(path)(files) !== null; },
|
|
12
12
|
promises: {
|
|
13
13
|
readdir: (_path) => Promise.resolve([]),
|
|
14
|
-
readFile: (_path
|
|
15
|
-
writeFile: (_path, _data
|
|
14
|
+
readFile: (_path) => Promise.resolve(new Uint8Array()),
|
|
15
|
+
writeFile: (_path, _data) => Promise.resolve(),
|
|
16
16
|
rm: (_path, _options) => Promise.resolve(),
|
|
17
17
|
mkdir: (_path, _options) => Promise.resolve(undefined),
|
|
18
18
|
copyFile: (_src, _dest) => Promise.resolve(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type List } from '../../types/list/module.f.ts';
|
|
2
|
-
import {
|
|
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;
|
package/js/tokenizer/module.f.js
CHANGED
|
@@ -3,7 +3,6 @@ import { merge, fromRange, get } from "../../types/range_map/module.f.js";
|
|
|
3
3
|
import { empty, stateScan, flat, toArray, reduce as listReduce, scan, map as listMap } from "../../types/list/module.f.js";
|
|
4
4
|
import { at, fromEntries } from "../../types/ordered_map/module.f.js";
|
|
5
5
|
import { one } from "../../types/range/module.f.js";
|
|
6
|
-
import {} from "../../types/bigfloat/module.f.js";
|
|
7
6
|
import { range,
|
|
8
7
|
//
|
|
9
8
|
backspace, ht, lf, ff, cr,
|
|
@@ -1,121 +1,131 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const { is } = Object;
|
|
2
|
+
const ois = (a) => (b) => {
|
|
3
|
+
if (is(a, b)) { }
|
|
3
4
|
else {
|
|
4
|
-
throw [a, '
|
|
5
|
+
throw [a, 'is', b];
|
|
5
6
|
}
|
|
6
7
|
};
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
else {
|
|
10
|
-
throw [a, '!==', b];
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const nan_res = (op) => (n) => {
|
|
8
|
+
const { isNaN } = Number;
|
|
9
|
+
const nanRes = (op) => (n) => {
|
|
14
10
|
const result = op(n);
|
|
15
|
-
if (!
|
|
11
|
+
if (!isNaN(result)) {
|
|
16
12
|
throw result;
|
|
17
13
|
}
|
|
18
14
|
};
|
|
19
15
|
export default {
|
|
20
|
-
eq: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
nullish: () => {
|
|
33
|
-
n(false)(undefined);
|
|
34
|
-
n(false)(null);
|
|
16
|
+
eq: () => {
|
|
17
|
+
const e = (a) => (b) => {
|
|
18
|
+
if (a === b) { }
|
|
19
|
+
else {
|
|
20
|
+
throw [a, '===', b];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const n = (a) => (b) => {
|
|
24
|
+
if (a !== b) { }
|
|
25
|
+
else {
|
|
26
|
+
throw [a, '!==', b];
|
|
35
27
|
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
e(
|
|
40
|
-
|
|
41
|
-
n(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
nullish: () => {
|
|
31
|
+
e(null)(null);
|
|
32
|
+
e(undefined)(undefined);
|
|
33
|
+
n(null)(undefined);
|
|
34
|
+
},
|
|
35
|
+
boolean: {
|
|
36
|
+
boolean: () => {
|
|
37
|
+
e(true)(true);
|
|
38
|
+
e(false)(false);
|
|
39
|
+
n(true)(false);
|
|
40
|
+
},
|
|
41
|
+
nullish: () => {
|
|
42
|
+
n(false)(undefined);
|
|
43
|
+
n(false)(null);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
},
|
|
46
|
+
number: {
|
|
47
|
+
number: () => {
|
|
48
|
+
e(2.3)(2.3);
|
|
49
|
+
n(2.3)(-5.4);
|
|
50
|
+
n(NaN)(NaN);
|
|
51
|
+
e(0)(-0);
|
|
52
|
+
if (!is(-0, -0)) {
|
|
53
|
+
throw -0;
|
|
54
|
+
}
|
|
55
|
+
if (is(0, -0)) {
|
|
56
|
+
throw -0;
|
|
57
|
+
}
|
|
58
|
+
e(Infinity)(Infinity);
|
|
59
|
+
e(-Infinity)(-Infinity);
|
|
60
|
+
n(Infinity)(-Infinity);
|
|
61
|
+
},
|
|
62
|
+
nullish: () => {
|
|
63
|
+
n(undefined)(NaN);
|
|
64
|
+
n(undefined)(0);
|
|
48
65
|
}
|
|
49
|
-
e(Infinity)(Infinity);
|
|
50
|
-
e(-Infinity)(-Infinity);
|
|
51
|
-
n(Infinity)(-Infinity);
|
|
52
66
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
object: () => {
|
|
85
|
-
const o = { '0': '0' };
|
|
86
|
-
e(o)(o);
|
|
87
|
-
n(o)({ '0': '0' });
|
|
67
|
+
string: {
|
|
68
|
+
string: () => {
|
|
69
|
+
e("hello")("hello");
|
|
70
|
+
n("hello")("world");
|
|
71
|
+
},
|
|
72
|
+
number: () => {
|
|
73
|
+
n(0)("0");
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
bigint: {
|
|
77
|
+
bigint: () => {
|
|
78
|
+
e(12n)(12n);
|
|
79
|
+
n(12n)(-12n);
|
|
80
|
+
n(12n)(13n);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
array: {
|
|
84
|
+
array: () => {
|
|
85
|
+
const a = [];
|
|
86
|
+
e(a)(a);
|
|
87
|
+
n([])([]);
|
|
88
|
+
const a0 = ['0'];
|
|
89
|
+
e(a0)(a0);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
object: {
|
|
93
|
+
object: () => {
|
|
94
|
+
const o = { '0': '0' };
|
|
95
|
+
e(o)(o);
|
|
96
|
+
n(o)({ '0': '0' });
|
|
97
|
+
}
|
|
88
98
|
}
|
|
89
|
-
}
|
|
99
|
+
};
|
|
90
100
|
},
|
|
91
101
|
unary_plus: () => {
|
|
92
102
|
const op = (n) => +n;
|
|
93
|
-
const nan =
|
|
103
|
+
const nan = nanRes(op);
|
|
94
104
|
return {
|
|
95
|
-
null: () =>
|
|
105
|
+
null: () => ois(op(null))(0),
|
|
96
106
|
undefined: () => nan(undefined),
|
|
97
107
|
boolean: {
|
|
98
|
-
false: () =>
|
|
99
|
-
true: () =>
|
|
108
|
+
false: () => ois(op(false))(0),
|
|
109
|
+
true: () => ois(op(true))(1)
|
|
100
110
|
},
|
|
101
111
|
number: {
|
|
102
|
-
zero: () =>
|
|
103
|
-
positive: () =>
|
|
104
|
-
negative: () =>
|
|
112
|
+
zero: () => ois(op(0))(0),
|
|
113
|
+
positive: () => ois(op(2.3))(2.3),
|
|
114
|
+
negative: () => ois(op(-2.3))(-2.3)
|
|
105
115
|
},
|
|
106
116
|
string: {
|
|
107
|
-
empty: () =>
|
|
108
|
-
zero: () =>
|
|
109
|
-
positive: () =>
|
|
117
|
+
empty: () => ois(op(""))(0),
|
|
118
|
+
zero: () => ois(op("0"))(0),
|
|
119
|
+
positive: () => ois(op("2.3"))(2.3),
|
|
110
120
|
nan: () => nan("a")
|
|
111
121
|
},
|
|
112
122
|
bigint: {
|
|
113
123
|
throw: () => op(0n),
|
|
114
124
|
},
|
|
115
125
|
array: {
|
|
116
|
-
empty: () =>
|
|
117
|
-
single_number: () =>
|
|
118
|
-
single_string: () =>
|
|
126
|
+
empty: () => ois(op([]))(0),
|
|
127
|
+
single_number: () => ois(op([2.3]))(2.3),
|
|
128
|
+
single_string: () => ois(op(["-2.3"]))(-2.3),
|
|
119
129
|
multiple: () => nan([null, null])
|
|
120
130
|
},
|
|
121
131
|
object: {
|
|
@@ -127,33 +137,33 @@ export default {
|
|
|
127
137
|
},
|
|
128
138
|
unary_minus: () => {
|
|
129
139
|
const op = (n) => -n;
|
|
130
|
-
const nan =
|
|
140
|
+
const nan = nanRes(op);
|
|
131
141
|
return {
|
|
132
|
-
null: () =>
|
|
142
|
+
null: () => ois(op(null))(-0),
|
|
133
143
|
undefined: () => nan(undefined),
|
|
134
144
|
boolean: {
|
|
135
|
-
false: () =>
|
|
136
|
-
true: () =>
|
|
145
|
+
false: () => ois(op(false))(-0),
|
|
146
|
+
true: () => ois(op(true))(-1)
|
|
137
147
|
},
|
|
138
148
|
number: {
|
|
139
|
-
zero: () =>
|
|
140
|
-
positive: () =>
|
|
141
|
-
negative: () =>
|
|
149
|
+
zero: () => ois(op(0))(-0),
|
|
150
|
+
positive: () => ois(op(2.3))(-2.3),
|
|
151
|
+
negative: () => ois(op(-2.3))(2.3)
|
|
142
152
|
},
|
|
143
153
|
string: {
|
|
144
|
-
empty: () =>
|
|
145
|
-
zero: () =>
|
|
146
|
-
positive: () =>
|
|
154
|
+
empty: () => ois(op(""))(-0),
|
|
155
|
+
zero: () => ois(op("0"))(-0),
|
|
156
|
+
positive: () => ois(op("2.3"))(-2.3),
|
|
147
157
|
nan: () => nan("a")
|
|
148
158
|
},
|
|
149
159
|
bigint: {
|
|
150
|
-
positive: () =>
|
|
151
|
-
negative: () =>
|
|
160
|
+
positive: () => ois(op(1n))(-1n),
|
|
161
|
+
negative: () => ois(op(-1n))(1n),
|
|
152
162
|
},
|
|
153
163
|
array: {
|
|
154
|
-
empty: () =>
|
|
155
|
-
single_number: () =>
|
|
156
|
-
single_string: () =>
|
|
164
|
+
empty: () => ois(op([]))(-0),
|
|
165
|
+
single_number: () => ois(op([2.3]))(-2.3),
|
|
166
|
+
single_string: () => ois(op(["-2.3"]))(2.3),
|
|
157
167
|
multiple: () => nan([null, null])
|
|
158
168
|
},
|
|
159
169
|
object: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -9,21 +9,19 @@
|
|
|
9
9
|
"description": "FunctionalScript is a purely functional subset of JavaScript",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepack": "tsc --NoEmit false",
|
|
12
|
-
"git-clean": "git clean -xf",
|
|
13
12
|
"test20": "npm run prepack && node --test",
|
|
14
13
|
"test": "tsc && node --test --experimental-strip-types --experimental-test-coverage --test-coverage-include=**/module.f.ts",
|
|
15
14
|
"index": "node ./dev/index/module.ts",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
15
|
+
"fst": "node ./fjs/module.ts t",
|
|
16
|
+
"fjs": "node ./fjs/module.ts",
|
|
18
17
|
"ci-update": "node ./ci/module.ts",
|
|
19
|
-
"update": "npm install && npm run index && npm run ci-update"
|
|
18
|
+
"update": "git clean -fdx && npm install && npm run index && npm run ci-update"
|
|
20
19
|
},
|
|
21
20
|
"engines": {
|
|
22
21
|
"node": ">=20"
|
|
23
22
|
},
|
|
24
23
|
"bin": {
|
|
25
|
-
"
|
|
26
|
-
"fst": "dev/tf/module.js"
|
|
24
|
+
"fjs": "fjs/module.js"
|
|
27
25
|
},
|
|
28
26
|
"repository": {
|
|
29
27
|
"type": "git",
|
package/path/module.f.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import type { Reduce, Unary } from "../types/function/operator/module.f.ts";
|
|
2
|
+
export declare const normalize: Unary<string, string>;
|
|
3
|
+
export declare const concat: Reduce<string>;
|
|
@@ -2,13 +2,13 @@ import type { Leaf1, Leaf2, Branch3, Branch5, TNode } from '../types/module.f.ts
|
|
|
2
2
|
import type { List } from '../../list/module.f.ts';
|
|
3
3
|
import { type Compare } from '../../function/compare/module.f.ts';
|
|
4
4
|
import type { Index3, Index5 } from "../../array/module.f.ts";
|
|
5
|
-
type FirstLeaf1<T> = readonly [Index3, Leaf1<T>];
|
|
6
|
-
type FirstBranch3<T> = readonly [1, Branch3<T>];
|
|
7
|
-
type FirstLeaf2<T> = readonly [Index5, Leaf2<T>];
|
|
8
|
-
type FirstBranch5<T> = readonly [1 | 3, Branch5<T>];
|
|
9
|
-
type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T>;
|
|
10
|
-
type PathItem3<T> = readonly [0 | 2, Branch3<T>];
|
|
11
|
-
type PathItem5<T> = readonly [0 | 2 | 4, Branch5<T>];
|
|
5
|
+
export type FirstLeaf1<T> = readonly [Index3, Leaf1<T>];
|
|
6
|
+
export type FirstBranch3<T> = readonly [1, Branch3<T>];
|
|
7
|
+
export type FirstLeaf2<T> = readonly [Index5, Leaf2<T>];
|
|
8
|
+
export type FirstBranch5<T> = readonly [1 | 3, Branch5<T>];
|
|
9
|
+
export type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T>;
|
|
10
|
+
export type PathItem3<T> = readonly [0 | 2, Branch3<T>];
|
|
11
|
+
export type PathItem5<T> = readonly [0 | 2 | 4, Branch5<T>];
|
|
12
12
|
export type PathItem<T> = PathItem3<T> | PathItem5<T>;
|
|
13
13
|
export type Path<T> = List<PathItem<T>>;
|
|
14
14
|
export type Result<T> = {
|
|
@@ -18,4 +18,3 @@ export type Result<T> = {
|
|
|
18
18
|
export declare const find: <T>(c: Compare<T>) => (node: TNode<T>) => Result<T>;
|
|
19
19
|
export declare const isFound: <T>([i]: First<T>) => boolean;
|
|
20
20
|
export declare const value: <T>([i, r]: First<T>) => T | null;
|
|
21
|
-
export {};
|