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.
- package/README.md +5 -5
- 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/bnf/module.f.d.ts +6 -2
- package/bnf/module.f.js +8 -9
- package/cas/module.f.d.ts +18 -0
- package/cas/module.f.js +95 -0
- package/cas/test.f.d.ts +2 -0
- package/cas/test.f.js +1 -0
- package/ci/module.f.d.ts +3 -2
- package/ci/module.f.js +11 -9
- package/ci/module.js +3 -3
- package/crypto/sha2/module.f.js +0 -1
- package/dev/module.f.d.ts +1 -1
- package/dev/module.f.js +14 -6
- package/dev/version/module.f.d.ts +2 -11
- package/dev/version/module.f.js +17 -14
- package/dev/version/test.f.d.ts +3 -1
- package/dev/version/test.f.js +26 -10
- package/djs/module.f.d.ts +1 -1
- package/djs/module.f.js +4 -4
- package/djs/parser-new/module.f.d.ts +3 -0
- package/djs/parser-new/module.f.js +150 -0
- package/djs/parser-new/test.f.d.ts +5 -0
- package/djs/parser-new/test.f.js +201 -0
- package/djs/serializer/module.f.js +6 -6
- 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 +25 -0
- package/{dev/tf → fjs}/module.js +1 -1
- package/fsc/module.f.js +1 -1
- package/io/module.d.ts +4 -0
- package/io/module.f.d.ts +14 -13
- package/io/module.f.js +21 -0
- package/io/module.js +7 -1
- 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/json/module.f.js +3 -3
- package/nanvm-lib/tests/test.f.d.ts +1 -1
- package/nanvm-lib/tests/test.f.js +114 -104
- package/package.json +6 -7
- package/path/module.f.d.ts +1 -0
- package/path/module.f.js +6 -3
- package/text/utf16/module.f.js +1 -1
- package/types/bit_vec/module.f.d.ts +1 -0
- package/types/bit_vec/module.f.js +1 -0
- 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/effect/mock/module.f.d.ts +5 -0
- package/types/effect/mock/module.f.js +14 -0
- package/types/effect/module.d.ts +2 -0
- package/types/effect/module.f.d.ts +23 -0
- package/types/effect/module.f.js +14 -0
- package/types/effect/module.js +11 -0
- package/types/effect/node/module.f.d.ts +52 -0
- package/types/effect/node/module.f.js +7 -0
- package/types/effect/node/test.f.d.ts +27 -0
- package/types/effect/node/test.f.js +259 -0
- package/types/effect/node/virtual/module.f.d.ts +13 -0
- package/types/effect/node/virtual/module.f.js +98 -0
- package/types/function/module.f.d.ts +1 -1
- package/types/function/module.f.js +1 -1
- package/types/function/test.f.js +1 -1
- package/types/list/module.f.d.ts +1 -0
- package/types/list/module.f.js +6 -6
- 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/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/website/module.d.ts +1 -0
- package/website/module.f.d.ts +3 -0
- package/website/module.f.js +9 -0
- package/website/module.js +3 -0
- package/fsc/module.d.ts +0 -2
- package/fsc/module.js +0 -4
- /package/{dev/tf → fjs}/module.d.ts +0 -0
|
@@ -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,25 @@
|
|
|
1
|
+
import { fromIo } from "../io/module.f.js";
|
|
2
|
+
import { compile } from "../djs/module.f.js";
|
|
3
|
+
import { main as testMain } from "../dev/tf/module.f.js";
|
|
4
|
+
import { main as casMain } from "../cas/module.f.js";
|
|
5
|
+
export const main = (io) => {
|
|
6
|
+
const { error } = io.console;
|
|
7
|
+
const [command, ...rest] = io.process.argv.slice(2);
|
|
8
|
+
switch (command) {
|
|
9
|
+
case 'test':
|
|
10
|
+
case 't':
|
|
11
|
+
return testMain(io);
|
|
12
|
+
case 'compile':
|
|
13
|
+
case 'c':
|
|
14
|
+
return compile(io)(rest);
|
|
15
|
+
case 'cas':
|
|
16
|
+
case 's':
|
|
17
|
+
return fromIo(io)(casMain(rest));
|
|
18
|
+
case undefined:
|
|
19
|
+
error('Error: command is required');
|
|
20
|
+
return Promise.resolve(1);
|
|
21
|
+
default:
|
|
22
|
+
error(`Error: Unknown command "${command}"`);
|
|
23
|
+
return Promise.resolve(1);
|
|
24
|
+
}
|
|
25
|
+
};
|
package/{dev/tf → fjs}/module.js
RENAMED
package/fsc/module.f.js
CHANGED
|
@@ -26,7 +26,7 @@ const reduce = (a) => {
|
|
|
26
26
|
return toArray(listReduce(merge)(empty)(a));
|
|
27
27
|
};
|
|
28
28
|
const codePointRange = fromRange(def);
|
|
29
|
-
const range = fn(asciiRange).
|
|
29
|
+
const range = fn(asciiRange).map(codePointRange).result;
|
|
30
30
|
const rangeSet = (l) => (f) => {
|
|
31
31
|
const codePointRange = fromRange(def);
|
|
32
32
|
const g = r => codePointRange(asciiRange(r))(f);
|
package/io/module.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type Io, type Run } from './module.f.ts';
|
|
2
|
+
import type { NodeProgram } from '../types/effect/node/module.f.ts';
|
|
2
3
|
export declare const io: Io;
|
|
3
4
|
declare const runDefault: Run;
|
|
4
5
|
export default runDefault;
|
|
6
|
+
export type NodeRun = (p: NodeProgram) => Promise<number>;
|
|
7
|
+
export declare const ioRun: (io: Io) => NodeRun;
|
|
8
|
+
export declare const nodeRun: NodeRun;
|
package/io/module.f.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type {
|
|
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';
|
|
1
|
+
import type { NodeEffect } from '../types/effect/node/module.f.ts';
|
|
2
|
+
import { type Result } from '../types/result/module.f.ts';
|
|
7
3
|
/**
|
|
8
4
|
* Represents a directory entry (file or directory) in the filesystem
|
|
9
5
|
* @see https://nodejs.org/api/fs.html#class-fsdirent
|
|
10
6
|
*/
|
|
11
7
|
export type Dirent = {
|
|
12
8
|
readonly name: string;
|
|
9
|
+
readonly parentPath: string;
|
|
13
10
|
readonly isDirectory: () => boolean;
|
|
14
11
|
readonly isFile: () => boolean;
|
|
15
12
|
};
|
|
@@ -20,21 +17,24 @@ export type RmOptions = {
|
|
|
20
17
|
export type MakeDirectoryOptions = {
|
|
21
18
|
readonly recursive?: boolean;
|
|
22
19
|
};
|
|
20
|
+
export type ReadDir = ((path: string, options: {
|
|
21
|
+
withFileTypes: true;
|
|
22
|
+
}) => Promise<Dirent[]>) & ((path: string, options: {
|
|
23
|
+
recursive?: true;
|
|
24
|
+
}) => Promise<readonly string[]>);
|
|
23
25
|
/**
|
|
24
26
|
* File system operations interface
|
|
25
27
|
* @see https://nodejs.org/api/fs.html
|
|
26
28
|
*/
|
|
27
29
|
export type Fs = {
|
|
28
30
|
readonly writeSync: (fd: number, s: string) => void;
|
|
29
|
-
readonly writeFileSync: (file: string, data:
|
|
30
|
-
readonly readFileSync: (path: string
|
|
31
|
+
readonly writeFileSync: (file: string, data: Uint8Array) => void;
|
|
32
|
+
readonly readFileSync: (path: string) => Uint8Array | null;
|
|
31
33
|
readonly existsSync: (path: string) => boolean;
|
|
32
34
|
readonly promises: {
|
|
33
|
-
readonly readFile: (path: string
|
|
34
|
-
readonly writeFile: (path: string, data:
|
|
35
|
-
readonly readdir:
|
|
36
|
-
withFileTypes: true;
|
|
37
|
-
}) => Promise<Dirent[]>;
|
|
35
|
+
readonly readFile: (path: string) => Promise<Uint8Array>;
|
|
36
|
+
readonly writeFile: (path: string, data: Uint8Array) => Promise<void>;
|
|
37
|
+
readonly readdir: ReadDir;
|
|
38
38
|
readonly rm: (path: string, options?: RmOptions) => Promise<void>;
|
|
39
39
|
readonly mkdir: (path: string, options?: MakeDirectoryOptions) => Promise<string | undefined>;
|
|
40
40
|
readonly copyFile: (src: string, dest: string) => Promise<void>;
|
|
@@ -104,3 +104,4 @@ export type Run = (f: App) => Promise<never>;
|
|
|
104
104
|
* Handles errors by exiting with code 1
|
|
105
105
|
*/
|
|
106
106
|
export declare const run: (io: Io) => Run;
|
|
107
|
+
export declare const fromIo: ({ console: { error, log }, fs: { promises: { mkdir, readFile, readdir, writeFile } }, }: Io) => <T>(effect: NodeEffect<T>) => Promise<T>;
|
package/io/module.f.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { normalize } from "../path/module.f.js";
|
|
2
|
+
import { asyncRun } from "../types/effect/module.js";
|
|
3
|
+
import { error, ok } from "../types/result/module.f.js";
|
|
4
|
+
import { fromVec, toVec } from "../types/uint8array/module.f.js";
|
|
1
5
|
/**
|
|
2
6
|
* Runs a function and exits the process with the returned code
|
|
3
7
|
* Handles errors by exiting with code 1
|
|
@@ -14,3 +18,20 @@ export const run = (io) => {
|
|
|
14
18
|
};
|
|
15
19
|
return async (f) => io.process.exit(code(await io.asyncTryCatch(() => f(io))));
|
|
16
20
|
};
|
|
21
|
+
const tc = async (f) => {
|
|
22
|
+
try {
|
|
23
|
+
return ok(await f());
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return error(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export const fromIo = ({ console: { error, log }, fs: { promises: { mkdir, readFile, readdir, writeFile } }, }) => asyncRun({
|
|
30
|
+
error: async (message) => error(message),
|
|
31
|
+
log: async (message) => log(message),
|
|
32
|
+
mkdir: param => tc(async () => { await mkdir(...param); }),
|
|
33
|
+
readFile: path => tc(async () => toVec(await readFile(path))),
|
|
34
|
+
readdir: ([path, r]) => tc(async () => (await readdir(path, { ...r, withFileTypes: true }))
|
|
35
|
+
.map(v => ({ name: v.name, parentPath: normalize(v.parentPath), isFile: v.isFile() }))),
|
|
36
|
+
writeFile: ([path, data]) => tc(() => writeFile(path, fromVec(data))),
|
|
37
|
+
});
|
package/io/module.js
CHANGED
|
@@ -6,7 +6,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
6
6
|
}
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
|
-
import { run } from "./module.f.js";
|
|
9
|
+
import { fromIo, run } from "./module.f.js";
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import process from "node:process";
|
|
12
12
|
import { concat } from "../path/module.f.js";
|
|
@@ -41,3 +41,9 @@ export const io = {
|
|
|
41
41
|
};
|
|
42
42
|
const runDefault = run(io);
|
|
43
43
|
export default runDefault;
|
|
44
|
+
export const ioRun = (io) => {
|
|
45
|
+
const r = fromIo(io);
|
|
46
|
+
const { argv } = io.process;
|
|
47
|
+
return p => r(p(argv));
|
|
48
|
+
};
|
|
49
|
+
export const nodeRun = ioRun(io);
|
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,
|
package/json/module.f.js
CHANGED
|
@@ -25,9 +25,9 @@ export const serialize = sort => {
|
|
|
25
25
|
]);
|
|
26
26
|
const mapPropertySerialize = map(propertySerialize);
|
|
27
27
|
const objectSerialize = fn(entries)
|
|
28
|
-
.
|
|
29
|
-
.
|
|
30
|
-
.
|
|
28
|
+
.map(sort)
|
|
29
|
+
.map(mapPropertySerialize)
|
|
30
|
+
.map(objectWrap)
|
|
31
31
|
.result;
|
|
32
32
|
const f = value => {
|
|
33
33
|
switch (typeof value) {
|
|
@@ -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.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -9,21 +9,20 @@
|
|
|
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",
|
|
19
|
+
"website": "node --experimental-strip-types ./website/module.ts"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"bin": {
|
|
25
|
-
"
|
|
26
|
-
"fst": "dev/tf/module.js"
|
|
25
|
+
"fjs": "fjs/module.js"
|
|
27
26
|
},
|
|
28
27
|
"repository": {
|
|
29
28
|
"type": "git",
|
package/path/module.f.d.ts
CHANGED
package/path/module.f.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fold, last, take, length, concat as listConcat } from "../types/list/module.f.js";
|
|
1
|
+
import { fold, last, take, length, concat as listConcat, toArray } from "../types/list/module.f.js";
|
|
2
2
|
import { join } from "../types/string/module.f.js";
|
|
3
3
|
import { concat as stringConcat } from "../types/string/module.f.js";
|
|
4
4
|
const foldNormalizeOp = input => state => {
|
|
@@ -21,9 +21,12 @@ const foldNormalizeOp = input => state => {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
export const
|
|
24
|
+
export const parse = (path) => {
|
|
25
25
|
const split = path.replaceAll('\\', '/').split('/');
|
|
26
|
-
|
|
26
|
+
return toArray(fold(foldNormalizeOp)([])(split));
|
|
27
|
+
};
|
|
28
|
+
export const normalize = path => {
|
|
29
|
+
const foldResult = parse(path);
|
|
27
30
|
return join('/')(foldResult);
|
|
28
31
|
};
|
|
29
32
|
export const concat = a => b => {
|
package/text/utf16/module.f.js
CHANGED
|
@@ -332,7 +332,7 @@ export const stringToCodePointList = (input) => toCodePointList(stringToList(inp
|
|
|
332
332
|
* ```
|
|
333
333
|
*/
|
|
334
334
|
export const listToString = fn(map(String.fromCharCode))
|
|
335
|
-
.
|
|
335
|
+
.map(reduce(concat)(''))
|
|
336
336
|
.result;
|
|
337
337
|
/**
|
|
338
338
|
* Converts a list of Unicode code points (CodePoint) to a string.
|