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.
Files changed (68) hide show
  1. package/README.md +4 -4
  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/cas/module.f.d.ts +17 -0
  7. package/cas/module.f.js +77 -0
  8. package/cas/test.f.d.ts +2 -0
  9. package/cas/test.f.js +1 -0
  10. package/ci/module.f.js +8 -6
  11. package/crypto/secp/module.f.d.ts +10 -7
  12. package/crypto/secp/module.f.js +32 -12
  13. package/crypto/secp/test.f.js +4 -5
  14. package/crypto/sha2/module.f.js +0 -1
  15. package/crypto/sign/module.f.d.ts +17 -4
  16. package/crypto/sign/module.f.js +141 -47
  17. package/crypto/sign/test.f.d.ts +11 -1
  18. package/crypto/sign/test.f.js +631 -1
  19. package/dev/module.f.js +3 -2
  20. package/dev/version/module.f.d.ts +2 -2
  21. package/dev/version/module.f.js +4 -3
  22. package/dev/version/test.f.js +3 -2
  23. package/djs/module.f.d.ts +1 -1
  24. package/djs/module.f.js +4 -4
  25. package/djs/transpiler/module.f.js +3 -2
  26. package/djs/transpiler/test.f.js +12 -11
  27. package/fjs/module.f.d.ts +2 -0
  28. package/fjs/module.f.js +24 -0
  29. package/{dev/tf → fjs}/module.js +1 -1
  30. package/io/module.f.d.ts +4 -9
  31. package/io/virtual/module.f.d.ts +1 -1
  32. package/io/virtual/module.f.js +3 -3
  33. package/js/tokenizer/module.f.d.ts +1 -1
  34. package/js/tokenizer/module.f.js +0 -1
  35. package/nanvm-lib/tests/test.f.d.ts +1 -1
  36. package/nanvm-lib/tests/test.f.js +114 -104
  37. package/nanvm-lib/tests/vm/test.f.js +1 -1
  38. package/package.json +5 -7
  39. package/path/module.f.d.ts +3 -2
  40. package/types/btree/find/module.f.d.ts +7 -8
  41. package/types/btree/set/module.f.js +21 -0
  42. package/types/cbase32/module.f.d.ts +6 -0
  43. package/types/cbase32/module.f.js +71 -0
  44. package/types/cbase32/test.f.d.ts +7 -0
  45. package/types/cbase32/test.f.js +74 -0
  46. package/types/list/module.f.d.ts +1 -0
  47. package/types/list/module.f.js +2 -2
  48. package/types/nullable/module.f.d.ts +2 -0
  49. package/types/nullable/module.f.js +1 -0
  50. package/types/nullable/test.f.d.ts +1 -1
  51. package/types/nullable/test.f.js +23 -11
  52. package/types/option/module.f.d.ts +9 -0
  53. package/types/option/module.f.js +6 -0
  54. package/{crypto → types}/prime_field/module.f.d.ts +1 -1
  55. package/{crypto → types}/prime_field/module.f.js +1 -1
  56. package/types/uint8array/module.f.d.ts +11 -0
  57. package/types/uint8array/module.f.js +21 -0
  58. package/types/uint8array/test.f.d.ts +12 -0
  59. package/types/uint8array/test.f.js +58 -0
  60. package/crypto/rfc6979/module.f.d.ts +0 -15
  61. package/crypto/rfc6979/module.f.js +0 -98
  62. package/crypto/rfc6979/test.f.d.ts +0 -10
  63. package/crypto/rfc6979/test.f.js +0 -490
  64. package/fsc/module.d.ts +0 -2
  65. package/fsc/module.js +0 -4
  66. /package/{dev/tf → fjs}/module.d.ts +0 -0
  67. /package/{crypto → types}/prime_field/test.f.d.ts +0 -0
  68. /package/{crypto → types}/prime_field/test.f.js +0 -0
@@ -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), 'utf8'));
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'),
@@ -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, process: { argv } }: Io) => Promise<number>;
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
- export const compile = ({ console: { error }, fs, process: { argv } }) => {
5
- const args = argv.slice(2);
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, '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,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
+ };
@@ -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/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: string) => void;
30
- readonly readFileSync: (path: string, options: BufferEncoding) => string | null;
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, options: BufferEncoding) => Promise<string>;
34
- readonly writeFile: (path: string, data: string, options: BufferEncoding) => Promise<void>;
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[]>;
@@ -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,
@@ -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: {
@@ -1,4 +1,4 @@
1
- const stringCoercion = (a) => a + '';
1
+ const stringCoercion = String;
2
2
  export default {
3
3
  stringCoercion: {
4
4
  number: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.8.1",
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
- "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"
20
19
  },
21
20
  "engines": {
22
21
  "node": ">=20"
23
22
  },
24
23
  "bin": {
25
- "fsc": "fsc/module.js",
26
- "fst": "dev/tf/module.js"
24
+ "fjs": "fjs/module.js"
27
25
  },
28
26
  "repository": {
29
27
  "type": "git",
@@ -1,2 +1,3 @@
1
- export declare const normalize: (path: string) => string;
2
- export declare const concat: (a: string) => (b: string) => string;
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 {};