functionalscript 0.1.604 → 0.1.606
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/com/cpp/module.f.mjs +1 -0
- package/com/cs/module.f.mjs +1 -0
- package/com/rust/module.f.mjs +1 -0
- package/com/types/module.f.mjs +1 -0
- package/commonjs/build/module.f.mjs +2 -1
- package/commonjs/module/function/module.f.d.mts +3 -3
- package/commonjs/module/function/module.f.mjs +5 -3
- package/commonjs/module/module.f.mjs +1 -0
- package/commonjs/module.f.mjs +2 -0
- package/commonjs/package/dependencies/module.f.mjs +1 -0
- package/commonjs/package/module.f.mjs +1 -0
- package/commonjs/path/module.f.mjs +1 -0
- package/dev/module.f.mjs +2 -0
- package/dev/module.mjs +5 -1
- package/dev/test/module.f.mjs +1 -0
- package/djs/module.f.mjs +2 -0
- package/djs/parser/module.f.mjs +2 -0
- package/djs/tokenizer/module.f.mjs +2 -0
- package/fsc/module.f.mjs +1 -0
- package/fsm/module.f.mjs +1 -0
- package/html/module.f.mjs +1 -0
- package/js/tokenizer/module.f.mjs +1 -0
- package/json/module.f.mjs +1 -0
- package/json/parser/module.f.mjs +1 -0
- package/json/serializer/module.f.mjs +1 -0
- package/json/tokenizer/module.f.mjs +1 -0
- package/jsr.json +59 -114
- package/nodejs/version/module.f.mjs +2 -0
- package/package.json +1 -1
- package/prime_field/module.f.mjs +1 -0
- package/secp/module.f.mjs +1 -0
- package/sha2/module.f.mjs +1 -0
- package/text/ascii/module.f.mjs +1 -0
- package/text/module.f.mjs +1 -0
- package/text/sgr/module.f.mjs +2 -0
- package/text/utf16/module.f.mjs +1 -0
- package/text/utf8/module.f.mjs +1 -0
- package/types/array/module.f.mjs +1 -0
- package/types/bigfloat/module.f.mjs +1 -0
- package/types/bigint/module.f.mjs +1 -0
- package/types/btree/find/module.f.mjs +1 -0
- package/types/btree/module.f.mjs +2 -0
- package/types/btree/remove/module.f.mjs +1 -0
- package/types/btree/set/module.f.mjs +1 -0
- package/types/btree/types/module.f.mjs +2 -0
- package/types/byte_set/module.f.mjs +1 -0
- package/types/function/compare/module.f.mjs +1 -0
- package/types/function/module.f.d.mts +33 -3
- package/types/function/module.f.mjs +29 -3
- package/types/function/operator/module.f.mjs +1 -0
- package/types/map/module.f.mjs +1 -0
- package/types/nibble_set/module.f.mjs +1 -0
- package/types/nullable/module.f.mjs +1 -0
- package/types/number/module.f.mjs +1 -0
- package/types/object/module.f.d.mts +3 -3
- package/types/object/module.f.mjs +4 -3
- package/types/range/module.f.mjs +1 -0
- package/types/range_map/module.f.mjs +1 -0
- package/types/result/module.f.mjs +1 -0
- package/types/sorted_list/module.f.mjs +1 -0
- package/types/sorted_set/module.f.mjs +1 -0
- package/types/string/module.f.mjs +1 -0
- package/types/string_set/module.f.mjs +1 -0
package/com/cpp/module.f.mjs
CHANGED
package/com/cs/module.f.mjs
CHANGED
package/com/rust/module.f.mjs
CHANGED
package/com/types/module.f.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
import * as packageT from '../package/module.f.mjs'
|
|
2
3
|
import module_, * as moduleT from '../module/module.f.mjs'
|
|
3
4
|
const { idToString, dir } = module_
|
|
4
5
|
import * as function_ from '../module/function/module.f.mjs'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const _default: {};
|
|
2
2
|
export default _default;
|
|
3
3
|
export type Function_ = <M>(require: Require<M>) => (prior: M) => Result<M>;
|
|
4
|
-
export type Result<M> = readonly [
|
|
4
|
+
export type Result<M> = readonly [TypesResult.Result<unknown, unknown>, M];
|
|
5
5
|
export type Require<M> = (path: string) => (prior: M) => Result<M>;
|
|
6
|
-
export type Compile = (source: string) =>
|
|
7
|
-
import * as
|
|
6
|
+
export type Compile = (source: string) => TypesResult.Result<Function_, unknown>;
|
|
7
|
+
import * as TypesResult from '../../../types/result/module.f.mjs';
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* An IO interface for creating and running module functions.
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
|
-
import * as
|
|
7
|
+
import * as TypesResult from '../../../types/result/module.f.mjs'
|
|
6
8
|
|
|
7
9
|
/** @typedef {<M>(require: Require<M>) => (prior: M) => Result<M>} Function_ */
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @template M
|
|
11
|
-
* @typedef {readonly[
|
|
13
|
+
* @typedef {readonly[TypesResult.Result<unknown, unknown>, M]} Result
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -16,6 +18,6 @@ import * as Result from '../../../types/result/module.f.mjs'
|
|
|
16
18
|
* @typedef {(path: string) => (prior: M) => Result<M>} Require
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
|
-
/** @typedef {(source: string) =>
|
|
21
|
+
/** @typedef {(source: string) => TypesResult.Result<Function_, unknown>} Compile */
|
|
20
22
|
|
|
21
23
|
export default {}
|
package/commonjs/module.f.mjs
CHANGED
package/dev/module.f.mjs
CHANGED
package/dev/module.mjs
CHANGED
|
@@ -181,8 +181,12 @@ const codeAdd = i => p => m => {
|
|
|
181
181
|
export const index = async () => {
|
|
182
182
|
{
|
|
183
183
|
const jj = './jsr.json'
|
|
184
|
+
const n = '/module.f.mjs'
|
|
184
185
|
const jsr_json = JSON.parse(await readFile(jj, { encoding: 'utf8' }))
|
|
185
|
-
const
|
|
186
|
+
const exportsA = Object.keys(await loadModuleMap())
|
|
187
|
+
.filter(v => v.endsWith(n))
|
|
188
|
+
.map(v => [v.replace(n, ''), v])
|
|
189
|
+
const exports = Object.fromEntries(exportsA)
|
|
186
190
|
await writeFile(
|
|
187
191
|
jj,
|
|
188
192
|
JSON.stringify({ ...jsr_json, exports }, null, 2))
|
package/dev/test/module.f.mjs
CHANGED
package/djs/module.f.mjs
CHANGED
package/djs/parser/module.f.mjs
CHANGED
package/fsc/module.f.mjs
CHANGED
package/fsm/module.f.mjs
CHANGED
package/html/module.f.mjs
CHANGED
package/json/module.f.mjs
CHANGED
package/json/parser/module.f.mjs
CHANGED
package/jsr.json
CHANGED
|
@@ -1,119 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionalscript/functionalscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.606",
|
|
4
4
|
"exports": {
|
|
5
|
-
"./com/cpp
|
|
6
|
-
"./com/
|
|
7
|
-
"./com/
|
|
8
|
-
"./com/
|
|
9
|
-
"./
|
|
10
|
-
"./
|
|
11
|
-
"./
|
|
12
|
-
"./
|
|
13
|
-
"./
|
|
14
|
-
"./
|
|
15
|
-
"./
|
|
16
|
-
"./
|
|
17
|
-
"./
|
|
18
|
-
"./
|
|
19
|
-
"./
|
|
20
|
-
"./
|
|
21
|
-
"./
|
|
22
|
-
"./
|
|
23
|
-
"./
|
|
24
|
-
"./
|
|
25
|
-
"./
|
|
26
|
-
"./
|
|
27
|
-
"./
|
|
28
|
-
"./
|
|
29
|
-
"./
|
|
30
|
-
"./
|
|
31
|
-
"./
|
|
32
|
-
"./
|
|
33
|
-
"./
|
|
34
|
-
"./
|
|
35
|
-
"./
|
|
36
|
-
"./
|
|
37
|
-
"./
|
|
38
|
-
"./
|
|
39
|
-
"./
|
|
40
|
-
"./
|
|
41
|
-
"./
|
|
42
|
-
"./
|
|
43
|
-
"./
|
|
44
|
-
"./
|
|
45
|
-
"./
|
|
46
|
-
"./
|
|
47
|
-
"./
|
|
48
|
-
"./
|
|
49
|
-
"./
|
|
50
|
-
"./
|
|
51
|
-
"./
|
|
52
|
-
"./
|
|
53
|
-
"./
|
|
54
|
-
"./
|
|
55
|
-
"./
|
|
56
|
-
"./
|
|
57
|
-
"./
|
|
58
|
-
"./
|
|
59
|
-
"./
|
|
60
|
-
"./
|
|
61
|
-
"./
|
|
62
|
-
"./
|
|
63
|
-
"./text/ascii/test": "./text/ascii/test.f.mjs",
|
|
64
|
-
"./text/module": "./text/module.f.mjs",
|
|
65
|
-
"./text/sgr/module": "./text/sgr/module.f.mjs",
|
|
66
|
-
"./text/test": "./text/test.f.mjs",
|
|
67
|
-
"./text/utf16/module": "./text/utf16/module.f.mjs",
|
|
68
|
-
"./text/utf16/test": "./text/utf16/test.f.mjs",
|
|
69
|
-
"./text/utf8/module": "./text/utf8/module.f.mjs",
|
|
70
|
-
"./text/utf8/test": "./text/utf8/test.f.mjs",
|
|
71
|
-
"./types/array/module": "./types/array/module.f.mjs",
|
|
72
|
-
"./types/array/test": "./types/array/test.f.mjs",
|
|
73
|
-
"./types/bigfloat/module": "./types/bigfloat/module.f.mjs",
|
|
74
|
-
"./types/bigfloat/test": "./types/bigfloat/test.f.mjs",
|
|
75
|
-
"./types/bigint/module": "./types/bigint/module.f.mjs",
|
|
76
|
-
"./types/bigint/test": "./types/bigint/test.f.mjs",
|
|
77
|
-
"./types/btree/find/module": "./types/btree/find/module.f.mjs",
|
|
78
|
-
"./types/btree/find/test": "./types/btree/find/test.f.mjs",
|
|
79
|
-
"./types/btree/module": "./types/btree/module.f.mjs",
|
|
80
|
-
"./types/btree/remove/module": "./types/btree/remove/module.f.mjs",
|
|
81
|
-
"./types/btree/remove/test": "./types/btree/remove/test.f.mjs",
|
|
82
|
-
"./types/btree/set/module": "./types/btree/set/module.f.mjs",
|
|
83
|
-
"./types/btree/set/test": "./types/btree/set/test.f.mjs",
|
|
84
|
-
"./types/btree/test": "./types/btree/test.f.mjs",
|
|
85
|
-
"./types/btree/types/module": "./types/btree/types/module.f.mjs",
|
|
86
|
-
"./types/byte_set/module": "./types/byte_set/module.f.mjs",
|
|
87
|
-
"./types/byte_set/test": "./types/byte_set/test.f.mjs",
|
|
88
|
-
"./types/function/compare/module": "./types/function/compare/module.f.mjs",
|
|
89
|
-
"./types/function/compare/test": "./types/function/compare/test.f.mjs",
|
|
90
|
-
"./types/function/module": "./types/function/module.f.mjs",
|
|
91
|
-
"./types/function/operator/module": "./types/function/operator/module.f.mjs",
|
|
92
|
-
"./types/function/test": "./types/function/test.f.mjs",
|
|
93
|
-
"./types/list/module": "./types/list/module.f.mjs",
|
|
94
|
-
"./types/list/test": "./types/list/test.f.mjs",
|
|
95
|
-
"./types/map/module": "./types/map/module.f.mjs",
|
|
96
|
-
"./types/map/test": "./types/map/test.f.mjs",
|
|
97
|
-
"./types/nibble_set/module": "./types/nibble_set/module.f.mjs",
|
|
98
|
-
"./types/nibble_set/test": "./types/nibble_set/test.f.mjs",
|
|
99
|
-
"./types/nullable/module": "./types/nullable/module.f.mjs",
|
|
100
|
-
"./types/nullable/test": "./types/nullable/test.f.mjs",
|
|
101
|
-
"./types/number/module": "./types/number/module.f.mjs",
|
|
102
|
-
"./types/number/test": "./types/number/test.f.mjs",
|
|
103
|
-
"./types/object/module": "./types/object/module.f.mjs",
|
|
104
|
-
"./types/object/test": "./types/object/test.f.mjs",
|
|
105
|
-
"./types/range/module": "./types/range/module.f.mjs",
|
|
106
|
-
"./types/range/test": "./types/range/test.f.mjs",
|
|
107
|
-
"./types/range_map/module": "./types/range_map/module.f.mjs",
|
|
108
|
-
"./types/range_map/test": "./types/range_map/test.f.mjs",
|
|
109
|
-
"./types/result/module": "./types/result/module.f.mjs",
|
|
110
|
-
"./types/sorted_list/module": "./types/sorted_list/module.f.mjs",
|
|
111
|
-
"./types/sorted_list/test": "./types/sorted_list/test.f.mjs",
|
|
112
|
-
"./types/sorted_set/module": "./types/sorted_set/module.f.mjs",
|
|
113
|
-
"./types/sorted_set/test": "./types/sorted_set/test.f.mjs",
|
|
114
|
-
"./types/string/module": "./types/string/module.f.mjs",
|
|
115
|
-
"./types/string/test": "./types/string/test.f.mjs",
|
|
116
|
-
"./types/string_set/module": "./types/string_set/module.f.mjs",
|
|
117
|
-
"./types/string_set/test": "./types/string_set/test.f.mjs"
|
|
5
|
+
"./com/cpp": "./com/cpp/module.f.mjs",
|
|
6
|
+
"./com/cs": "./com/cs/module.f.mjs",
|
|
7
|
+
"./com/rust": "./com/rust/module.f.mjs",
|
|
8
|
+
"./com/types": "./com/types/module.f.mjs",
|
|
9
|
+
"./commonjs/build": "./commonjs/build/module.f.mjs",
|
|
10
|
+
"./commonjs": "./commonjs/module.f.mjs",
|
|
11
|
+
"./commonjs/module/function": "./commonjs/module/function/module.f.mjs",
|
|
12
|
+
"./commonjs/module": "./commonjs/module/module.f.mjs",
|
|
13
|
+
"./commonjs/package/dependencies": "./commonjs/package/dependencies/module.f.mjs",
|
|
14
|
+
"./commonjs/package": "./commonjs/package/module.f.mjs",
|
|
15
|
+
"./commonjs/path": "./commonjs/path/module.f.mjs",
|
|
16
|
+
"./dev": "./dev/module.f.mjs",
|
|
17
|
+
"./dev/test": "./dev/test/module.f.mjs",
|
|
18
|
+
"./djs": "./djs/module.f.mjs",
|
|
19
|
+
"./djs/parser": "./djs/parser/module.f.mjs",
|
|
20
|
+
"./djs/tokenizer": "./djs/tokenizer/module.f.mjs",
|
|
21
|
+
"./fsc": "./fsc/module.f.mjs",
|
|
22
|
+
"./fsm": "./fsm/module.f.mjs",
|
|
23
|
+
"./html": "./html/module.f.mjs",
|
|
24
|
+
"./js/tokenizer": "./js/tokenizer/module.f.mjs",
|
|
25
|
+
"./json": "./json/module.f.mjs",
|
|
26
|
+
"./json/parser": "./json/parser/module.f.mjs",
|
|
27
|
+
"./json/serializer": "./json/serializer/module.f.mjs",
|
|
28
|
+
"./json/tokenizer": "./json/tokenizer/module.f.mjs",
|
|
29
|
+
"./nodejs/version": "./nodejs/version/module.f.mjs",
|
|
30
|
+
"./prime_field": "./prime_field/module.f.mjs",
|
|
31
|
+
"./secp": "./secp/module.f.mjs",
|
|
32
|
+
"./sha2": "./sha2/module.f.mjs",
|
|
33
|
+
"./text/ascii": "./text/ascii/module.f.mjs",
|
|
34
|
+
"./text": "./text/module.f.mjs",
|
|
35
|
+
"./text/sgr": "./text/sgr/module.f.mjs",
|
|
36
|
+
"./text/utf16": "./text/utf16/module.f.mjs",
|
|
37
|
+
"./text/utf8": "./text/utf8/module.f.mjs",
|
|
38
|
+
"./types/array": "./types/array/module.f.mjs",
|
|
39
|
+
"./types/bigfloat": "./types/bigfloat/module.f.mjs",
|
|
40
|
+
"./types/bigint": "./types/bigint/module.f.mjs",
|
|
41
|
+
"./types/btree/find": "./types/btree/find/module.f.mjs",
|
|
42
|
+
"./types/btree": "./types/btree/module.f.mjs",
|
|
43
|
+
"./types/btree/remove": "./types/btree/remove/module.f.mjs",
|
|
44
|
+
"./types/btree/set": "./types/btree/set/module.f.mjs",
|
|
45
|
+
"./types/btree/types": "./types/btree/types/module.f.mjs",
|
|
46
|
+
"./types/byte_set": "./types/byte_set/module.f.mjs",
|
|
47
|
+
"./types/function/compare": "./types/function/compare/module.f.mjs",
|
|
48
|
+
"./types/function": "./types/function/module.f.mjs",
|
|
49
|
+
"./types/function/operator": "./types/function/operator/module.f.mjs",
|
|
50
|
+
"./types/list": "./types/list/module.f.mjs",
|
|
51
|
+
"./types/map": "./types/map/module.f.mjs",
|
|
52
|
+
"./types/nibble_set": "./types/nibble_set/module.f.mjs",
|
|
53
|
+
"./types/nullable": "./types/nullable/module.f.mjs",
|
|
54
|
+
"./types/number": "./types/number/module.f.mjs",
|
|
55
|
+
"./types/object": "./types/object/module.f.mjs",
|
|
56
|
+
"./types/range": "./types/range/module.f.mjs",
|
|
57
|
+
"./types/range_map": "./types/range_map/module.f.mjs",
|
|
58
|
+
"./types/result": "./types/result/module.f.mjs",
|
|
59
|
+
"./types/sorted_list": "./types/sorted_list/module.f.mjs",
|
|
60
|
+
"./types/sorted_set": "./types/sorted_set/module.f.mjs",
|
|
61
|
+
"./types/string": "./types/string/module.f.mjs",
|
|
62
|
+
"./types/string_set": "./types/string_set/module.f.mjs"
|
|
118
63
|
}
|
|
119
64
|
}
|
package/package.json
CHANGED
package/prime_field/module.f.mjs
CHANGED
package/secp/module.f.mjs
CHANGED
package/sha2/module.f.mjs
CHANGED
package/text/ascii/module.f.mjs
CHANGED
package/text/module.f.mjs
CHANGED
package/text/sgr/module.f.mjs
CHANGED
package/text/utf16/module.f.mjs
CHANGED
package/text/utf8/module.f.mjs
CHANGED
package/types/array/module.f.mjs
CHANGED
package/types/btree/module.f.mjs
CHANGED
|
@@ -5,14 +5,26 @@ declare namespace _default {
|
|
|
5
5
|
export { fn };
|
|
6
6
|
}
|
|
7
7
|
export default _default;
|
|
8
|
+
/**
|
|
9
|
+
* A generic function type.
|
|
10
|
+
*/
|
|
8
11
|
export type Func<I, O> = (_: I) => O;
|
|
12
|
+
/**
|
|
13
|
+
* A functional utility type that enables seamless chaining of transformations.
|
|
14
|
+
*/
|
|
9
15
|
export type Fn<I, O> = {
|
|
10
16
|
readonly result: Func<I, O>;
|
|
11
17
|
readonly then: <T>(g: Func<O, T>) => Fn<I, T>;
|
|
12
18
|
};
|
|
13
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* A generic identity function.
|
|
21
|
+
*
|
|
22
|
+
* @type {<T>(value: T) => T}
|
|
23
|
+
*/
|
|
14
24
|
declare const identity: <T>(value: T) => T;
|
|
15
25
|
/**
|
|
26
|
+
* A generic function type.
|
|
27
|
+
*
|
|
16
28
|
* @template I
|
|
17
29
|
* @template O
|
|
18
30
|
* @typedef {(_: I) => O} Func
|
|
@@ -23,14 +35,32 @@ declare const identity: <T>(value: T) => T;
|
|
|
23
35
|
* @type {<I, X>(g: Func<I, X>) => <O>(f: Func<X, O>) => Func<I, O>}
|
|
24
36
|
*/
|
|
25
37
|
declare const compose: <I, X>(g: Func<I, X>) => <O>(f: Func<X, O>) => Func<I, O>;
|
|
26
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Flips the arguments of a curried function.
|
|
40
|
+
*
|
|
41
|
+
* @type {<A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C}
|
|
42
|
+
*/
|
|
27
43
|
declare const flip: <A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C;
|
|
28
44
|
/**
|
|
45
|
+
* A functional utility type that enables seamless chaining of transformations.
|
|
46
|
+
*
|
|
29
47
|
* @template I,O
|
|
30
48
|
* @typedef {{
|
|
31
49
|
* readonly result: Func<I, O>
|
|
32
50
|
* readonly then: <T>(g: Func<O, T>) => Fn<I, T>
|
|
33
51
|
* }} Fn
|
|
34
52
|
*/
|
|
35
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Creates an `Fn` instance from a function, enabling chaining of transformations.
|
|
55
|
+
*
|
|
56
|
+
* @type {<I, O>(f: (i: I) => O) => Fn<I, O>}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const add2 = (x) => x + 2; // Adds 2
|
|
60
|
+
* const multiply3 = (x) => x * 3; // Multiplies by 3
|
|
61
|
+
*
|
|
62
|
+
* // Chain transformations
|
|
63
|
+
* const add2multiply3 = fn(add2).then(multiply3).result;
|
|
64
|
+
* const result = add2multiply3(5); // result is 21. (5 + 2) * 3.
|
|
65
|
+
*/
|
|
36
66
|
declare const fn: <I, O>(f: (i: I) => O) => Fn<I, O>;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
|
|
1
3
|
/**
|
|
4
|
+
* A generic function type.
|
|
5
|
+
*
|
|
2
6
|
* @template I
|
|
3
7
|
* @template O
|
|
4
8
|
* @typedef {(_: I) => O} Func
|
|
@@ -11,13 +15,23 @@
|
|
|
11
15
|
*/
|
|
12
16
|
const compose = g => f => x => f(g(x))
|
|
13
17
|
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* A generic identity function.
|
|
20
|
+
*
|
|
21
|
+
* @type {<T>(value: T) => T}
|
|
22
|
+
*/
|
|
15
23
|
const identity = value => value
|
|
16
24
|
|
|
17
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Flips the arguments of a curried function.
|
|
27
|
+
*
|
|
28
|
+
* @type {<A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C}
|
|
29
|
+
*/
|
|
18
30
|
const flip = f => b => a => f(a)(b)
|
|
19
31
|
|
|
20
32
|
/**
|
|
33
|
+
* A functional utility type that enables seamless chaining of transformations.
|
|
34
|
+
*
|
|
21
35
|
* @template I,O
|
|
22
36
|
* @typedef {{
|
|
23
37
|
* readonly result: Func<I, O>
|
|
@@ -25,7 +39,19 @@ const flip = f => b => a => f(a)(b)
|
|
|
25
39
|
* }} Fn
|
|
26
40
|
*/
|
|
27
41
|
|
|
28
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Creates an `Fn` instance from a function, enabling chaining of transformations.
|
|
44
|
+
*
|
|
45
|
+
* @type {<I, O>(f: (i: I) => O) => Fn<I, O>}
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const add2 = (x) => x + 2; // Adds 2
|
|
49
|
+
* const multiply3 = (x) => x * 3; // Multiplies by 3
|
|
50
|
+
*
|
|
51
|
+
* // Chain transformations
|
|
52
|
+
* const add2multiply3 = fn(add2).then(multiply3).result;
|
|
53
|
+
* const result = add2multiply3(5); // result is 21. (5 + 2) * 3.
|
|
54
|
+
*/
|
|
29
55
|
const fn = result => ({
|
|
30
56
|
result,
|
|
31
57
|
then: g => fn(compose(result)(g))
|
package/types/map/module.f.mjs
CHANGED
|
@@ -23,7 +23,7 @@ declare const at: (name: string) => <T>(object: Map<T>) => T | null;
|
|
|
23
23
|
declare const sort: <T>(e: List.List<Entry<T>>) => List.List<Entry<T>>;
|
|
24
24
|
/** @type {<T>(e: List.List<Entry<T>>) => Map<T>} */
|
|
25
25
|
declare const fromEntries: <T>(e: List.List<Entry<T>>) => Map<T>;
|
|
26
|
-
/** @type {<T>(m:
|
|
27
|
-
declare const fromMap: <T>(m:
|
|
26
|
+
/** @type {<T>(m: BTMap.Map<T>) => Map<T>} */
|
|
27
|
+
declare const fromMap: <T>(m: BTMap.Map<T>) => Map<T>;
|
|
28
28
|
import * as List from '../list/module.f.mjs';
|
|
29
|
-
import * as
|
|
29
|
+
import * as BTMap from '../map/module.f.mjs';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
1
2
|
import list, * as List from '../list/module.f.mjs'
|
|
2
3
|
const { iterable } = list
|
|
3
|
-
import
|
|
4
|
-
const { entries: mapEntries, fromEntries: mapFromEntries } =
|
|
4
|
+
import btMap, * as BTMap from '../map/module.f.mjs'
|
|
5
|
+
const { entries: mapEntries, fromEntries: mapFromEntries } = btMap
|
|
5
6
|
const { getOwnPropertyDescriptor, fromEntries: objectFromEntries } = Object
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -28,7 +29,7 @@ const sort = e => mapEntries(mapFromEntries(e))
|
|
|
28
29
|
/** @type {<T>(e: List.List<Entry<T>>) => Map<T>} */
|
|
29
30
|
const fromEntries = e => objectFromEntries(iterable(e))
|
|
30
31
|
|
|
31
|
-
/** @type {<T>(m:
|
|
32
|
+
/** @type {<T>(m: BTMap.Map<T>) => Map<T>} */
|
|
32
33
|
const fromMap = m => fromEntries(mapEntries(m))
|
|
33
34
|
|
|
34
35
|
export default {
|
package/types/range/module.f.mjs
CHANGED