functionalscript 0.1.608 → 0.2.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/CHANGELOG.md +10 -0
- package/Cargo.lock +4 -0
- package/Cargo.toml +4 -2
- package/README.md +1 -1
- package/com/cpp/module.f.d.mts +4 -8
- package/com/cpp/module.f.mjs +20 -25
- package/com/cpp/testlib.f.mjs +3 -4
- package/com/cs/module.f.d.mts +4 -8
- package/com/cs/module.f.mjs +18 -23
- package/com/cs/testlib.f.mjs +3 -5
- package/com/rust/module.f.d.mts +3 -7
- package/com/rust/module.f.mjs +25 -30
- package/com/rust/nanocom/src/cobject.rs +1 -1
- package/com/rust/testlib.f.mjs +3 -5
- package/com/test/build.f.d.mts +2 -2
- package/com/test/build.f.mjs +2 -2
- package/com/test/build.mjs +4 -4
- package/com/test/rust/src/lib.rs +4 -4
- package/com/types/module.f.d.mts +5 -10
- package/com/types/module.f.mjs +5 -12
- package/commonjs/build/module.f.d.mts +13 -17
- package/commonjs/build/module.f.mjs +23 -28
- package/commonjs/build/test.f.mjs +4 -4
- package/commonjs/module/function/module.f.d.mts +0 -2
- package/commonjs/module/function/module.f.mjs +0 -2
- package/commonjs/module/module.f.d.mts +16 -21
- package/commonjs/module/module.f.mjs +2 -9
- package/commonjs/module.d.mts +1 -5
- package/commonjs/module.f.d.mts +0 -2
- package/commonjs/module.f.mjs +0 -2
- package/commonjs/module.mjs +2 -7
- package/commonjs/package/dependencies/module.f.d.mts +3 -7
- package/commonjs/package/dependencies/module.f.mjs +5 -10
- package/commonjs/package/dependencies/test.f.mjs +1 -1
- package/commonjs/package/module.f.d.mts +12 -18
- package/commonjs/package/module.f.mjs +6 -13
- package/commonjs/package/test.f.mjs +1 -1
- package/commonjs/path/module.f.d.mts +25 -32
- package/commonjs/path/module.f.mjs +12 -23
- package/commonjs/path/test.f.mjs +11 -11
- package/commonjs/test.mjs +1 -1
- package/dev/module.f.d.mts +1 -4
- package/dev/module.f.mjs +1 -4
- package/dev/module.mjs +1 -1
- package/dev/test/module.f.d.mts +2 -3
- package/dev/test/module.f.mjs +5 -7
- package/djs/module.f.d.mts +13 -18
- package/djs/module.f.mjs +12 -19
- package/djs/parser/module.f.d.mts +53 -37
- package/djs/parser/module.f.mjs +278 -131
- package/djs/parser/test.f.d.mts +4 -0
- package/djs/parser/test.f.mjs +186 -70
- package/djs/test.f.mjs +4 -4
- package/djs/tokenizer/module.f.d.mts +6 -10
- package/djs/tokenizer/module.f.mjs +19 -22
- package/djs/tokenizer/test.f.mjs +7 -7
- package/doc/LANGUAGE.md +17 -16
- package/doc/README.md +14 -50
- package/fsc/README.md +0 -3
- package/fsc/module.f.d.mts +4 -9
- package/fsc/module.f.mjs +17 -24
- package/fsc/test.f.mjs +3 -3
- package/fsm/README.md +1 -1
- package/fsm/module.f.d.mts +13 -20
- package/fsm/module.f.mjs +27 -38
- package/fsm/test.f.mjs +8 -8
- package/html/README.md +24 -0
- package/html/module.f.d.mts +7 -12
- package/html/module.f.mjs +14 -23
- package/html/test.f.mjs +4 -4
- package/issues/01-test-debug.md +3 -0
- package/issues/{publish.md → 05-publish.md} +8 -8
- package/issues/17-djs-extension.md +6 -0
- package/issues/README.md +20 -13
- package/issues/lang/1000-json.md +38 -0
- package/issues/lang/2110-default-export.md +2 -2
- package/issues/lang/2310-undefined.md +1 -1
- package/issues/lang/2330-property-accessor.md +225 -0
- package/issues/lang/2360-built-in.md +54 -47
- package/issues/lang/3240-export.md +44 -0
- package/issues/lang/README.md +64 -22
- package/issues/test.f.d.mts +16 -0
- package/issues/test.f.mjs +57 -0
- package/js/tokenizer/module.f.d.mts +18 -17
- package/js/tokenizer/module.f.mjs +80 -61
- package/js/tokenizer/test.f.mjs +15 -12
- package/json/module.f.d.mts +18 -26
- package/json/module.f.mjs +18 -31
- package/json/parser/module.f.d.mts +9 -13
- package/json/parser/module.f.mjs +9 -14
- package/json/parser/test.f.mjs +7 -7
- package/json/serializer/module.f.d.mts +11 -20
- package/json/serializer/module.f.mjs +14 -29
- package/json/serializer/test.f.mjs +2 -2
- package/json/test.f.mjs +3 -3
- package/json/tokenizer/module.f.d.mts +6 -10
- package/json/tokenizer/module.f.mjs +16 -20
- package/json/tokenizer/test.f.mjs +6 -6
- package/jsr.json +1 -1
- package/nanvm-lib/Cargo.toml +6 -0
- package/nanvm-lib/src/extension.rs +119 -0
- package/nanvm-lib/src/interface.rs +136 -0
- package/nanvm-lib/src/lib.rs +7 -0
- package/nanvm-lib/src/naive.rs +229 -0
- package/nanvm-lib/src/nanenum.rs +230 -0
- package/nanvm-lib/src/nullish.rs +7 -0
- package/nanvm-lib/src/sign.rs +5 -0
- package/nanvm-lib/src/simple.rs +32 -0
- package/nanvm-lib/tests/test.f.d.mts +36 -0
- package/nanvm-lib/tests/test.f.mjs +79 -0
- package/nanvm-lib/tests/test.rs +108 -0
- package/nodejs/version/main.mjs +1 -1
- package/nodejs/version/module.f.d.mts +4 -9
- package/nodejs/version/module.f.mjs +2 -7
- package/nodejs/version/test.f.mjs +3 -3
- package/package.json +1 -1
- package/prime_field/module.f.d.mts +20 -23
- package/prime_field/module.f.mjs +9 -12
- package/prime_field/test.f.mjs +1 -1
- package/secp/module.f.d.mts +27 -28
- package/secp/module.f.mjs +38 -39
- package/secp/test.f.mjs +4 -4
- package/sha2/module.f.d.mts +8 -16
- package/sha2/module.f.mjs +7 -20
- package/sha2/test.f.mjs +4 -4
- package/text/README.md +2 -2
- package/text/ascii/module.f.d.mts +69 -72
- package/text/ascii/module.f.mjs +5 -10
- package/text/ascii/test.f.mjs +3 -3
- package/text/module.f.d.mts +9 -14
- package/text/module.f.mjs +7 -14
- package/text/sgr/module.f.d.mts +7 -9
- package/text/sgr/module.f.mjs +2 -4
- package/text/test.f.mjs +3 -3
- package/text/utf16/module.f.d.mts +8 -15
- package/text/utf16/module.f.mjs +17 -28
- package/text/utf16/test.f.mjs +5 -5
- package/text/utf8/module.f.d.mts +4 -9
- package/text/utf8/module.f.mjs +9 -16
- package/text/utf8/test.f.mjs +4 -4
- package/types/array/module.f.d.mts +14 -24
- package/types/array/module.f.mjs +8 -25
- package/types/array/test.f.mjs +3 -3
- package/types/bigfloat/module.f.d.mts +4 -9
- package/types/bigfloat/module.f.mjs +3 -10
- package/types/bigfloat/test.f.mjs +1 -1
- package/types/bigint/module.f.d.mts +16 -64
- package/types/bigint/module.f.mjs +11 -30
- package/types/bigint/test.f.mjs +1 -1
- package/types/btree/find/module.f.d.mts +20 -26
- package/types/btree/find/module.f.mjs +8 -17
- package/types/btree/find/test.f.mjs +7 -7
- package/types/btree/module.f.d.mts +4 -8
- package/types/btree/module.f.mjs +6 -11
- package/types/btree/remove/module.f.d.mts +7 -12
- package/types/btree/remove/module.f.mjs +10 -17
- package/types/btree/remove/test.f.mjs +5 -5
- package/types/btree/set/module.f.d.mts +3 -7
- package/types/btree/set/module.f.mjs +4 -9
- package/types/btree/set/test.f.mjs +4 -4
- package/types/btree/test.f.mjs +9 -9
- package/types/btree/types/module.f.d.mts +0 -2
- package/types/btree/types/module.f.mjs +0 -2
- package/types/byte_set/module.f.d.mts +16 -29
- package/types/byte_set/module.f.mjs +14 -39
- package/types/byte_set/test.f.mjs +5 -5
- package/types/function/compare/module.f.d.mts +9 -15
- package/types/function/compare/module.f.mjs +3 -12
- package/types/function/compare/test.f.mjs +1 -1
- package/types/function/module.f.d.mts +20 -27
- package/types/function/module.f.mjs +4 -15
- package/types/function/operator/module.f.d.mts +28 -43
- package/types/function/operator/module.f.mjs +14 -41
- package/types/function/test.f.mjs +1 -1
- package/types/list/module.f.d.mts +56 -91
- package/types/list/module.f.mjs +45 -114
- package/types/list/test.f.mjs +10 -10
- package/types/map/module.f.d.mts +15 -24
- package/types/map/module.f.mjs +15 -30
- package/types/map/test.f.mjs +2 -2
- package/types/nibble_set/module.f.d.mts +10 -20
- package/types/nibble_set/module.f.mjs +7 -24
- package/types/nibble_set/test.f.mjs +2 -2
- package/types/nullable/module.f.d.mts +3 -8
- package/types/nullable/module.f.mjs +2 -9
- package/types/nullable/test.f.mjs +1 -1
- package/types/number/module.f.d.mts +7 -13
- package/types/number/module.f.mjs +8 -19
- package/types/number/test.f.mjs +1 -1
- package/types/object/module.f.d.mts +11 -18
- package/types/object/module.f.mjs +9 -20
- package/types/object/test.f.mjs +1 -1
- package/types/range/module.f.d.mts +3 -8
- package/types/range/module.f.mjs +2 -9
- package/types/range/test.f.mjs +1 -1
- package/types/range_map/module.f.d.mts +9 -15
- package/types/range_map/module.f.mjs +9 -18
- package/types/range_map/test.f.mjs +32 -32
- package/types/result/module.d.mts +3 -3
- package/types/result/module.f.d.mts +6 -12
- package/types/result/module.f.mjs +3 -12
- package/types/result/module.mjs +2 -2
- package/types/sorted_list/module.f.d.mts +22 -28
- package/types/sorted_list/module.f.mjs +10 -19
- package/types/sorted_list/test.f.mjs +7 -7
- package/types/sorted_set/module.f.d.mts +6 -12
- package/types/sorted_set/module.f.mjs +7 -16
- package/types/sorted_set/test.f.mjs +7 -7
- package/types/string/module.f.d.mts +8 -14
- package/types/string/module.f.mjs +10 -21
- package/types/string/test.f.mjs +2 -2
- package/types/string_set/module.f.d.mts +8 -16
- package/types/string_set/module.f.mjs +12 -27
- package/types/string_set/test.f.mjs +1 -1
- package/issues/lang/2351-property-accessor.md +0 -44
- package/issues/lang/2352-property-call.md +0 -43
- package/issues/lang/2353-property-at.md +0 -19
- package/issues/test-debug.md +0 -12
- /package/issues/{esm.md → 02-esm.md} +0 -0
- /package/issues/{djs.md → 03-djs.md} +0 -0
- /package/issues/{fs-load.md → 11-fs-load.md} +0 -0
- /package/issues/lang/{2330-grouping.md → 2350-grouping.md} +0 -0
|
@@ -1,117 +1,82 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export let empty: null;
|
|
3
|
-
export { concat };
|
|
4
|
-
export { next };
|
|
5
|
-
export { iterable };
|
|
6
|
-
export { toArray };
|
|
7
|
-
export { flat };
|
|
8
|
-
export { map };
|
|
9
|
-
export { flatMap };
|
|
10
|
-
export { filter };
|
|
11
|
-
export { filterMap };
|
|
12
|
-
export { takeWhile };
|
|
13
|
-
export { take };
|
|
14
|
-
export { dropWhile };
|
|
15
|
-
export { drop };
|
|
16
|
-
export { first };
|
|
17
|
-
export { last };
|
|
18
|
-
export { find };
|
|
19
|
-
export { some };
|
|
20
|
-
export { every };
|
|
21
|
-
export { isEmpty };
|
|
22
|
-
export { includes };
|
|
23
|
-
export { countdown };
|
|
24
|
-
export { repeat };
|
|
25
|
-
export { cycle };
|
|
26
|
-
export { scan };
|
|
27
|
-
export { stateScan };
|
|
28
|
-
export { foldScan };
|
|
29
|
-
export { fold };
|
|
30
|
-
export { reduce };
|
|
31
|
-
export { length };
|
|
32
|
-
export { entries };
|
|
33
|
-
export { reverse };
|
|
34
|
-
export { zip };
|
|
35
|
-
export { equal };
|
|
36
|
-
}
|
|
37
|
-
export default _default;
|
|
38
|
-
export type List<T> = NotLazy<T> | Thunk<T>;
|
|
39
|
-
export type NotLazy<T> = Result<T> | Concat<T> | readonly T[];
|
|
40
|
-
export type Empty = null;
|
|
41
|
-
export type Result<T> = Empty | NonEmpty<T>;
|
|
42
|
-
export type Thunk<T> = () => List<T>;
|
|
43
|
-
export type NonEmpty<T> = {
|
|
44
|
-
readonly first: T;
|
|
45
|
-
readonly tail: List<T>;
|
|
46
|
-
};
|
|
47
|
-
export type Concat<T> = {
|
|
48
|
-
readonly head: List<T>;
|
|
49
|
-
readonly tail: List<T>;
|
|
50
|
-
};
|
|
51
|
-
export type Entry<T> = readonly [number, T];
|
|
52
1
|
/** @type {<T>(head: List<T>) => (tail: List<T>) => List<T>} */
|
|
53
|
-
|
|
2
|
+
export const concat: <T>(head: List<T>) => (tail: List<T>) => List<T>;
|
|
54
3
|
/** @type {<T>(list: List<T>) => Result<T>} */
|
|
55
|
-
|
|
4
|
+
export const next: <T>(list: List<T>) => Result<T>;
|
|
56
5
|
/** @type {<T>(list: List<T>) => Iterable<T>} */
|
|
57
|
-
|
|
6
|
+
export const iterable: <T>(list: List<T>) => Iterable<T>;
|
|
58
7
|
/** @type {<T>(list: List<T>) => readonly T[]} */
|
|
59
|
-
|
|
8
|
+
export const toArray: <T>(list: List<T>) => readonly T[];
|
|
60
9
|
/** @type {<T>(list: List<List<T>>) => Thunk<T>} */
|
|
61
|
-
|
|
10
|
+
export const flat: <T>(list: List<List<T>>) => Thunk<T>;
|
|
62
11
|
/** @type {<I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>} */
|
|
63
|
-
|
|
12
|
+
export const map: <I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>;
|
|
64
13
|
/** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>} */
|
|
65
|
-
|
|
14
|
+
export const flatMap: <I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>;
|
|
66
15
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
67
|
-
|
|
16
|
+
export const filter: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
|
|
68
17
|
/** @type {<I, O>(f: (value: I) => O|null) => (input: List<I>) => Thunk<O>} */
|
|
69
|
-
|
|
18
|
+
export const filterMap: <I, O>(f: (value: I) => O | null) => (input: List<I>) => Thunk<O>;
|
|
70
19
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
71
|
-
|
|
20
|
+
export const takeWhile: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
|
|
72
21
|
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
73
|
-
|
|
22
|
+
export const take: (n: number) => <T>(input: List<T>) => Thunk<T>;
|
|
74
23
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
75
|
-
|
|
24
|
+
export const dropWhile: <T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>;
|
|
76
25
|
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
77
|
-
|
|
26
|
+
export const drop: (n: number) => <T>(input: List<T>) => Thunk<T>;
|
|
78
27
|
/** @type {<D>(def: D) => <T>(input: List<T>) => D|T} */
|
|
79
|
-
|
|
28
|
+
export const first: <D>(def: D) => <T>(input: List<T>) => D | T;
|
|
80
29
|
/** @type {<D>(first: D) => <T>(tail: List<T>) => D|T} */
|
|
81
|
-
|
|
30
|
+
export const last: <D>(first: D) => <T>(tail: List<T>) => D | T;
|
|
82
31
|
/** @type {<D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D|T} */
|
|
83
|
-
|
|
32
|
+
export const find: <D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D | T;
|
|
84
33
|
/** @type {(input: List<boolean>) => boolean} */
|
|
85
|
-
|
|
86
|
-
declare const every: import("../function/module.f.mjs").Func<List<boolean>, boolean>;
|
|
34
|
+
export const some: (input: List<boolean>) => boolean;
|
|
87
35
|
/** @type {<T>(input: List<T>) => boolean} */
|
|
88
|
-
|
|
36
|
+
export const isEmpty: <T>(input: List<T>) => boolean;
|
|
37
|
+
export const every: function_.Func<List<boolean>, boolean>;
|
|
89
38
|
/** @type {<T>(value: T) => (sequence: List<T>) => boolean} */
|
|
90
|
-
|
|
39
|
+
export const includes: <T>(value: T) => (sequence: List<T>) => boolean;
|
|
91
40
|
/** @type {(count: number) => Thunk<number>} */
|
|
92
|
-
|
|
41
|
+
export const countdown: (count: number) => Thunk<number>;
|
|
93
42
|
/** @type {<T>(v: T) => (c: number) => Thunk<T>} */
|
|
94
|
-
|
|
43
|
+
export const repeat: <T>(v: T) => (c: number) => Thunk<T>;
|
|
95
44
|
/** @type {<T>(list: List<T>) => List<T>} */
|
|
96
|
-
|
|
97
|
-
/** @type {<I, O>(op:
|
|
98
|
-
|
|
99
|
-
/** @type {<I, S, O>(op:
|
|
100
|
-
|
|
101
|
-
/** @type {<I,O>(op:
|
|
102
|
-
|
|
103
|
-
/** @type {<I,O>(op:
|
|
104
|
-
|
|
105
|
-
/** @type {<T>(op:
|
|
106
|
-
|
|
45
|
+
export const cycle: <T>(list: List<T>) => List<T>;
|
|
46
|
+
/** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
|
|
47
|
+
export const scan: <I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>;
|
|
48
|
+
/** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
|
|
49
|
+
export const stateScan: <I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>;
|
|
50
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
|
|
51
|
+
export const foldScan: <I, O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>;
|
|
52
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
|
|
53
|
+
export const fold: <I, O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O;
|
|
54
|
+
/** @type {<T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
55
|
+
export const reduce: <T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D | T;
|
|
107
56
|
/** @type {<T>(input: List<T>) => number} */
|
|
108
|
-
|
|
57
|
+
export const length: <T>(input: List<T>) => number;
|
|
109
58
|
/** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
|
|
110
|
-
|
|
59
|
+
export const entries: <T>(input: List<T>) => Thunk<Entry<T>>;
|
|
111
60
|
/** @type {<T>(input: List<T>) => List<T>} */
|
|
112
|
-
|
|
61
|
+
export const reverse: <T>(input: List<T>) => List<T>;
|
|
113
62
|
/** @type {<A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly[A, B]>} */
|
|
114
|
-
|
|
115
|
-
/** @type {<T>(e:
|
|
116
|
-
|
|
117
|
-
|
|
63
|
+
export const zip: <A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly [A, B]>;
|
|
64
|
+
/** @type {<T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
|
|
65
|
+
export const equal: <T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean;
|
|
66
|
+
export const empty: null;
|
|
67
|
+
export type List<T> = NotLazy<T> | Thunk<T>;
|
|
68
|
+
export type NotLazy<T> = Result<T> | Concat<T> | readonly T[];
|
|
69
|
+
export type Empty = null;
|
|
70
|
+
export type Result<T> = Empty | NonEmpty<T>;
|
|
71
|
+
export type Thunk<T> = () => List<T>;
|
|
72
|
+
export type NonEmpty<T> = {
|
|
73
|
+
readonly first: T;
|
|
74
|
+
readonly tail: List<T>;
|
|
75
|
+
};
|
|
76
|
+
export type Concat<T> = {
|
|
77
|
+
readonly head: List<T>;
|
|
78
|
+
readonly tail: List<T>;
|
|
79
|
+
};
|
|
80
|
+
export type Entry<T> = readonly [number, T];
|
|
81
|
+
import * as function_ from '../function/module.f.mjs';
|
|
82
|
+
import * as operator from '../function/operator/module.f.mjs';
|
package/types/list/module.f.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import function_ from '../function/module.f.mjs'
|
|
2
|
+
import * as function_ from '../function/module.f.mjs'
|
|
3
3
|
const { identity, fn, compose } = function_
|
|
4
|
-
import
|
|
4
|
+
import * as operator from '../function/operator/module.f.mjs'
|
|
5
5
|
const {
|
|
6
6
|
addition,
|
|
7
7
|
logicalNot,
|
|
@@ -62,7 +62,7 @@ const fromArray = array => {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/** @type {<T>(head: List<T>) => (tail: List<T>) => List<T>} */
|
|
65
|
-
const concat = head => tail => tail === null ? head : ({ head, tail })
|
|
65
|
+
export const concat = head => tail => tail === null ? head : ({ head, tail })
|
|
66
66
|
|
|
67
67
|
/** @type {<T>(list: List<T>) => NotLazy<T> } */
|
|
68
68
|
const trampoline = list => {
|
|
@@ -71,7 +71,7 @@ const trampoline = list => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** @type {<T>(list: List<T>) => Result<T>} */
|
|
74
|
-
const next = head => {
|
|
74
|
+
export const next = head => {
|
|
75
75
|
/** @type {typeof head} */
|
|
76
76
|
let tail = null
|
|
77
77
|
while (true) {
|
|
@@ -95,7 +95,7 @@ const next = head => {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/** @type {<T>(list: List<T>) => Iterable<T>} */
|
|
98
|
-
const iterable = list => ({
|
|
98
|
+
export const iterable = list => ({
|
|
99
99
|
*[Symbol.iterator]() {
|
|
100
100
|
let i = list
|
|
101
101
|
while (true) {
|
|
@@ -110,7 +110,7 @@ const iterable = list => ({
|
|
|
110
110
|
const { from } = Array
|
|
111
111
|
|
|
112
112
|
/** @type {<T>(list: List<T>) => readonly T[]} */
|
|
113
|
-
const toArray = list => {
|
|
113
|
+
export const toArray = list => {
|
|
114
114
|
const u = trampoline(list)
|
|
115
115
|
return u instanceof Array ? u : from(iterable(u))
|
|
116
116
|
}
|
|
@@ -126,16 +126,16 @@ const apply = f => input => () => {
|
|
|
126
126
|
const flatStep = ({ first, tail }) => concat(first)(flat(tail))
|
|
127
127
|
|
|
128
128
|
/** @type {<T>(list: List<List<T>>) => Thunk<T>} */
|
|
129
|
-
const flat = apply(flatStep)
|
|
129
|
+
export const flat = apply(flatStep)
|
|
130
130
|
|
|
131
131
|
/** @type {<I, O>(f: (value: I) => O) => (n: NonEmpty<I>) => List<O>} */
|
|
132
132
|
const mapStep = f => ({ first, tail }) => ({ first: f(first), tail: map(f)(tail) })
|
|
133
133
|
|
|
134
134
|
/** @type {<I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>} */
|
|
135
|
-
const map = f => apply(mapStep(f))
|
|
135
|
+
export const map = f => apply(mapStep(f))
|
|
136
136
|
|
|
137
137
|
/** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>} */
|
|
138
|
-
const flatMap = f => compose(map(f))(flat)
|
|
138
|
+
export const flatMap = f => compose(map(f))(flat)
|
|
139
139
|
|
|
140
140
|
/** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
|
|
141
141
|
const filterStep = f => ({ first, tail }) => {
|
|
@@ -144,7 +144,7 @@ const filterStep = f => ({ first, tail }) => {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
147
|
-
const filter = f => apply(filterStep(f))
|
|
147
|
+
export const filter = f => apply(filterStep(f))
|
|
148
148
|
|
|
149
149
|
/** @type {<I, O>(f: (value: I) => O|null) => (n: NonEmpty<I>) => List<O>} */
|
|
150
150
|
const filterMapStep = f => n => {
|
|
@@ -153,40 +153,40 @@ const filterMapStep = f => n => {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/** @type {<I, O>(f: (value: I) => O|null) => (input: List<I>) => Thunk<O>} */
|
|
156
|
-
const filterMap = f => apply(filterMapStep(f))
|
|
156
|
+
export const filterMap = f => apply(filterMapStep(f))
|
|
157
157
|
|
|
158
158
|
/** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
|
|
159
159
|
const takeWhileStep = f => ({ first, tail }) => f(first) ? { first, tail: takeWhile(f)(tail) } : null
|
|
160
160
|
|
|
161
161
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
162
|
-
const takeWhile = f => apply(takeWhileStep(f))
|
|
162
|
+
export const takeWhile = f => apply(takeWhileStep(f))
|
|
163
163
|
|
|
164
164
|
/** @type {(n: number) => <T>(result: NonEmpty<T>) => List<T>} */
|
|
165
165
|
const takeStep = n => ({ first, tail }) => 0 < n ? { first: first, tail: take(n - 1)(tail) } : null
|
|
166
166
|
|
|
167
167
|
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
168
|
-
const take = n => apply(takeStep(n))
|
|
168
|
+
export const take = n => apply(takeStep(n))
|
|
169
169
|
|
|
170
170
|
/** @type {<T>(f: (value: T) => boolean) => (ne: NonEmpty<T>) => List<T>} */
|
|
171
171
|
const dropWhileStep = f => ne => f(ne.first) ? dropWhile(f)(ne.tail) : ne
|
|
172
172
|
|
|
173
173
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
174
|
-
const dropWhile = f => apply(dropWhileStep(f))
|
|
174
|
+
export const dropWhile = f => apply(dropWhileStep(f))
|
|
175
175
|
|
|
176
176
|
/** @type {(n: number) => <T>(ne: NonEmpty<T>) => List<T>} */
|
|
177
177
|
const dropStep = n => ne => 0 < n ? drop(n - 1)(ne.tail) : ne
|
|
178
178
|
|
|
179
179
|
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
180
|
-
const drop = n => apply(dropStep(n))
|
|
180
|
+
export const drop = n => apply(dropStep(n))
|
|
181
181
|
|
|
182
182
|
/** @type {<D>(def: D) => <T>(input: List<T>) => D|T} */
|
|
183
|
-
const first = def => input => {
|
|
183
|
+
export const first = def => input => {
|
|
184
184
|
const ne = next(input)
|
|
185
185
|
return ne === null ? def : ne.first
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/** @type {<D>(first: D) => <T>(tail: List<T>) => D|T} */
|
|
189
|
-
const last = first => tail => {
|
|
189
|
+
export const last = first => tail => {
|
|
190
190
|
/** @typedef {typeof tail extends List<infer T> ? T : never} T */
|
|
191
191
|
/** @type {NonEmpty<typeof first|T>} */
|
|
192
192
|
let i = { first, tail }
|
|
@@ -200,61 +200,61 @@ const last = first => tail => {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/** @type {<D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D|T} */
|
|
203
|
-
const find = def => f => compose(filter(f))(first(def))
|
|
203
|
+
export const find = def => f => compose(filter(f))(first(def))
|
|
204
204
|
|
|
205
205
|
/** @type {(input: List<boolean>) => boolean} */
|
|
206
|
-
const some = find(false)(identity)
|
|
206
|
+
export const some = find(false)(identity)
|
|
207
207
|
|
|
208
208
|
/** @type {<T>(input: List<T>) => boolean} */
|
|
209
|
-
const isEmpty = fn(map(() => true))
|
|
209
|
+
export const isEmpty = fn(map(() => true))
|
|
210
210
|
.then(some)
|
|
211
211
|
.then(logicalNot)
|
|
212
212
|
.result
|
|
213
213
|
|
|
214
|
-
const every = fn(map(logicalNot))
|
|
214
|
+
export const every = fn(map(logicalNot))
|
|
215
215
|
.then(some)
|
|
216
216
|
.then(logicalNot)
|
|
217
217
|
.result
|
|
218
218
|
|
|
219
219
|
/** @type {<T>(value: T) => (sequence: List<T>) => boolean} */
|
|
220
|
-
const includes = value => compose(map(strictEqual(value)))(some)
|
|
220
|
+
export const includes = value => compose(map(strictEqual(value)))(some)
|
|
221
221
|
|
|
222
222
|
/** @type {(count: number) => Thunk<number>} */
|
|
223
|
-
const countdown = count => () => {
|
|
223
|
+
export const countdown = count => () => {
|
|
224
224
|
if (count <= 0) { return null }
|
|
225
225
|
const first = count - 1
|
|
226
226
|
return { first, tail: countdown(first) }
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/** @type {<T>(v: T) => (c: number) => Thunk<T>} */
|
|
230
|
-
const repeat = v => compose(countdown)(map(() => v))
|
|
230
|
+
export const repeat = v => compose(countdown)(map(() => v))
|
|
231
231
|
|
|
232
232
|
/** @type {<T>(list: List<T>) => List<T>} */
|
|
233
|
-
const cycle = list => () => {
|
|
233
|
+
export const cycle = list => () => {
|
|
234
234
|
const i = next(list)
|
|
235
235
|
return i === null ? null : { first: i.first, tail: concat(i.tail)(cycle(list)) }
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
/** @type {<I, O>(op:
|
|
238
|
+
/** @type {<I, O>(op: operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>} */
|
|
239
239
|
const scanStep = op => ne => {
|
|
240
240
|
const [first, newOp] = op(ne.first)
|
|
241
241
|
return { first, tail: scan(newOp)(ne.tail) }
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
/** @type {<I, O>(op:
|
|
245
|
-
const scan = op => apply(scanStep(op))
|
|
244
|
+
/** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
|
|
245
|
+
export const scan = op => apply(scanStep(op))
|
|
246
246
|
|
|
247
|
-
/** @type {<I, S, O>(op:
|
|
248
|
-
const stateScan = op => compose(stateScanToScan(op))(scan)
|
|
247
|
+
/** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
|
|
248
|
+
export const stateScan = op => compose(stateScanToScan(op))(scan)
|
|
249
249
|
|
|
250
|
-
/** @type {<I,O>(op:
|
|
251
|
-
const foldScan = op => compose(foldToScan(op))(scan)
|
|
250
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
|
|
251
|
+
export const foldScan = op => compose(foldToScan(op))(scan)
|
|
252
252
|
|
|
253
|
-
/** @type {<I,O>(op:
|
|
254
|
-
const fold = op => init => compose(foldScan(op)(init))(last(init))
|
|
253
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
|
|
254
|
+
export const fold = op => init => compose(foldScan(op)(init))(last(init))
|
|
255
255
|
|
|
256
|
-
/** @type {<T>(op:
|
|
257
|
-
const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
|
|
256
|
+
/** @type {<T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
257
|
+
export const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
|
|
258
258
|
|
|
259
259
|
/** @type {<T>(list: List<T>) => Thunk<number>} */
|
|
260
260
|
const lengthList = list => () => {
|
|
@@ -271,7 +271,7 @@ const lengthList = list => () => {
|
|
|
271
271
|
const sum = reduce(addition)(0)
|
|
272
272
|
|
|
273
273
|
/** @type {<T>(input: List<T>) => number} */
|
|
274
|
-
const length = compose(lengthList)(sum)
|
|
274
|
+
export const length = compose(lengthList)(sum)
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
277
|
* @template T
|
|
@@ -282,9 +282,9 @@ const length = compose(lengthList)(sum)
|
|
|
282
282
|
const entryOperator = index => value => [[index, value], index + 1]
|
|
283
283
|
|
|
284
284
|
/** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
|
|
285
|
-
const entries = input => {
|
|
285
|
+
export const entries = input => {
|
|
286
286
|
/** @typedef {typeof input extends List<infer T> ? T : never} T */
|
|
287
|
-
/** @type {
|
|
287
|
+
/** @type {operator.StateScan<T, Number, Entry<T>>} */
|
|
288
288
|
const o = entryOperator
|
|
289
289
|
return stateScan(o)(0)(input)
|
|
290
290
|
}
|
|
@@ -293,10 +293,10 @@ const entries = input => {
|
|
|
293
293
|
const reverseOperator = first => tail => ({ first, tail })
|
|
294
294
|
|
|
295
295
|
/** @type {<T>(input: List<T>) => List<T>} */
|
|
296
|
-
const reverse = fold(reverseOperator)(null)
|
|
296
|
+
export const reverse = fold(reverseOperator)(null)
|
|
297
297
|
|
|
298
298
|
/** @type {<A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly[A, B]>} */
|
|
299
|
-
const zip = a => b => () => {
|
|
299
|
+
export const zip = a => b => () => {
|
|
300
300
|
const aResult = next(a)
|
|
301
301
|
if (aResult === null) { return null }
|
|
302
302
|
const bResult = next(b)
|
|
@@ -304,9 +304,9 @@ const zip = a => b => () => {
|
|
|
304
304
|
return { first: [aResult.first, bResult.first], tail: zip(aResult.tail)(bResult.tail) }
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
/** @type {<T>(e:
|
|
308
|
-
const equal = e => {
|
|
309
|
-
/** @typedef {typeof e extends
|
|
307
|
+
/** @type {<T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
|
|
308
|
+
export const equal = e => {
|
|
309
|
+
/** @typedef {typeof e extends operator.Equal<infer T> ? T : never} T */
|
|
310
310
|
/** @type {(a: List<T>) => (b: List<T>) => List<boolean>} */
|
|
311
311
|
const f = a => b => () => {
|
|
312
312
|
const [aResult, bResult] = [next(a), next(b)]
|
|
@@ -317,73 +317,4 @@ const equal = e => {
|
|
|
317
317
|
return a => b => every(f(a)(b))
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
export
|
|
321
|
-
/** @readonly */
|
|
322
|
-
empty: null,
|
|
323
|
-
/** @readonly */
|
|
324
|
-
concat,
|
|
325
|
-
/** @readonly */
|
|
326
|
-
next,
|
|
327
|
-
/** @readonly */
|
|
328
|
-
iterable,
|
|
329
|
-
/** @readonly */
|
|
330
|
-
toArray,
|
|
331
|
-
/** @readonly */
|
|
332
|
-
flat,
|
|
333
|
-
/** @readonly */
|
|
334
|
-
map,
|
|
335
|
-
/** @readonly */
|
|
336
|
-
flatMap,
|
|
337
|
-
/** @readonly */
|
|
338
|
-
filter,
|
|
339
|
-
/** @readonly */
|
|
340
|
-
filterMap,
|
|
341
|
-
/** @readonly */
|
|
342
|
-
takeWhile,
|
|
343
|
-
/** @readonly */
|
|
344
|
-
take,
|
|
345
|
-
/** @readonly */
|
|
346
|
-
dropWhile,
|
|
347
|
-
/** @readonly */
|
|
348
|
-
drop,
|
|
349
|
-
/** @readonly */
|
|
350
|
-
first,
|
|
351
|
-
/** @readonly */
|
|
352
|
-
last,
|
|
353
|
-
/** @readonly */
|
|
354
|
-
find,
|
|
355
|
-
/** @readonly */
|
|
356
|
-
some,
|
|
357
|
-
/** @readonly */
|
|
358
|
-
every,
|
|
359
|
-
/** @readonly */
|
|
360
|
-
isEmpty,
|
|
361
|
-
/** @readonly */
|
|
362
|
-
includes,
|
|
363
|
-
/** @readonly */
|
|
364
|
-
countdown,
|
|
365
|
-
/** @readonly */
|
|
366
|
-
repeat,
|
|
367
|
-
/** @readonly */
|
|
368
|
-
cycle,
|
|
369
|
-
/** @readonly */
|
|
370
|
-
scan,
|
|
371
|
-
/** @readonly */
|
|
372
|
-
stateScan,
|
|
373
|
-
/** @readonly */
|
|
374
|
-
foldScan,
|
|
375
|
-
/** @readonly */
|
|
376
|
-
fold,
|
|
377
|
-
/** @readonly */
|
|
378
|
-
reduce,
|
|
379
|
-
/** @readonly */
|
|
380
|
-
length,
|
|
381
|
-
/** @readonly */
|
|
382
|
-
entries,
|
|
383
|
-
/** @readonly */
|
|
384
|
-
reverse,
|
|
385
|
-
/** @readonly */
|
|
386
|
-
zip,
|
|
387
|
-
/** @readonly */
|
|
388
|
-
equal
|
|
389
|
-
}
|
|
320
|
+
export const empty = null
|
package/types/list/test.f.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import o
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
|
+
import * as json from '../../json/module.f.mjs'
|
|
3
|
+
import * as o from '../object/module.f.mjs'
|
|
4
4
|
const { sort } = o
|
|
5
|
-
import operator from '../function/operator/module.f.mjs'
|
|
5
|
+
import * as operator from '../function/operator/module.f.mjs'
|
|
6
6
|
const { addition, strictEqual, reduceToScan } = operator
|
|
7
7
|
|
|
8
|
-
/** @type {(sequence:
|
|
8
|
+
/** @type {(sequence: _.List<json.Unknown>) => string} */
|
|
9
9
|
const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
10
10
|
|
|
11
11
|
const stringifyTest = () => {
|
|
@@ -197,7 +197,7 @@ const stress = () => ({
|
|
|
197
197
|
if (first !== n - 1) { throw first }
|
|
198
198
|
},
|
|
199
199
|
concatBack: () => {
|
|
200
|
-
/** @type {
|
|
200
|
+
/** @type {_.List<number>} */
|
|
201
201
|
let sequence = []
|
|
202
202
|
// 20_000_000 is too much
|
|
203
203
|
// 10_000_000 is too much for Deno 1
|
|
@@ -207,7 +207,7 @@ const stress = () => ({
|
|
|
207
207
|
const r = _.toArray(sequence)
|
|
208
208
|
},
|
|
209
209
|
flatToArray: () => {
|
|
210
|
-
/** @type {
|
|
210
|
+
/** @type {_.List<number>} */
|
|
211
211
|
let sequence = []
|
|
212
212
|
// 4_000_000 is too much
|
|
213
213
|
for (let i = 0; i < 2_000_000; ++i) {
|
|
@@ -216,7 +216,7 @@ const stress = () => ({
|
|
|
216
216
|
const r = _.toArray(sequence)
|
|
217
217
|
},
|
|
218
218
|
flatNext: () => {
|
|
219
|
-
/** @type {
|
|
219
|
+
/** @type {_.List<number>} */
|
|
220
220
|
let sequence = []
|
|
221
221
|
// 4_000_000 is too much
|
|
222
222
|
for (let i = 0; i < 2_000_000; ++i) {
|
|
@@ -225,7 +225,7 @@ const stress = () => ({
|
|
|
225
225
|
const a = _.next(sequence)
|
|
226
226
|
},
|
|
227
227
|
concatFront: () => {
|
|
228
|
-
/** @type {
|
|
228
|
+
/** @type {_.List<number>} */
|
|
229
229
|
let sequence = []
|
|
230
230
|
// 20_000_000 is too much
|
|
231
231
|
for (let i = 0; i < 10_000_000; ++i) {
|
|
@@ -234,7 +234,7 @@ const stress = () => ({
|
|
|
234
234
|
const a = _.next(sequence)
|
|
235
235
|
},
|
|
236
236
|
flatFront: () => {
|
|
237
|
-
/** @type {
|
|
237
|
+
/** @type {_.List<number>} */
|
|
238
238
|
let sequence = []
|
|
239
239
|
// 10_000_000 is too much
|
|
240
240
|
for (let i = 0; i < 5_000_000; ++i) {
|
package/types/map/module.f.d.mts
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export let empty: null;
|
|
3
|
-
export { at };
|
|
4
|
-
export { setReduce };
|
|
5
|
-
export { setReplace };
|
|
6
|
-
export { entries };
|
|
7
|
-
export { fromEntries };
|
|
8
|
-
export { remove };
|
|
9
|
-
}
|
|
10
|
-
export default _default;
|
|
11
|
-
export type Sign = Compare.Sign;
|
|
12
|
-
export type Cmp<T> = Compare.Compare<T>;
|
|
13
|
-
export type Entry<T> = readonly [string, T];
|
|
14
|
-
export type Map<T> = BtreeTypes.Tree<Entry<T>>;
|
|
15
1
|
/** @type {(name: string) => <T>(map: Map<T>) => T|null} */
|
|
16
|
-
|
|
2
|
+
export const at: (name: string) => <T>(map: Map<T>) => T | null;
|
|
17
3
|
/** @type {<T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>} */
|
|
18
|
-
|
|
4
|
+
export const setReduce: <T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>;
|
|
19
5
|
/** @type {(name: string) => <T>(value: T) => (map: Map<T>) => Map<T>} */
|
|
20
|
-
|
|
21
|
-
/** @type {<T>(map: Map<T>) =>
|
|
22
|
-
|
|
23
|
-
/** @type {<T>(entries:
|
|
24
|
-
|
|
6
|
+
export const setReplace: (name: string) => <T>(value: T) => (map: Map<T>) => Map<T>;
|
|
7
|
+
/** @type {<T>(map: Map<T>) => list.List<Entry<T>>} */
|
|
8
|
+
export const entries: <T>(map: Map<T>) => list.List<Entry<T>>;
|
|
9
|
+
/** @type {<T>(entries: list.List<Entry<T>>) => Map<T>} */
|
|
10
|
+
export const fromEntries: <T>(entries: list.List<Entry<T>>) => Map<T>;
|
|
25
11
|
/** @type {(name: string) => <T>(map: Map<T>) => Map<T>} */
|
|
26
|
-
|
|
12
|
+
export const remove: (name: string) => <T>(map: Map<T>) => Map<T>;
|
|
13
|
+
export const empty: null;
|
|
14
|
+
export type Sign = Compare.Sign;
|
|
15
|
+
export type Cmp<T> = Compare.Compare<T>;
|
|
16
|
+
export type Entry<T> = readonly [string, T];
|
|
17
|
+
export type Map<T> = BtreeTypes.Tree<Entry<T>>;
|
|
18
|
+
import * as Operator from '../function/operator/module.f.mjs';
|
|
19
|
+
import * as list from '../list/module.f.mjs';
|
|
27
20
|
import * as Compare from '../function/compare/module.f.mjs';
|
|
28
21
|
import * as BtreeTypes from '../btree/types/module.f.mjs';
|
|
29
|
-
import * as Operator from '../function/operator/module.f.mjs';
|
|
30
|
-
import * as List from '../list/module.f.mjs';
|