functionalscript 0.3.10 → 0.3.12

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 (54) hide show
  1. package/README.md +1 -0
  2. package/bnf/djs/module.f.d.ts +11 -0
  3. package/bnf/djs/module.f.js +6 -0
  4. package/bnf/djs/test.f.d.ts +1 -0
  5. package/bnf/djs/test.f.js +221 -0
  6. package/bnf/module.f.d.ts +135 -0
  7. package/bnf/module.f.js +142 -0
  8. package/bnf/test.f.d.ts +65 -0
  9. package/bnf/test.f.js +368 -0
  10. package/crypto/prime_field/module.f.d.ts +1 -4
  11. package/crypto/secp/module.f.d.ts +2 -2
  12. package/dev/test/module.f.js +2 -1
  13. package/fsc/module.f.js +5 -6
  14. package/fsm/module.f.d.ts +9 -9
  15. package/fsm/module.f.js +13 -22
  16. package/html/module.f.js +1 -2
  17. package/issues/31-json.f.d.ts +1 -0
  18. package/issues/31-json.f.js +241 -0
  19. package/js/tokenizer/module.f.js +6 -1
  20. package/nanvm-lib/tests/test.f.d.ts +4 -0
  21. package/nanvm-lib/tests/test.f.js +5 -7
  22. package/nodejs/version/module.f.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/text/module.f.js +3 -3
  25. package/text/utf16/module.f.d.ts +11 -5
  26. package/text/utf16/module.f.js +2 -0
  27. package/text/utf16/test.f.js +8 -1
  28. package/types/btree/find/module.f.d.ts +2 -2
  29. package/types/btree/remove/module.f.d.ts +4 -4
  30. package/types/btree/remove/module.f.js +9 -11
  31. package/types/btree/remove/test.f.js +2 -2
  32. package/types/btree/set/module.f.d.ts +3 -3
  33. package/types/byte_set/test.f.js +31 -31
  34. package/types/function/module.f.d.ts +1 -1
  35. package/types/range_map/module.f.d.ts +79 -2
  36. package/types/range_map/module.f.js +49 -2
  37. package/types/range_map/test.f.d.ts +1 -0
  38. package/types/range_map/test.f.js +76 -33
  39. package/types/result/module.f.d.ts +48 -1
  40. package/types/result/module.f.js +40 -2
  41. package/types/result/test.f.d.ts +4 -0
  42. package/types/result/test.f.js +18 -0
  43. package/types/sorted_list/module.f.js +8 -7
  44. package/types/sorted_set/module.f.d.ts +28 -0
  45. package/types/sorted_set/test.f.d.ts +1 -0
  46. package/types/sorted_set/test.f.js +19 -0
  47. package/types/string/module.f.d.ts +17 -0
  48. package/types/string/module.f.js +17 -0
  49. package/types/string/test.f.d.ts +1 -0
  50. package/types/string/test.f.js +15 -0
  51. package/types/string_set/module.f.d.ts +21 -0
  52. package/types/string_set/module.f.js +21 -0
  53. package/types/string_set/test.f.d.ts +1 -0
  54. package/types/string_set/test.f.js +18 -1
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ // JSON: https://www.json.org/json-en.html
3
+ {
4
+ // null, [0x09, 0x0A], 0x0D, 0x20
5
+ const ws = () => ({ or: [
6
+ [],
7
+ ['\t', ws], // 0x09
8
+ ['\n', ws], // 0x0A
9
+ ['\r', ws], // 0x0D
10
+ [' ', ws], // 0x20
11
+ ] });
12
+ // null, 0x2B, 0x2D
13
+ const sign = { or: [
14
+ [],
15
+ '+', // 0x2B
16
+ '-', // 0x2D
17
+ ] };
18
+ // null, [0x30, 0x39]
19
+ const digits1 = () => ({ or: [
20
+ [],
21
+ digits // [0x30, 0x39]
22
+ ] });
23
+ // [0x30, 0x39]
24
+ const digits = () => [digit, digits1];
25
+ // null, 0x45, 0x65
26
+ const exponent = { or: [
27
+ [],
28
+ ['E', sign, digits], // 0x45
29
+ ['e', sign, digits], // 0x65
30
+ ] };
31
+ // null, 0x2E
32
+ const fraction = { or: [
33
+ [],
34
+ ['.', digits] // 0x2E
35
+ ] };
36
+ // [0x31, 0x39]
37
+ const onenine = [0x31, 0x39];
38
+ // [0x30, 0x39]
39
+ const digit = { or: [
40
+ '0', // 0x30
41
+ onenine, // [0x31, 0x39]
42
+ ] };
43
+ // null, 0x2C
44
+ const members2 = () => ({ or: [
45
+ [],
46
+ [',', ws, members1], // 0x2C
47
+ ] });
48
+ // 0x22
49
+ const members1 = () => [member1, members2];
50
+ // 0x22, 0x7D
51
+ const object1 = { or: [
52
+ [members1, '}'], // 0x22
53
+ '}', // 0x7D
54
+ ] };
55
+ // 0x7B
56
+ const object = ['{', ws, object1];
57
+ // 0x22, 0x2D, [0x30, 0x39], 0x5B, 0x5D, 0x66, 0x6E, 0x74, 0x7B
58
+ const array1 = () => ({ or: [
59
+ [element1, ']'], // 0x22, 0x2D, [0x30, 0x39], 0x5B, 0x66, 0x6E, 0x74, 0x7B
60
+ ']', // 0x5D
61
+ ] });
62
+ // 0x5B
63
+ const array = ['[', ws, array1];
64
+ // [0x30, 0x39], [0x41, 0x46], [0x61, 0x66]
65
+ const hex = { or: [
66
+ digit, // [0x30, 0x39]
67
+ [0x41, 0x46], // A..F
68
+ [0x61, 0x66], // a..f
69
+ ] };
70
+ // 0x22, 0x2F, 0x5C, 0x62, 0x66, 0x6E, 0x72, [0x74, 0x75]
71
+ const escape = { or: [
72
+ '"', // 0x22
73
+ '/', // 0x2F
74
+ '\\', // 0x5C
75
+ 'b', // 0x62
76
+ 'f', // 0x66
77
+ 'n', // 0x6E
78
+ 'r', // 0x72
79
+ 't', // 0x74
80
+ ['u', hex, hex, hex, hex] // 0x75
81
+ ] };
82
+ // [0x20, 0x21], [0x23, 0x10FFFF]
83
+ const character = { or: [
84
+ [0x20, 0x21], // exclude '"' 0x22
85
+ [0x23, 0x5B], // exclude '\' 0x5C
86
+ [0x5D, 0x10FFFF], //
87
+ ['\\', escape], // 0x5C
88
+ ] };
89
+ // null, [0x20, 0x21], [0x23, 0x10FFFF]
90
+ const characters = () => ({ or: [
91
+ [],
92
+ [character, characters]
93
+ ] });
94
+ // 0x22
95
+ const string = ['"', characters, '"'];
96
+ // [0x30, 0x39]
97
+ const integer1 = { or: [
98
+ '0',
99
+ [onenine, digits1],
100
+ ] };
101
+ // 0x2D, [0x30, 0x39]
102
+ const integer = { or: [
103
+ ['-', integer1], // 0x2D
104
+ '0', // 0x30
105
+ [onenine, digits1], // [0x31, 0x39]
106
+ ] };
107
+ // 0x2D, [0x30, 0x39]
108
+ const number = [integer, fraction, exponent];
109
+ // 0x22, 0x2D, [0x30, 0x39], 0x5B, 0x66, 0x6E, 0x74, 0x7B
110
+ const value = { or: [
111
+ string, // 0x22
112
+ number, // 0x2D, [0x30, 0x39]
113
+ array, // 0x5B
114
+ 'false', // 0x66
115
+ 'null', // 0x6E
116
+ 'true', // 0x74
117
+ object, // 0x7B
118
+ ] };
119
+ // 0x22, 0x2D, [0x30, 0x39], 0x5B, 0x66, 0x6E, 0x74, 0x7B
120
+ const element1 = [value, ws];
121
+ // [0x09, 0x0A], 0x0D, 0x20, 0x22, 0x2D, [0x30, 0x39], 0x5B, 0x66, 0x6E, 0x74, 0x7B
122
+ const element = [ws, element1];
123
+ // 0x22
124
+ const member1 = [string, ws, ':', element];
125
+ const json = element;
126
+ }
127
+ // serializable
128
+ {
129
+ //
130
+ const element = { id: 'element' };
131
+ const ws = { id: 'ws' };
132
+ const value = { id: 'value' };
133
+ const object = { id: 'object' };
134
+ const array = { id: 'array' };
135
+ const string = { id: 'string' };
136
+ const number = { id: 'number' };
137
+ const members = { id: 'members' };
138
+ const characters = { id: 'characters' };
139
+ const integer = { id: 'integer' };
140
+ const fraction = { id: 'fraction' };
141
+ const exponent = { id: 'exponent' };
142
+ const member = { id: 'member' };
143
+ const character = { id: 'character' };
144
+ const digit = { id: 'digit' };
145
+ const onenine = { id: 'onenine' };
146
+ const digits = { id: 'digits' };
147
+ const sign = { id: 'sign' };
148
+ const escape = { id: 'escape' };
149
+ const hex = { id: 'hex' };
150
+ const map = {
151
+ json: element,
152
+ element: [ws, value, ws],
153
+ ws: { or: [
154
+ [],
155
+ [' ', ws],
156
+ ['\t', ws],
157
+ ['\n', ws],
158
+ ['\r', ws],
159
+ ] },
160
+ value: { or: [
161
+ object,
162
+ array,
163
+ string,
164
+ number,
165
+ 'true',
166
+ 'false',
167
+ 'null'
168
+ ] },
169
+ object: { or: [
170
+ ['{', ws, '}'],
171
+ ['{', members, '}'],
172
+ ] },
173
+ array: { or: [
174
+ ['[', ws, ']'],
175
+ ['[', element, ']'],
176
+ ] },
177
+ string: ['"', characters, '"'],
178
+ number: [integer, fraction, exponent],
179
+ members: { or: [
180
+ member,
181
+ [member, ',', members],
182
+ ] },
183
+ characters: { or: [
184
+ [],
185
+ [character, characters]
186
+ ] },
187
+ integer: { or: [
188
+ digit,
189
+ [onenine, digits],
190
+ ['-', digit],
191
+ ['-', onenine, digits],
192
+ ] },
193
+ fraction: { or: [
194
+ [],
195
+ ['.', digits]
196
+ ] },
197
+ exponent: { or: [
198
+ [],
199
+ ['E', sign, digits],
200
+ ['e', sign, digits],
201
+ ] },
202
+ member: [ws, string, ws, ':', element],
203
+ character: { or: [
204
+ [0x20, 0x21], // exclude '"' 0x22
205
+ [0x23, 0x5B], // exclude '\' 0x5C
206
+ [0x5D, 0x10FFFF],
207
+ ['\\', escape],
208
+ ] },
209
+ digit: { or: [
210
+ '0',
211
+ onenine,
212
+ ] },
213
+ onenine: [0x31, 0x39],
214
+ digits: { or: [
215
+ digit,
216
+ [digit, digits]
217
+ ] },
218
+ sign: { or: [
219
+ [],
220
+ '+',
221
+ '-',
222
+ ] },
223
+ escape: { or: [
224
+ '"',
225
+ '\\',
226
+ '/',
227
+ 'b',
228
+ 'f',
229
+ 'n',
230
+ 'r',
231
+ 't',
232
+ ['u', hex, hex, hex, hex]
233
+ ] },
234
+ hex: { or: [
235
+ digit,
236
+ [0x41, 0x46], // A..F
237
+ [0x61, 0x66], // a..f
238
+ ] },
239
+ };
240
+ const _map = map;
241
+ }
@@ -107,6 +107,7 @@ const union = def => a => b => {
107
107
  const rangeMapMerge = def => merge({
108
108
  union: union(def),
109
109
  equal: operator.strictEqual,
110
+ def,
110
111
  });
111
112
  const rangeFunc = r => f => def => fromRange(def)(r)(f);
112
113
  const scanRangeOp = def => f => [f(def), scanRangeOp(def)];
@@ -126,7 +127,11 @@ const create = (def) => (a) => {
126
127
  };
127
128
  const digitToBigInt = d => BigInt(d - digit0);
128
129
  const startNumber = digit => ({ s: 1n, m: digitToBigInt(digit), f: 0, es: 1, e: 0 });
129
- const startNegativeNumber = { s: -1n, m: 0n, f: 0, es: 1, e: 0 };
130
+ /*
131
+ const startNegativeNumber
132
+ : ParseNumberBuffer
133
+ = { s: -1n, m: 0n, f: 0, es: 1, e: 0 }
134
+ */
130
135
  const addIntDigit = digit => b => ({ ...b, m: b.m * 10n + digitToBigInt(digit) });
131
136
  const addFracDigit = digit => b => ({ ...b, m: b.m * 10n + digitToBigInt(digit), f: b.f - 1 });
132
137
  const addExpDigit = digit => b => ({ ...b, e: b.e * 10 + digit - digit0 });
@@ -41,6 +41,9 @@ declare const _default: {
41
41
  positive: () => void;
42
42
  nan: () => void;
43
43
  };
44
+ bigint: {
45
+ throw: () => number;
46
+ };
44
47
  array: {
45
48
  empty: () => void;
46
49
  single_number: () => void;
@@ -50,6 +53,7 @@ declare const _default: {
50
53
  object: {
51
54
  empty: () => void;
52
55
  };
56
+ function: () => void;
53
57
  };
54
58
  };
55
59
  export default _default;
@@ -108,11 +108,9 @@ export default {
108
108
  positive: () => e(op("2.3"))(2.3),
109
109
  nan: () => nan("a")
110
110
  },
111
- // TODO: bigint - handle TypeError exception for bigint. The test below (that follows
112
- // current Rust implementation) is incorrect.
113
- // bigint: {
114
- // nan: () => u_p_nan(0n)
115
- // }
111
+ bigint: {
112
+ throw: () => op(0n),
113
+ },
116
114
  array: {
117
115
  empty: () => e(op([]))(0),
118
116
  single_number: () => e(op([2.3]))(2.3),
@@ -122,8 +120,8 @@ export default {
122
120
  object: {
123
121
  empty: () => nan({})
124
122
  // TODO: test objects with valueOf, toString functions - when Rust logic is implemented
125
- }
126
- // TODO: test Function - when Rust logic is implemented
123
+ },
124
+ function: () => nan(op(() => { }))
127
125
  };
128
126
  }
129
127
  };
@@ -1,4 +1,4 @@
1
- export type Buffer = {};
1
+ export type Buffer = object;
2
2
  type Fs<T> = {
3
3
  readonly readFileSync: (name: string) => Buffer;
4
4
  readonly writeFileSync: (name: string, content: string) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.f.d.ts",
package/text/module.f.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { msb, u8List, u8ListToVec } from "../types/bit_vec/module.f.js";
2
2
  import { flatMap } from "../types/list/module.f.js";
3
3
  import * as utf8 from "./utf8/module.f.js";
4
- import * as utf16 from "./utf16/module.f.js";
4
+ import { stringToCodePointList, codePointListToString } from "./utf16/module.f.js";
5
5
  export const flat = (indent) => {
6
6
  const f = (prefix) => {
7
7
  const g = (item) => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item);
@@ -16,11 +16,11 @@ export const curly = (type) => (name) => (body) => [`${type} ${name}`, '{', body
16
16
  * @param s The input string to be converted.
17
17
  * @returns The resulting UTF-8 bit vector, MSB first.
18
18
  */
19
- export const msbUtf8 = (s) => u8ListToVec(msb)(utf8.fromCodePointList(utf16.toCodePointList(utf16.stringToList(s))));
19
+ export const msbUtf8 = (s) => u8ListToVec(msb)(utf8.fromCodePointList(stringToCodePointList(s)));
20
20
  /**
21
21
  * Converts a UTF-8 bit vector with MSB first encoding to a string.
22
22
  *
23
23
  * @param msbV - The UTF-8 bit vector with MSB first encoding.
24
24
  * @returns The resulting string.
25
25
  */
26
- export const msbUtf8ToString = (msbV) => utf16.listToString(utf16.fromCodePointList(utf8.toCodePointList(u8List(msb)(msbV))));
26
+ export const msbUtf8ToString = (msbV) => codePointListToString(utf8.toCodePointList(u8List(msb)(msbV)));
@@ -1,8 +1,14 @@
1
1
  import { type List, type Thunk } from '../../types/list/module.f.ts';
2
- type U16 = number;
3
- type I32 = number;
4
- export declare const fromCodePointList: (input: List<number>) => Thunk<number>;
5
- export declare const toCodePointList: (input: List<U16>) => List<I32>;
2
+ export type U16 = number;
3
+ /**
4
+ * [0, 0x10_FFFF]: 16+5 = 21 bits
5
+ *
6
+ * 121_0000_0000: 16+16+9 = 41 bits
7
+ */
8
+ export type CodePoint = number;
9
+ export declare const fromCodePointList: (input: List<CodePoint>) => Thunk<U16>;
10
+ export declare const toCodePointList: (input: List<U16>) => List<CodePoint>;
6
11
  export declare const stringToList: (s: string) => List<U16>;
12
+ export declare const stringToCodePointList: (input: string) => List<CodePoint>;
7
13
  export declare const listToString: (input: List<U16>) => string;
8
- export {};
14
+ export declare const codePointListToString: (input: List<CodePoint>) => string;
@@ -60,6 +60,8 @@ export const stringToList = (s) => {
60
60
  };
61
61
  return at(0);
62
62
  };
63
+ export const stringToCodePointList = (input) => toCodePointList(stringToList(input));
63
64
  export const listToString = fn(map(String.fromCharCode))
64
65
  .then(reduce(concat)(''))
65
66
  .result;
67
+ export const codePointListToString = (input) => listToString(fromCodePointList(input));
@@ -1,4 +1,4 @@
1
- import { toCodePointList, fromCodePointList, stringToList, listToString } from "./module.f.js";
1
+ import { toCodePointList, fromCodePointList, stringToList, listToString, stringToCodePointList, codePointListToString } from "./module.f.js";
2
2
  import * as json from "../../json/module.f.js";
3
3
  import { sort } from "../../types/object/module.f.js";
4
4
  import { toArray } from "../../types/list/module.f.js";
@@ -130,6 +130,13 @@ export default {
130
130
  throw result;
131
131
  }
132
132
  },
133
+ () => {
134
+ const cpList = stringToCodePointList("Hello world!😂🚜🚲");
135
+ const result = codePointListToString(cpList);
136
+ if (result !== "Hello world!😂🚜🚲") {
137
+ throw result;
138
+ }
139
+ },
133
140
  () => {
134
141
  const a = stringToList("Hello world!😂🚜🚲");
135
142
  const b = toCodePointList(a);
@@ -1,5 +1,5 @@
1
1
  import type { Leaf1, Leaf2, Branch3, Branch5, TNode } from '../types/module.f.ts';
2
- import type * as List from '../../list/module.f.ts';
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
5
  type FirstLeaf1<T> = readonly [Index3, Leaf1<T>];
@@ -10,7 +10,7 @@ type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T
10
10
  type PathItem3<T> = readonly [0 | 2, Branch3<T>];
11
11
  type PathItem5<T> = readonly [0 | 2 | 4, Branch5<T>];
12
12
  export type PathItem<T> = PathItem3<T> | PathItem5<T>;
13
- export type Path<T> = List.List<PathItem<T>>;
13
+ export type Path<T> = List<PathItem<T>>;
14
14
  export type Result<T> = {
15
15
  readonly first: First<T>;
16
16
  readonly tail: Path<T>;
@@ -1,4 +1,4 @@
1
- import type * as _ from '../types/module.f.ts';
2
- import type * as Cmp from '../../function/compare/module.f.ts';
3
- export declare const nodeRemove: <T>(c: Cmp.Compare<T>) => (node: _.TNode<T>) => _.Tree<T>;
4
- export declare const remove: <T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>;
1
+ import type { TNode, Tree } from '../types/module.f.ts';
2
+ import type { Compare } from '../../function/compare/module.f.ts';
3
+ export declare const nodeRemove: <T>(c: Compare<T>) => (node: TNode<T>) => Tree<T>;
4
+ export declare const remove: <T>(c: Compare<T>) => (tree: Tree<T>) => Tree<T>;
@@ -1,9 +1,7 @@
1
- import * as find from "../find/module.f.js";
2
- import * as list from "../../list/module.f.js";
3
- const { fold, concat, next } = list;
4
- import * as n from "../../nullable/module.f.js";
5
- const { map } = n;
6
- const path = tail => n => {
1
+ import { find } from "../find/module.f.js";
2
+ import { fold, concat, next } from "../../list/module.f.js";
3
+ import { map } from "../../nullable/module.f.js";
4
+ const path = (tail) => (n) => {
7
5
  switch (n.length) {
8
6
  case 1: {
9
7
  return [n[0], { first: null, tail }];
@@ -19,7 +17,7 @@ const path = tail => n => {
19
17
  }
20
18
  }
21
19
  };
22
- const reduceValue0 = a => n => {
20
+ const reduceValue0 = (a) => (n) => {
23
21
  const [, v1, n2] = n;
24
22
  if (a.length === 1) {
25
23
  switch (n2.length) {
@@ -38,7 +36,7 @@ const reduceValue0 = a => n => {
38
36
  return [a, v1, n2];
39
37
  }
40
38
  };
41
- const reduceValue2 = a => n => {
39
+ const reduceValue2 = (a) => (n) => {
42
40
  const [n0, v1,] = n;
43
41
  if (a.length === 1) {
44
42
  switch (n0.length) {
@@ -57,7 +55,7 @@ const reduceValue2 = a => n => {
57
55
  return [n0, v1, a];
58
56
  }
59
57
  };
60
- const initValue0 = a => n => {
58
+ const initValue0 = (a) => (n) => {
61
59
  const [, v1, n2] = n;
62
60
  if (a === null) {
63
61
  switch (n2.length) {
@@ -76,7 +74,7 @@ const initValue0 = a => n => {
76
74
  return [a, v1, n2];
77
75
  }
78
76
  };
79
- const initValue1 = a => n => {
77
+ const initValue1 = (a) => (n) => {
80
78
  const [n0, v1] = n;
81
79
  if (a === null) {
82
80
  switch (n0.length) {
@@ -117,7 +115,7 @@ const reduce = fold(reduceX([reduceValue0, reduceValue2]));
117
115
  const initReduce = reduceX([initValue0, initValue1]);
118
116
  export const nodeRemove = (c) => (node) => {
119
117
  const f = () => {
120
- const { first, tail } = find.find(c)(node);
118
+ const { first, tail } = find(c)(node);
121
119
  const branch = n => f => {
122
120
  const [v, p] = path(null)(n);
123
121
  return { first: p.first, tail: concat(p.tail)({ first: f(v), tail }) };
@@ -1,10 +1,10 @@
1
- import * as _ from "./module.f.js";
1
+ import { nodeRemove } from "./module.f.js";
2
2
  import * as s from "../set/module.f.js";
3
3
  import { cmp } from "../../string/module.f.js";
4
4
  import * as json from "../../../json/module.f.js";
5
5
  import { sort } from "../../object/module.f.js";
6
6
  const set = (node) => (value) => s.set(cmp(value))(() => value)(node);
7
- const remove = (node) => (value) => _.nodeRemove(cmp(value))(node);
7
+ const remove = (node) => (value) => nodeRemove(cmp(value))(node);
8
8
  const jsonStr = json.stringify(sort);
9
9
  const test = () => {
10
10
  let _map = ['1'];
@@ -1,3 +1,3 @@
1
- import type * as _ from '../types/module.f.ts';
2
- import type * as Cmp from '../../function/compare/module.f.ts';
3
- export declare const set: <T>(c: Cmp.Compare<T>) => (f: (value: T | null) => T) => (tree: _.Tree<T>) => _.TNode<T>;
1
+ import type { TNode, Tree } from '../types/module.f.ts';
2
+ import type { Compare } from '../../function/compare/module.f.ts';
3
+ export declare const set: <T>(c: Compare<T>) => (f: (value: T | null) => T) => (tree: Tree<T>) => TNode<T>;
@@ -1,4 +1,4 @@
1
- import * as _ from "./module.f.js";
1
+ import { has, empty, set, setRange, unset, universe, complement, toRangeMap } from "./module.f.js";
2
2
  import { every, countdown, map, toArray } from "../list/module.f.js";
3
3
  import * as json from "../../json/module.f.js";
4
4
  import { sort } from "../object/module.f.js";
@@ -6,112 +6,112 @@ const stringify = json.stringify(sort);
6
6
  export default {
7
7
  has: [
8
8
  () => {
9
- if (_.has(0)(_.empty)) {
10
- throw _.empty;
9
+ if (has(0)(empty)) {
10
+ throw empty;
11
11
  }
12
- if (_.has(1)(_.empty)) {
13
- throw _.empty;
12
+ if (has(1)(empty)) {
13
+ throw empty;
14
14
  }
15
- if (_.has(33)(_.empty)) {
16
- throw _.empty;
15
+ if (has(33)(empty)) {
16
+ throw empty;
17
17
  }
18
18
  },
19
19
  () => {
20
- const s = _.set(0)(_.empty);
20
+ const s = set(0)(empty);
21
21
  if (s !== 1n) {
22
22
  throw s;
23
23
  }
24
- if (!_.has(0)(s)) {
24
+ if (!has(0)(s)) {
25
25
  throw s;
26
26
  }
27
- if (_.has(1)(s)) {
27
+ if (has(1)(s)) {
28
28
  throw s;
29
29
  }
30
- if (_.has(33)(s)) {
30
+ if (has(33)(s)) {
31
31
  throw s;
32
32
  }
33
33
  },
34
34
  () => {
35
- const s = _.set(33)(_.empty);
35
+ const s = set(33)(empty);
36
36
  if (s !== 8589934592n) {
37
37
  throw s;
38
38
  }
39
- if (_.has(0)(s)) {
39
+ if (has(0)(s)) {
40
40
  throw s;
41
41
  }
42
- if (_.has(1)(s)) {
42
+ if (has(1)(s)) {
43
43
  throw s;
44
44
  }
45
- if (!_.has(33)(s)) {
45
+ if (!has(33)(s)) {
46
46
  throw s;
47
47
  }
48
48
  }
49
49
  ],
50
50
  setRange: () => {
51
- const result = _.setRange([2, 5])(_.empty);
51
+ const result = setRange([2, 5])(empty);
52
52
  if (result !== 60n) {
53
53
  throw result;
54
54
  }
55
55
  },
56
56
  unset: [
57
57
  () => {
58
- const a = _.set(0)(_.empty);
59
- const result = _.unset(0)(a);
58
+ const a = set(0)(empty);
59
+ const result = unset(0)(a);
60
60
  if (result !== 0n) {
61
61
  throw result;
62
62
  }
63
63
  },
64
64
  () => {
65
- const a = _.set(255)(_.empty);
66
- const result = _.unset(255)(a);
65
+ const a = set(255)(empty);
66
+ const result = unset(255)(a);
67
67
  if (result !== 0n) {
68
68
  throw result;
69
69
  }
70
70
  }
71
71
  ],
72
72
  universe: () => {
73
- const x = every(map((v) => _.has(v)(_.universe))(countdown(256)));
73
+ const x = every(map((v) => has(v)(universe))(countdown(256)));
74
74
  if (!x) {
75
75
  throw x;
76
76
  }
77
77
  },
78
78
  compliment: {
79
79
  empty: () => {
80
- const r = _.complement(_.empty);
81
- if (r !== _.universe) {
80
+ const r = complement(empty);
81
+ if (r !== universe) {
82
82
  throw r;
83
83
  }
84
84
  },
85
85
  universe: () => {
86
- const r = _.complement(_.universe);
87
- if (r !== _.empty) {
86
+ const r = complement(universe);
87
+ if (r !== empty) {
88
88
  throw r;
89
89
  }
90
90
  },
91
91
  },
92
92
  toRangeMap: [
93
93
  () => {
94
- const result = stringify(toArray(_.toRangeMap(_.empty)('a')));
94
+ const result = stringify(toArray(toRangeMap(empty)('a')));
95
95
  if (result !== '[]') {
96
96
  throw result;
97
97
  }
98
98
  },
99
99
  () => {
100
- const s = _.set(0)(_.empty);
101
- const result = stringify(toArray(_.toRangeMap(s)('a')));
100
+ const s = set(0)(empty);
101
+ const result = stringify(toArray(toRangeMap(s)('a')));
102
102
  if (result !== '[[["a"],0]]') {
103
103
  throw result;
104
104
  }
105
105
  },
106
106
  () => {
107
- const s = _.setRange([1, 2])(_.empty);
108
- const result = stringify(toArray(_.toRangeMap(s)('a')));
107
+ const s = setRange([1, 2])(empty);
108
+ const result = stringify(toArray(toRangeMap(s)('a')));
109
109
  if (result !== '[[[],0],[["a"],2]]') {
110
110
  throw result;
111
111
  }
112
112
  },
113
113
  () => {
114
- const result = stringify(toArray(_.toRangeMap(_.universe)('a')));
114
+ const result = stringify(toArray(toRangeMap(universe)('a')));
115
115
  if (result !== '[[["a"],255]]') {
116
116
  throw result;
117
117
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A generic function type.
3
3
  */
4
- type Func<I, O> = (_: I) => O;
4
+ export type Func<I, O> = (_: I) => O;
5
5
  /**
6
6
  * A postfix compose function.
7
7
  */