exupery-core-internals 0.1.3 → 0.1.4
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/private/create_asynchronous_processes_monitor.d.ts +15 -0
- package/dist/imp/private/{create_async_registry.js → create_asynchronous_processes_monitor.js} +9 -8
- package/dist/imp/public/array_literal.d.ts +2 -2
- package/dist/imp/public/array_literal.js +19 -27
- package/dist/imp/public/{cast_to_async_value_imp.d.ts → create_Async_Value.d.ts} +1 -1
- package/dist/imp/public/{cast_to_async_value_imp.js → create_Async_Value.js} +3 -3
- package/dist/imp/public/dictionary_literal.js +18 -26
- package/dist/imp/public/make_async.js +2 -2
- package/dist/imp/public/resolve_async_tuple_2.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/imp/private/create_async_registry.d.ts +0 -14
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type I_Async_Monitor = {
|
|
2
|
+
readonly 'report process started': () => void;
|
|
3
|
+
readonly 'report process finished': () => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* this function helps in keeping track of ongoing async operations
|
|
7
|
+
* async operations are registered and when finished reported as such.
|
|
8
|
+
* when all ongoing operations are finished the onEnd callback is called
|
|
9
|
+
*
|
|
10
|
+
* this function is specifically useful for async map functions
|
|
11
|
+
*
|
|
12
|
+
* @param callback this callback creates a scope within which the counter is provided
|
|
13
|
+
* @param onEnd this callback will be called when all ongoing operations are finished
|
|
14
|
+
*/
|
|
15
|
+
export declare function create_asynchronous_processes_monitor(monitoring_phase: ($: I_Async_Monitor) => void, on_all_finished: () => void): void;
|
package/dist/imp/private/{create_async_registry.js → create_asynchronous_processes_monitor.js}
RENAMED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.create_asynchronous_processes_monitor = create_asynchronous_processes_monitor;
|
|
4
4
|
/**
|
|
5
|
-
* this function
|
|
6
|
-
*
|
|
5
|
+
* this function helps in keeping track of ongoing async operations
|
|
6
|
+
* async operations are registered and when finished reported as such.
|
|
7
|
+
* when all ongoing operations are finished the onEnd callback is called
|
|
7
8
|
*
|
|
8
9
|
* this function is specifically useful for async map functions
|
|
9
10
|
*
|
|
10
11
|
* @param callback this callback creates a scope within which the counter is provided
|
|
11
|
-
* @param onEnd this callback will be called when
|
|
12
|
+
* @param onEnd this callback will be called when all ongoing operations are finished
|
|
12
13
|
*/
|
|
13
|
-
function
|
|
14
|
+
function create_asynchronous_processes_monitor(monitoring_phase, on_all_finished) {
|
|
14
15
|
let counter = 0;
|
|
15
16
|
/*
|
|
16
17
|
* we need to keep track of if the registration phase is ended or not.
|
|
@@ -31,14 +32,14 @@ function create_async_registry(registration_phase, on_all_finished) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
monitoring_phase({
|
|
36
|
+
'report process started': () => {
|
|
36
37
|
if (on_all_finished_has_been_called) {
|
|
37
38
|
throw new Error("CORE: async call done after context is ready");
|
|
38
39
|
}
|
|
39
40
|
counter += 1;
|
|
40
41
|
},
|
|
41
|
-
|
|
42
|
+
'report process finished': () => {
|
|
42
43
|
if (counter === 0) {
|
|
43
44
|
throw new Error("CORE: decrement while counter is 0");
|
|
44
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _et from "exupery-core-types";
|
|
2
2
|
/**
|
|
3
3
|
* returns a Exupery array
|
|
4
4
|
* why is this not the constructor? to call a constructor, you have to use the keyword 'new'. Exupery doesn't use the concept of a class so that keyword should be avoided
|
|
@@ -6,4 +6,4 @@ import * as pt from "exupery-core-types";
|
|
|
6
6
|
* @param source An array literal
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function array_literal<T>(source: readonly T[]):
|
|
9
|
+
export declare function array_literal<T>(source: readonly T[]): _et.Array<T>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.array_literal = array_literal;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const create_asynchronous_processes_monitor_1 = require("../private/create_asynchronous_processes_monitor");
|
|
5
|
+
const create_Async_Value_1 = require("./create_Async_Value");
|
|
6
6
|
const not_set_1 = require("./not_set");
|
|
7
7
|
const set_1 = require("./set");
|
|
8
8
|
/**
|
|
@@ -19,34 +19,26 @@ class Array_Class {
|
|
|
19
19
|
return $v(entry);
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
22
|
-
async_map(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
});
|
|
22
|
+
async_map(on_element_value) {
|
|
23
|
+
const data = this.data;
|
|
24
|
+
return (0, create_Async_Value_1.create_Async_Value)({
|
|
25
|
+
'execute': (on_array_value) => {
|
|
26
|
+
const temp = [];
|
|
27
|
+
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((registry) => {
|
|
28
|
+
data.map(on_element_value).forEach((v) => {
|
|
29
|
+
registry['report process started']();
|
|
30
|
+
v.__start((v) => {
|
|
31
|
+
temp.push(v);
|
|
32
|
+
registry['report process finished']();
|
|
40
33
|
});
|
|
41
|
-
}, () => {
|
|
42
|
-
on_value(array_literal(temp));
|
|
43
34
|
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
}, () => {
|
|
36
|
+
on_array_value(array_literal(temp));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
48
40
|
}
|
|
49
|
-
|
|
41
|
+
//internal methods
|
|
50
42
|
__for_each($i) {
|
|
51
43
|
this.data.forEach(($) => {
|
|
52
44
|
$i($);
|
|
@@ -7,4 +7,4 @@ export type Executer<T> = {
|
|
|
7
7
|
* @param executer the function that produces the eventual value
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function create_Async_Value<T>(executer: Executer<T>): pt.Async_Value<T>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.create_Async_Value = create_Async_Value;
|
|
4
4
|
class Async_Value_Class {
|
|
5
5
|
constructor(executer) {
|
|
6
6
|
this.executer = executer;
|
|
7
7
|
}
|
|
8
8
|
map(handle_value) {
|
|
9
|
-
return
|
|
9
|
+
return create_Async_Value({
|
|
10
10
|
'execute': (on_value) => {
|
|
11
11
|
this.executer.execute((value) => {
|
|
12
12
|
handle_value(value).__start(on_value);
|
|
@@ -23,6 +23,6 @@ class Async_Value_Class {
|
|
|
23
23
|
* @param executer the function that produces the eventual value
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
|
-
function
|
|
26
|
+
function create_Async_Value(executer) {
|
|
27
27
|
return new Async_Value_Class(executer);
|
|
28
28
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dictionary_literal = dictionary_literal;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const create_asynchronous_processes_monitor_1 = require("../private/create_asynchronous_processes_monitor");
|
|
5
|
+
const create_Async_Value_1 = require("./create_Async_Value");
|
|
6
6
|
const set_1 = require("./set");
|
|
7
7
|
const not_set_1 = require("./not_set");
|
|
8
8
|
const array_literal_1 = require("./array_literal");
|
|
@@ -21,32 +21,24 @@ class Dictionary {
|
|
|
21
21
|
};
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
|
-
async_map(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
});
|
|
24
|
+
async_map(on_entry_value) {
|
|
25
|
+
const source = this.source;
|
|
26
|
+
const temp = {};
|
|
27
|
+
return (0, create_Async_Value_1.create_Async_Value)({
|
|
28
|
+
'execute': (on_dictionary_value) => {
|
|
29
|
+
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((counter) => {
|
|
30
|
+
source.map(($) => {
|
|
31
|
+
counter['report process started']();
|
|
32
|
+
on_entry_value($.value).__start((nv) => {
|
|
33
|
+
temp[$.key] = nv;
|
|
34
|
+
counter['report process finished']();
|
|
42
35
|
});
|
|
43
|
-
}, () => {
|
|
44
|
-
on_value(dictionary_literal(temp));
|
|
45
36
|
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
}, () => {
|
|
38
|
+
on_dictionary_value(dictionary_literal(temp));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
50
42
|
}
|
|
51
43
|
__map_with_key($v) {
|
|
52
44
|
return new Dictionary(this.source.map(($) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.make_async = make_async;
|
|
4
|
-
const
|
|
4
|
+
const create_Async_Value_1 = require("./create_Async_Value");
|
|
5
5
|
/**
|
|
6
6
|
* converts a regular value to a {@link Async_Value}
|
|
7
7
|
* @param $ the value
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
function make_async($) {
|
|
11
|
-
return (0,
|
|
11
|
+
return (0, create_Async_Value_1.create_Async_Value)({
|
|
12
12
|
'execute': (on_value) => {
|
|
13
13
|
on_value($);
|
|
14
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolve_async_tuple_2 = resolve_async_tuple_2;
|
|
4
|
-
const
|
|
4
|
+
const create_Async_Value_1 = require("./create_Async_Value");
|
|
5
5
|
function resolve_async_tuple_2(first, second) {
|
|
6
|
-
return (0,
|
|
6
|
+
return (0, create_Async_Value_1.create_Async_Value)({
|
|
7
7
|
'execute': (on_value) => {
|
|
8
8
|
let element_1_is_set = false;
|
|
9
9
|
let element_2_is_set = false;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from "./imp/public/switch_state";
|
|
|
8
8
|
export * from "./imp/public/get_location_info";
|
|
9
9
|
export * from "./imp/public/resolve_async_tuple_2";
|
|
10
10
|
export * from "./imp/public/make_async";
|
|
11
|
-
export * from "./imp/public/
|
|
11
|
+
export * from "./imp/public/create_Async_Value";
|
|
12
12
|
export * from "./imp/public/set";
|
|
13
13
|
export * from "./imp/public/not_set";
|
|
14
14
|
export * from "./imp/public/Error";
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ __exportStar(require("./imp/public/switch_state"), exports);
|
|
|
24
24
|
__exportStar(require("./imp/public/get_location_info"), exports);
|
|
25
25
|
__exportStar(require("./imp/public/resolve_async_tuple_2"), exports);
|
|
26
26
|
__exportStar(require("./imp/public/make_async"), exports);
|
|
27
|
-
__exportStar(require("./imp/public/
|
|
27
|
+
__exportStar(require("./imp/public/create_Async_Value"), exports);
|
|
28
28
|
__exportStar(require("./imp/public/set"), exports);
|
|
29
29
|
__exportStar(require("./imp/public/not_set"), exports);
|
|
30
30
|
__exportStar(require("./imp/public/Error"), exports);
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type I_Async_Registry = {
|
|
2
|
-
readonly 'register': () => void;
|
|
3
|
-
readonly 'report_finished': () => void;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* this function provides a callback with a counter as parameter
|
|
7
|
-
* when the counter reaches 0, the onEnd callback is called
|
|
8
|
-
*
|
|
9
|
-
* this function is specifically useful for async map functions
|
|
10
|
-
*
|
|
11
|
-
* @param callback this callback creates a scope within which the counter is provided
|
|
12
|
-
* @param onEnd this callback will be called when the counter reaches 0
|
|
13
|
-
*/
|
|
14
|
-
export declare function create_async_registry(registration_phase: ($: I_Async_Registry) => void, on_all_finished: () => void): void;
|