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.
Files changed (87) hide show
  1. package/bnf/data/test.f.d.ts +2 -0
  2. package/bnf/data/test.f.js +39 -2
  3. package/bnf/module.f.d.ts +3 -2
  4. package/bnf/module.f.js +5 -4
  5. package/cas/module.f.d.ts +5 -0
  6. package/cas/module.f.js +5 -0
  7. package/ci/module.f.js +45 -35
  8. package/ci/module.js +3 -3
  9. package/crypto/hmac/test.f.js +1 -1
  10. package/crypto/sign/module.f.d.ts +5 -0
  11. package/crypto/sign/test.f.js +1 -1
  12. package/dev/index/module.js +2 -2
  13. package/dev/module.f.d.ts +5 -0
  14. package/dev/module.f.js +5 -0
  15. package/dev/tf/all.test.js +2 -2
  16. package/dev/tf/module.f.js +7 -2
  17. package/dev/version/module.f.js +5 -0
  18. package/djs/ast/module.f.d.ts +5 -0
  19. package/djs/module.f.d.ts +5 -0
  20. package/djs/parser/module.f.d.ts +5 -0
  21. package/djs/parser/module.f.js +5 -0
  22. package/djs/parser-new/module.f.js +6 -2
  23. package/djs/parser-new/test.f.js +2 -1
  24. package/djs/serializer/module.f.d.ts +5 -0
  25. package/djs/transpiler/module.f.d.ts +5 -0
  26. package/djs/transpiler/module.f.js +5 -0
  27. package/fjs/module.f.d.ts +5 -0
  28. package/fjs/module.f.js +5 -0
  29. package/fjs/module.js +2 -2
  30. package/fsc/module.f.js +5 -0
  31. package/fsm/module.f.d.ts +5 -0
  32. package/fsm/module.f.js +5 -0
  33. package/io/module.d.ts +3 -3
  34. package/io/module.f.d.ts +1 -1
  35. package/io/module.f.js +8 -1
  36. package/io/module.js +8 -7
  37. package/io/virtual/module.f.d.ts +5 -0
  38. package/json/parser/module.f.d.ts +5 -0
  39. package/json/parser/module.f.js +5 -0
  40. package/json/serializer/module.f.d.ts +5 -0
  41. package/json/serializer/module.f.js +5 -0
  42. package/json/tokenizer/module.f.js +5 -0
  43. package/package.json +1 -1
  44. package/path/module.f.d.ts +5 -0
  45. package/text/utf8/module.f.d.ts +1 -1
  46. package/types/asn.1/module.f.d.ts +62 -0
  47. package/types/asn.1/module.f.js +276 -0
  48. package/types/asn.1/test.f.d.ts +44 -0
  49. package/types/asn.1/test.f.js +312 -0
  50. package/types/base128/module.f.d.ts +20 -0
  51. package/types/base128/module.f.js +43 -0
  52. package/types/base128/test.f.d.ts +2 -0
  53. package/types/base128/test.f.js +26 -0
  54. package/types/bigfloat/module.f.js +5 -0
  55. package/types/bit_vec/module.f.d.ts +14 -3
  56. package/types/bit_vec/module.f.js +21 -2
  57. package/types/bit_vec/test.f.d.ts +1 -0
  58. package/types/bit_vec/test.f.js +28 -6
  59. package/types/btree/find/module.f.d.ts +5 -0
  60. package/types/btree/module.f.d.ts +5 -0
  61. package/types/btree/module.f.js +5 -0
  62. package/types/btree/remove/module.f.d.ts +5 -0
  63. package/types/btree/set/module.f.d.ts +5 -0
  64. package/types/btree/types/module.f.d.ts +5 -0
  65. package/types/byte_set/module.f.js +5 -0
  66. package/types/cbase32/module.f.d.ts +5 -0
  67. package/types/cbase32/module.f.js +5 -0
  68. package/types/effect/mock/module.f.d.ts +5 -0
  69. package/types/effect/module.f.d.ts +5 -0
  70. package/types/effect/node/module.f.d.ts +5 -1
  71. package/types/effect/node/module.f.js +1 -0
  72. package/types/effect/node/test.f.d.ts +1 -0
  73. package/types/effect/node/test.f.js +19 -1
  74. package/types/effect/node/virtual/module.f.d.ts +3 -0
  75. package/types/effect/node/virtual/module.f.js +10 -0
  76. package/types/function/compare/module.f.d.ts +5 -0
  77. package/types/function/operator/module.f.d.ts +5 -0
  78. package/types/list/module.f.js +5 -0
  79. package/types/map/module.f.js +5 -0
  80. package/types/nibble_set/module.f.d.ts +5 -0
  81. package/types/nominal/module.f.d.ts +5 -0
  82. package/types/nullable/module.f.d.ts +5 -0
  83. package/types/ordered_map/module.f.d.ts +5 -0
  84. package/types/range/module.f.d.ts +5 -0
  85. package/types/sorted_list/module.f.d.ts +5 -0
  86. package/website/module.f.js +5 -0
  87. 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,4 +1,5 @@
1
1
  import { do_ } from "../module.f.js";
2
+ export const fetch = (url) => do_('fetch', url);
2
3
  export const mkdir = (...p) => do_('mkdir', p);
3
4
  export const readFile = (path) => do_('readFile', path);
4
5
  export const readdir = (...p) => do_('readdir', p);
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  map: () => void;
3
+ fetch: () => void;
3
4
  mkdir: {
4
5
  one: () => void;
5
6
  rec: () => void;
@@ -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),
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Comparison function types and helpers.
3
+ *
4
+ * @module
5
+ */
1
6
  import type { Index3, Index5, Array2 } from '../../array/module.f.ts';
2
7
  export type Sign = -1 | 0 | 1;
3
8
  export type Compare<T> = (_: T) => Sign;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Common higher-order operator type aliases.
3
+ *
4
+ * @module
5
+ */
1
6
  export type Binary<A, B, R> = (a: A) => (b: B) => R;
2
7
  export type Fold<I, O> = Binary<I, O, O>;
3
8
  export declare const join: (separator: string) => Reduce<string>;
@@ -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) => {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Persistent map operations built on ordered collections.
3
+ *
4
+ * @module
5
+ */
1
6
  const concat = (x, y) => ({
2
7
  *[Symbol.iterator]() {
3
8
  yield* x;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Nibble-set operations for compact 4-bit membership tracking.
3
+ *
4
+ * @module
5
+ */
1
6
  export type NibbleSet = number;
2
7
  export type Nibble = number;
3
8
  export declare const empty = 0;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Nominal typing helpers for branded TypeScript types.
3
+ *
4
+ * @module
5
+ */
1
6
  export type Nominal<N extends string, R extends string, B> = symbol & {
2
7
  [k in N]: readonly [R, B];
3
8
  };
@@ -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>;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Ordered map operations with deterministic key traversal.
3
+ *
4
+ * @module
5
+ */
1
6
  import type { Tree } from '../btree/types/module.f.ts';
2
7
  import { type List } from '../list/module.f.ts';
3
8
  import type { Reduce } from '../function/operator/module.f.ts';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Range and interval utilities for numeric boundaries.
3
+ *
4
+ * @module
5
+ */
1
6
  export type Range = readonly [number, number];
2
7
  export declare const contains: (range: Range) => (i: number) => boolean;
3
8
  export declare const one: (i: number) => Range;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Sorted immutable list helpers and merge operations.
3
+ *
4
+ * @module
5
+ */
1
6
  import type { Sign } from '../function/compare/module.f.ts';
2
7
  import { type List } from '../list/module.f.ts';
3
8
  import type { Nullable } from '../nullable/module.f.ts';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Static website generation program for project landing content.
3
+ *
4
+ * @module
5
+ */
1
6
  import { htmlToString } from "../html/module.f.js";
2
7
  import { writeFile } from "../types/effect/node/module.f.js";
3
8
  import { utf8 } from "../text/module.f.js";
package/website/module.js CHANGED
@@ -1,3 +1,3 @@
1
- import { nodeRun } from "../io/module.js";
2
- import run from "./module.f.js";
3
- await nodeRun(run);
1
+ import run from "../io/module.js";
2
+ import app from "./module.f.js";
3
+ run(app);