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.
Files changed (91) hide show
  1. package/README.md +5 -5
  2. package/bnf/data/module.f.d.ts +10 -1
  3. package/bnf/data/module.f.js +58 -19
  4. package/bnf/data/test.f.d.ts +2 -0
  5. package/bnf/data/test.f.js +244 -3
  6. package/bnf/module.f.d.ts +6 -2
  7. package/bnf/module.f.js +8 -9
  8. package/cas/module.f.d.ts +18 -0
  9. package/cas/module.f.js +95 -0
  10. package/cas/test.f.d.ts +2 -0
  11. package/cas/test.f.js +1 -0
  12. package/ci/module.f.d.ts +3 -2
  13. package/ci/module.f.js +11 -9
  14. package/ci/module.js +3 -3
  15. package/crypto/sha2/module.f.js +0 -1
  16. package/dev/module.f.d.ts +1 -1
  17. package/dev/module.f.js +14 -6
  18. package/dev/version/module.f.d.ts +2 -11
  19. package/dev/version/module.f.js +17 -14
  20. package/dev/version/test.f.d.ts +3 -1
  21. package/dev/version/test.f.js +26 -10
  22. package/djs/module.f.d.ts +1 -1
  23. package/djs/module.f.js +4 -4
  24. package/djs/parser-new/module.f.d.ts +3 -0
  25. package/djs/parser-new/module.f.js +150 -0
  26. package/djs/parser-new/test.f.d.ts +5 -0
  27. package/djs/parser-new/test.f.js +201 -0
  28. package/djs/serializer/module.f.js +6 -6
  29. package/djs/transpiler/module.f.js +3 -2
  30. package/djs/transpiler/test.f.js +12 -11
  31. package/fjs/module.f.d.ts +2 -0
  32. package/fjs/module.f.js +25 -0
  33. package/{dev/tf → fjs}/module.js +1 -1
  34. package/fsc/module.f.js +1 -1
  35. package/io/module.d.ts +4 -0
  36. package/io/module.f.d.ts +14 -13
  37. package/io/module.f.js +21 -0
  38. package/io/module.js +7 -1
  39. package/io/virtual/module.f.d.ts +1 -1
  40. package/io/virtual/module.f.js +3 -3
  41. package/js/tokenizer/module.f.d.ts +1 -1
  42. package/js/tokenizer/module.f.js +0 -1
  43. package/json/module.f.js +3 -3
  44. package/nanvm-lib/tests/test.f.d.ts +1 -1
  45. package/nanvm-lib/tests/test.f.js +114 -104
  46. package/package.json +6 -7
  47. package/path/module.f.d.ts +1 -0
  48. package/path/module.f.js +6 -3
  49. package/text/utf16/module.f.js +1 -1
  50. package/types/bit_vec/module.f.d.ts +1 -0
  51. package/types/bit_vec/module.f.js +1 -0
  52. package/types/btree/find/module.f.d.ts +7 -8
  53. package/types/btree/set/module.f.js +21 -0
  54. package/types/cbase32/module.f.d.ts +6 -0
  55. package/types/cbase32/module.f.js +71 -0
  56. package/types/cbase32/test.f.d.ts +7 -0
  57. package/types/cbase32/test.f.js +74 -0
  58. package/types/effect/mock/module.f.d.ts +5 -0
  59. package/types/effect/mock/module.f.js +14 -0
  60. package/types/effect/module.d.ts +2 -0
  61. package/types/effect/module.f.d.ts +23 -0
  62. package/types/effect/module.f.js +14 -0
  63. package/types/effect/module.js +11 -0
  64. package/types/effect/node/module.f.d.ts +52 -0
  65. package/types/effect/node/module.f.js +7 -0
  66. package/types/effect/node/test.f.d.ts +27 -0
  67. package/types/effect/node/test.f.js +259 -0
  68. package/types/effect/node/virtual/module.f.d.ts +13 -0
  69. package/types/effect/node/virtual/module.f.js +98 -0
  70. package/types/function/module.f.d.ts +1 -1
  71. package/types/function/module.f.js +1 -1
  72. package/types/function/test.f.js +1 -1
  73. package/types/list/module.f.d.ts +1 -0
  74. package/types/list/module.f.js +6 -6
  75. package/types/nullable/module.f.d.ts +2 -0
  76. package/types/nullable/module.f.js +1 -0
  77. package/types/nullable/test.f.d.ts +1 -1
  78. package/types/nullable/test.f.js +23 -11
  79. package/types/option/module.f.d.ts +9 -0
  80. package/types/option/module.f.js +6 -0
  81. package/types/uint8array/module.f.d.ts +11 -0
  82. package/types/uint8array/module.f.js +21 -0
  83. package/types/uint8array/test.f.d.ts +12 -0
  84. package/types/uint8array/test.f.js +58 -0
  85. package/website/module.d.ts +1 -0
  86. package/website/module.f.d.ts +3 -0
  87. package/website/module.f.js +9 -0
  88. package/website/module.js +3 -0
  89. package/fsc/module.d.ts +0 -2
  90. package/fsc/module.js +0 -4
  91. /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, 'utf8');
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 => {
@@ -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') {
@@ -0,0 +1,2 @@
1
+ import { type Io } from '../io/module.f.ts';
2
+ export declare const main: (io: Io) => Promise<number>;
@@ -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
+ };
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { main } from "./module.f.js";
3
- import node from "../../io/module.js";
3
+ import node from "../io/module.js";
4
4
  await node(main);
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).then(codePointRange).result;
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 { 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';
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: string) => void;
30
- readonly readFileSync: (path: string, options: BufferEncoding) => string | null;
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, options: BufferEncoding) => Promise<string>;
34
- readonly writeFile: (path: string, data: string, options: BufferEncoding) => Promise<void>;
35
- readonly readdir: (path: string, options: {
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);
@@ -1,3 +1,3 @@
1
1
  import type { Io } from '../module.f.ts';
2
2
  import { type OrderedMap } from '../../types/ordered_map/module.f.ts';
3
- export declare const createVirtualIo: (files: OrderedMap<string>) => Io;
3
+ export declare const createVirtualIo: (files: OrderedMap<Uint8Array>) => Io;
@@ -7,12 +7,12 @@ export const createVirtualIo = (files) => ({
7
7
  fs: {
8
8
  writeSync: (fd, s) => { },
9
9
  writeFileSync: (_file, _data) => { },
10
- readFileSync: (path, _options) => { return at(path)(files); },
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, _options) => Promise.resolve(''),
15
- writeFile: (_path, _data, _options) => Promise.resolve(),
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 { type BigFloat } from '../../types/bigfloat/module.f.ts';
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;
@@ -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
- .then(sort)
29
- .then(mapPropertySerialize)
30
- .then(objectWrap)
28
+ .map(sort)
29
+ .map(mapPropertySerialize)
30
+ .map(objectWrap)
31
31
  .result;
32
32
  const f = value => {
33
33
  switch (typeof value) {
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- eq: {
2
+ eq: () => {
3
3
  nullish: () => void;
4
4
  boolean: {
5
5
  boolean: () => void;
@@ -1,121 +1,131 @@
1
- const e = (a) => (b) => {
2
- if (a === b) { }
1
+ const { is } = Object;
2
+ const ois = (a) => (b) => {
3
+ if (is(a, b)) { }
3
4
  else {
4
- throw [a, '===', b];
5
+ throw [a, 'is', b];
5
6
  }
6
7
  };
7
- const n = (a) => (b) => {
8
- if (a !== b) { }
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 (!Number.isNaN(result)) {
11
+ if (!isNaN(result)) {
16
12
  throw result;
17
13
  }
18
14
  };
19
15
  export default {
20
- eq: {
21
- nullish: () => {
22
- e(null)(null);
23
- e(undefined)(undefined);
24
- n(null)(undefined);
25
- },
26
- boolean: {
27
- boolean: () => {
28
- e(true)(true);
29
- e(false)(false);
30
- n(true)(false);
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
- number: {
38
- number: () => {
39
- e(2.3)(2.3);
40
- n(2.3)(-5.4);
41
- n(NaN)(NaN);
42
- e(0)(-0);
43
- if (!Object.is(-0, -0)) {
44
- throw -0;
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
- if (Object.is(0, -0)) {
47
- throw -0;
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
- nullish: () => {
54
- n(undefined)(NaN);
55
- n(undefined)(0);
56
- }
57
- },
58
- string: {
59
- string: () => {
60
- e("hello")("hello");
61
- n("hello")("world");
62
- },
63
- number: () => {
64
- n(0)("0");
65
- }
66
- },
67
- bigint: {
68
- bigint: () => {
69
- e(12n)(12n);
70
- n(12n)(-12n);
71
- n(12n)(13n);
72
- }
73
- },
74
- array: {
75
- array: () => {
76
- const a = [];
77
- e(a)(a);
78
- n([])([]);
79
- const a0 = ['0'];
80
- e(a0)(a0);
81
- }
82
- },
83
- object: {
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 = nan_res(op);
103
+ const nan = nanRes(op);
94
104
  return {
95
- null: () => e(op(null))(0),
105
+ null: () => ois(op(null))(0),
96
106
  undefined: () => nan(undefined),
97
107
  boolean: {
98
- false: () => e(op(false))(0),
99
- true: () => e(op(true))(1)
108
+ false: () => ois(op(false))(0),
109
+ true: () => ois(op(true))(1)
100
110
  },
101
111
  number: {
102
- zero: () => e(op(0))(0),
103
- positive: () => e(op(2.3))(2.3),
104
- negative: () => e(op(-2.3))(-2.3)
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: () => e(op(""))(0),
108
- zero: () => e(op("0"))(0),
109
- positive: () => e(op("2.3"))(2.3),
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: () => e(op([]))(0),
117
- single_number: () => e(op([2.3]))(2.3),
118
- single_string: () => e(op(["-2.3"]))(-2.3),
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 = nan_res(op);
140
+ const nan = nanRes(op);
131
141
  return {
132
- null: () => e(op(null))(0),
142
+ null: () => ois(op(null))(-0),
133
143
  undefined: () => nan(undefined),
134
144
  boolean: {
135
- false: () => e(op(false))(0),
136
- true: () => e(op(true))(-1)
145
+ false: () => ois(op(false))(-0),
146
+ true: () => ois(op(true))(-1)
137
147
  },
138
148
  number: {
139
- zero: () => e(op(0))(0),
140
- positive: () => e(op(2.3))(-2.3),
141
- negative: () => e(op(-2.3))(2.3)
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: () => e(op(""))(0),
145
- zero: () => e(op("0"))(0),
146
- positive: () => e(op("2.3"))(-2.3),
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: () => e(op(1n))(-1n),
151
- negative: () => e(op(-1n))(1n),
160
+ positive: () => ois(op(1n))(-1n),
161
+ negative: () => ois(op(-1n))(1n),
152
162
  },
153
163
  array: {
154
- empty: () => e(op([]))(0),
155
- single_number: () => e(op([2.3]))(-2.3),
156
- single_string: () => e(op(["-2.3"]))(2.3),
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.8.2",
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
- "fsc": "node ./fsc/module.ts",
17
- "fst": "node ./dev/tf/module.ts",
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
- "fsc": "fsc/module.js",
26
- "fst": "dev/tf/module.js"
25
+ "fjs": "fjs/module.js"
27
26
  },
28
27
  "repository": {
29
28
  "type": "git",
@@ -1,3 +1,4 @@
1
1
  import type { Reduce, Unary } from "../types/function/operator/module.f.ts";
2
+ export declare const parse: (path: string) => readonly string[];
2
3
  export declare const normalize: Unary<string, string>;
3
4
  export declare const concat: Reduce<string>;
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 normalize = path => {
24
+ export const parse = (path) => {
25
25
  const split = path.replaceAll('\\', '/').split('/');
26
- const foldResult = fold(foldNormalizeOp)([])(split);
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 => {
@@ -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
- .then(reduce(concat)(''))
335
+ .map(reduce(concat)(''))
336
336
  .result;
337
337
  /**
338
338
  * Converts a list of Unicode code points (CodePoint) to a string.