exupery-core-internals 0.1.2 → 0.1.3
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/dist/imp/public/array_literal.js +13 -11
- package/dist/imp/public/cast_to_async_value_imp.d.ts +5 -3
- package/dist/imp/public/cast_to_async_value_imp.js +14 -15
- package/dist/imp/public/dictionary_literal.js +13 -11
- package/dist/imp/public/make_async.js +4 -2
- package/dist/imp/public/resolve_async_tuple_2.js +20 -18
- package/package.json +2 -2
- package/dist/imp/types/Execute.d.ts +0 -5
- package/dist/imp/types/Execute.js +0 -2
|
@@ -27,19 +27,21 @@ class Array_Class {
|
|
|
27
27
|
// })
|
|
28
28
|
function array(array, $v) {
|
|
29
29
|
const mapped = array.map($v);
|
|
30
|
-
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
|
|
31
|
+
'execute': (on_value) => {
|
|
32
|
+
const temp = [];
|
|
33
|
+
(0, create_async_registry_1.create_async_registry)((registry) => {
|
|
34
|
+
mapped.forEach((v) => {
|
|
35
|
+
registry.register();
|
|
36
|
+
v.__start((v) => {
|
|
37
|
+
temp.push(v);
|
|
38
|
+
registry.report_finished();
|
|
39
|
+
});
|
|
38
40
|
});
|
|
41
|
+
}, () => {
|
|
42
|
+
on_value(array_literal(temp));
|
|
39
43
|
});
|
|
40
|
-
}
|
|
41
|
-
$c(array_literal(temp));
|
|
42
|
-
});
|
|
44
|
+
}
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
return array(this.data, $v);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as pt from "exupery-core-types";
|
|
2
|
-
|
|
2
|
+
export type Executer<T> = {
|
|
3
|
+
'execute': (on_value: ($: T) => void) => void;
|
|
4
|
+
};
|
|
3
5
|
/**
|
|
4
6
|
* returns an {@link Async_Value }
|
|
5
|
-
* @param
|
|
7
|
+
* @param executer the function that produces the eventual value
|
|
6
8
|
* @returns
|
|
7
9
|
*/
|
|
8
|
-
export declare function cast_to_async_value_imp<T>(
|
|
10
|
+
export declare function cast_to_async_value_imp<T>(executer: Executer<T>): pt.Async_Value<T>;
|
|
@@ -2,28 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cast_to_async_value_imp = cast_to_async_value_imp;
|
|
4
4
|
class Async_Value_Class {
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
5
|
+
constructor(executer) {
|
|
6
|
+
this.executer = executer;
|
|
7
7
|
}
|
|
8
|
-
map(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
map(handle_value) {
|
|
9
|
+
return cast_to_async_value_imp({
|
|
10
|
+
'execute': (on_value) => {
|
|
11
|
+
this.executer.execute((value) => {
|
|
12
|
+
handle_value(value).__start(on_value);
|
|
13
13
|
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return rewrite(this.execute, $v);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
this.execute(
|
|
17
|
+
__start(on_value) {
|
|
18
|
+
this.executer.execute(on_value);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* returns an {@link Async_Value }
|
|
24
|
-
* @param
|
|
23
|
+
* @param executer the function that produces the eventual value
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
|
-
function cast_to_async_value_imp(
|
|
28
|
-
return new Async_Value_Class(
|
|
26
|
+
function cast_to_async_value_imp(executer) {
|
|
27
|
+
return new Async_Value_Class(executer);
|
|
29
28
|
}
|
|
@@ -29,19 +29,21 @@ class Dictionary {
|
|
|
29
29
|
value: $v($.value),
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
|
-
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
|
|
33
|
+
'execute': (on_value) => {
|
|
34
|
+
const temp = {};
|
|
35
|
+
(0, create_async_registry_1.create_async_registry)((counter) => {
|
|
36
|
+
mapped.map(($) => {
|
|
37
|
+
counter.register();
|
|
38
|
+
$.value.__start((nv) => {
|
|
39
|
+
temp[$.key] = nv;
|
|
40
|
+
counter.report_finished();
|
|
41
|
+
});
|
|
40
42
|
});
|
|
43
|
+
}, () => {
|
|
44
|
+
on_value(dictionary_literal(temp));
|
|
41
45
|
});
|
|
42
|
-
}
|
|
43
|
-
cb(dictionary_literal(temp));
|
|
44
|
-
});
|
|
46
|
+
}
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
return imp(this.source, $v);
|
|
@@ -8,7 +8,9 @@ const cast_to_async_value_imp_1 = require("./cast_to_async_value_imp");
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
function make_async($) {
|
|
11
|
-
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)(
|
|
12
|
-
|
|
11
|
+
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
|
|
12
|
+
'execute': (on_value) => {
|
|
13
|
+
on_value($);
|
|
14
|
+
}
|
|
13
15
|
});
|
|
14
16
|
}
|
|
@@ -3,25 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolve_async_tuple_2 = resolve_async_tuple_2;
|
|
4
4
|
const cast_to_async_value_imp_1 = require("./cast_to_async_value_imp");
|
|
5
5
|
function resolve_async_tuple_2(first, second) {
|
|
6
|
-
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
|
|
7
|
+
'execute': (on_value) => {
|
|
8
|
+
let element_1_is_set = false;
|
|
9
|
+
let element_2_is_set = false;
|
|
10
|
+
let elem1;
|
|
11
|
+
let elem2;
|
|
12
|
+
function wrap_up() {
|
|
13
|
+
if (element_1_is_set && element_2_is_set) {
|
|
14
|
+
on_value({ first: elem1, second: elem2 });
|
|
15
|
+
}
|
|
14
16
|
}
|
|
17
|
+
first.__start((val) => {
|
|
18
|
+
elem1 = val;
|
|
19
|
+
element_1_is_set = true;
|
|
20
|
+
wrap_up();
|
|
21
|
+
});
|
|
22
|
+
second.__start((val) => {
|
|
23
|
+
elem2 = val;
|
|
24
|
+
element_2_is_set = true;
|
|
25
|
+
wrap_up();
|
|
26
|
+
});
|
|
15
27
|
}
|
|
16
|
-
first.__execute((val) => {
|
|
17
|
-
elem1 = val;
|
|
18
|
-
element_1_is_set = true;
|
|
19
|
-
wrap_up();
|
|
20
|
-
});
|
|
21
|
-
second.__execute((val) => {
|
|
22
|
-
elem2 = val;
|
|
23
|
-
element_2_is_set = true;
|
|
24
|
-
wrap_up();
|
|
25
|
-
});
|
|
26
28
|
});
|
|
27
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exupery-core-internals",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Corno",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "https://github.com/corno/exupery-core/issues"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"exupery-core-types": "^0.1.
|
|
18
|
+
"exupery-core-types": "^0.1.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^18.15.3"
|