functionalscript 0.9.2 → 0.10.0
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/test.f.d.ts +2 -0
- package/bnf/data/test.f.js +39 -2
- package/bnf/module.f.d.ts +3 -2
- package/bnf/module.f.js +5 -4
- package/cas/module.f.d.ts +5 -0
- package/cas/module.f.js +5 -0
- package/ci/module.f.js +45 -35
- package/ci/module.js +3 -3
- package/crypto/hmac/test.f.js +1 -1
- package/crypto/sign/module.f.d.ts +5 -0
- package/crypto/sign/test.f.js +1 -1
- package/dev/index/module.js +2 -2
- package/dev/module.f.d.ts +5 -0
- package/dev/module.f.js +5 -0
- package/dev/tf/all.test.js +2 -2
- package/dev/tf/module.f.js +7 -2
- package/dev/version/module.f.js +5 -0
- package/djs/ast/module.f.d.ts +5 -0
- package/djs/module.f.d.ts +5 -0
- package/djs/parser/module.f.d.ts +5 -0
- package/djs/parser/module.f.js +5 -0
- package/djs/parser-new/module.f.js +6 -2
- package/djs/parser-new/test.f.js +2 -1
- package/djs/serializer/module.f.d.ts +5 -0
- package/djs/transpiler/module.f.d.ts +5 -0
- package/djs/transpiler/module.f.js +5 -0
- package/fjs/module.f.d.ts +5 -0
- package/fjs/module.f.js +5 -0
- package/fjs/module.js +2 -2
- package/fsc/module.f.js +5 -0
- package/fsm/module.f.d.ts +5 -0
- package/fsm/module.f.js +5 -0
- package/io/module.d.ts +3 -3
- package/io/module.f.d.ts +1 -1
- package/io/module.f.js +8 -1
- package/io/module.js +8 -7
- package/io/virtual/module.f.d.ts +5 -0
- package/json/parser/module.f.d.ts +5 -0
- package/json/parser/module.f.js +5 -0
- package/json/serializer/module.f.d.ts +5 -0
- package/json/serializer/module.f.js +5 -0
- package/json/tokenizer/module.f.js +5 -0
- package/package.json +1 -1
- package/path/module.f.d.ts +5 -0
- package/text/utf8/module.f.d.ts +1 -1
- package/types/asn.1/module.f.d.ts +62 -0
- package/types/asn.1/module.f.js +276 -0
- package/types/asn.1/test.f.d.ts +44 -0
- package/types/asn.1/test.f.js +312 -0
- package/types/base128/module.f.d.ts +20 -0
- package/types/base128/module.f.js +43 -0
- package/types/base128/test.f.d.ts +2 -0
- package/types/base128/test.f.js +26 -0
- package/types/bigfloat/module.f.js +5 -0
- package/types/bit_vec/module.f.d.ts +14 -3
- package/types/bit_vec/module.f.js +21 -2
- package/types/bit_vec/test.f.d.ts +1 -0
- package/types/bit_vec/test.f.js +28 -6
- package/types/btree/find/module.f.d.ts +5 -0
- package/types/btree/module.f.d.ts +5 -0
- package/types/btree/module.f.js +5 -0
- package/types/btree/remove/module.f.d.ts +5 -0
- package/types/btree/set/module.f.d.ts +5 -0
- package/types/btree/types/module.f.d.ts +5 -0
- package/types/byte_set/module.f.js +5 -0
- package/types/cbase32/module.f.d.ts +5 -0
- package/types/cbase32/module.f.js +5 -0
- package/types/effect/mock/module.f.d.ts +5 -0
- package/types/effect/module.f.d.ts +5 -0
- package/types/effect/node/module.f.d.ts +5 -1
- package/types/effect/node/module.f.js +1 -0
- package/types/effect/node/test.f.d.ts +1 -0
- package/types/effect/node/test.f.js +19 -1
- package/types/effect/node/virtual/module.f.d.ts +3 -0
- package/types/effect/node/virtual/module.f.js +10 -0
- package/types/function/compare/module.f.d.ts +5 -0
- package/types/function/operator/module.f.d.ts +5 -0
- package/types/list/module.f.js +5 -0
- package/types/map/module.f.js +5 -0
- package/types/nibble_set/module.f.d.ts +5 -0
- package/types/nominal/module.f.d.ts +5 -0
- package/types/nullable/module.f.d.ts +5 -0
- package/types/ordered_map/module.f.d.ts +5 -0
- package/types/range/module.f.d.ts +5 -0
- package/types/sorted_list/module.f.d.ts +5 -0
- package/website/module.f.js +5 -0
- package/website/module.js +3 -3
|
@@ -2,6 +2,10 @@ import type { Vec } from '../../bit_vec/module.f.ts';
|
|
|
2
2
|
import type { Result } from '../../result/module.f.ts';
|
|
3
3
|
import { type Do, type Effect, type ToAsyncOperationMap } from '../module.f.ts';
|
|
4
4
|
export type IoResult<T> = Result<T, unknown>;
|
|
5
|
+
export type Fetch = {
|
|
6
|
+
readonly fetch: readonly [string, IoResult<Vec>];
|
|
7
|
+
};
|
|
8
|
+
export declare const fetch: (url: string) => Do<Fetch, IoResult<Vec>>;
|
|
5
9
|
export type MakeDirectoryOptions = {
|
|
6
10
|
readonly recursive: true;
|
|
7
11
|
};
|
|
@@ -46,7 +50,7 @@ export type Log = {
|
|
|
46
50
|
};
|
|
47
51
|
export declare const log: (msg: string) => Do<Log, void>;
|
|
48
52
|
export type Console = Log & Error;
|
|
49
|
-
export type NodeOperations = Console & Fs;
|
|
53
|
+
export type NodeOperations = Fetch & Console & Fs;
|
|
50
54
|
export type NodeEffect<T> = Effect<NodeOperations, T>;
|
|
51
55
|
export type NodeOperationMap = ToAsyncOperationMap<NodeOperations>;
|
|
52
56
|
export type NodeProgram = (argv: readonly string[]) => NodeEffect<number>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { empty, isVec, uint, vec8 } from "../../bit_vec/module.f.js";
|
|
2
2
|
import { run } from "../mock/module.f.js";
|
|
3
|
-
import { mkdir, readdir, readFile, writeFile } from "./module.f.js";
|
|
3
|
+
import { fetch, mkdir, readdir, readFile, writeFile } from "./module.f.js";
|
|
4
4
|
import { emptyState, virtual } from "./virtual/module.f.js";
|
|
5
5
|
export default {
|
|
6
6
|
map: () => {
|
|
@@ -29,6 +29,24 @@ export default {
|
|
|
29
29
|
e = cont(['ok', vec8(0x15n)]);
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
fetch: () => {
|
|
33
|
+
const v = run(virtual);
|
|
34
|
+
const [_, [t, result]] = v({
|
|
35
|
+
...emptyState,
|
|
36
|
+
internet: {
|
|
37
|
+
'https://example.com/data': vec8(0x2an),
|
|
38
|
+
},
|
|
39
|
+
})(fetch('https://example.com/data'));
|
|
40
|
+
if (t === 'error') {
|
|
41
|
+
throw result;
|
|
42
|
+
}
|
|
43
|
+
if (!isVec(result)) {
|
|
44
|
+
throw result;
|
|
45
|
+
}
|
|
46
|
+
if (uint(result) !== 0x2an) {
|
|
47
|
+
throw result;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
32
50
|
mkdir: {
|
|
33
51
|
one: () => {
|
|
34
52
|
const v = run(virtual);
|
|
@@ -8,6 +8,9 @@ export type VirtualState = {
|
|
|
8
8
|
stdout: string;
|
|
9
9
|
stderr: string;
|
|
10
10
|
root: VirtualDir;
|
|
11
|
+
internet: {
|
|
12
|
+
readonly [url: string]: Vec;
|
|
13
|
+
};
|
|
11
14
|
};
|
|
12
15
|
export declare const emptyState: VirtualState;
|
|
13
16
|
export declare const virtual: MemOperationMap<NodeOperations, VirtualState>;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual Node-effect operations for filesystem and process tests.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { parse } from "../../../../path/module.f.js";
|
|
2
7
|
import { isVec } from "../../../bit_vec/module.f.js";
|
|
3
8
|
import { error, ok } from "../../../result/module.f.js";
|
|
@@ -5,6 +10,7 @@ export const emptyState = {
|
|
|
5
10
|
stdout: '',
|
|
6
11
|
stderr: '',
|
|
7
12
|
root: {},
|
|
13
|
+
internet: {},
|
|
8
14
|
};
|
|
9
15
|
const operation = (op) => {
|
|
10
16
|
const f = (dir, path) => {
|
|
@@ -91,6 +97,10 @@ const console = (name) => (state, payload) => [{ ...state, [name]: `${state[name
|
|
|
91
97
|
export const virtual = {
|
|
92
98
|
error: console('stderr'),
|
|
93
99
|
log: console('stdout'),
|
|
100
|
+
fetch: (state, url) => {
|
|
101
|
+
const result = state.internet[url];
|
|
102
|
+
return result === undefined ? [state, error('not found')] : [state, ok(result)];
|
|
103
|
+
},
|
|
94
104
|
mkdir: (state, [path, p]) => mkdir(p !== undefined)(state, path),
|
|
95
105
|
readFile,
|
|
96
106
|
readdir: (state, [path, { recursive }]) => readdir(path, recursive === true)(state, path),
|
package/types/list/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable list data structure utilities and combinators.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { identity, fn, compose } from "../function/module.f.js";
|
|
2
7
|
import { addition, logicalNot, strictEqual, stateScanToScan, foldToScan, reduceToScan, } from "../function/operator/module.f.js";
|
|
3
8
|
export const fromArrayLike = (array) => {
|
package/types/map/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for nullable (`null`/`undefined`) value handling.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import type { Option } from '../option/module.f.ts';
|
|
2
7
|
export type Nullable<T> = T | null;
|
|
3
8
|
export declare const map: <T, R>(f: (value: T) => R) => (value: Nullable<T>) => Nullable<R>;
|
package/website/module.f.js
CHANGED
package/website/module.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import run from "../io/module.js";
|
|
2
|
+
import app from "./module.f.js";
|
|
3
|
+
run(app);
|