exupery-core-async 0.1.25 → 0.1.26
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/Guaranteed_Procedure_Context.d.ts +4 -0
- package/dist/Guaranteed_Query_Result.d.ts +20 -0
- package/dist/Unguaranteed_Procedure_Context.d.ts +24 -0
- package/dist/{Unsafe_Query_Result.d.ts → Unguaranteed_Query_Result.d.ts} +9 -9
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -23
- package/dist/initialize_guaranteed_procedure_context.d.ts +12 -0
- package/dist/{initialize_safe_procedure_context.js → initialize_guaranteed_procedure_context.js} +10 -10
- package/dist/{initialize_unsafe_procedure_context.d.ts → initialize_unguaranteed_procedure_context.d.ts} +3 -3
- package/dist/{initialize_unsafe_procedure_context.js → initialize_unguaranteed_procedure_context.js} +24 -24
- package/dist/merge_2_guaranteed_query_results.d.ts +6 -0
- package/dist/{merge_2_safe_query_results.js → merge_2_guaranteed_query_results.js} +4 -4
- package/dist/{run_safe_query.d.ts → run_guaranteed_query.d.ts} +2 -2
- package/dist/{run_safe_query.js → run_guaranteed_query.js} +14 -14
- package/dist/{run_unsafe_query.d.ts → run_unguaranteed_query.d.ts} +2 -2
- package/dist/{run_unsafe_query.js → run_unguaranteed_query.js} +14 -14
- package/package.json +1 -1
- package/dist/Safe_Procedure_Context.d.ts +0 -4
- package/dist/Safe_Query_Result.d.ts +0 -20
- package/dist/Unsafe_Procedure_Context.d.ts +0 -24
- package/dist/initialize_safe_procedure_context.d.ts +0 -12
- package/dist/merge_2_safe_query_results.d.ts +0 -6
- /package/dist/{Safe_Procedure_Context.js → Guaranteed_Procedure_Context.js} +0 -0
- /package/dist/{Safe_Query_Result.js → Guaranteed_Query_Result.js} +0 -0
- /package/dist/{Unsafe_Procedure_Context.js → Unguaranteed_Procedure_Context.js} +0 -0
- /package/dist/{Unsafe_Query_Result.js → Unguaranteed_Query_Result.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Guaranteed_Procedure_Context } from "./Guaranteed_Procedure_Context";
|
|
2
|
+
import { Ungaranteed_Procedure_Context } from "./Unguaranteed_Procedure_Context";
|
|
3
|
+
/**
|
|
4
|
+
* A value that will asynchronously become available.
|
|
5
|
+
* Similar to the concept of a promise, but with a smaller API.
|
|
6
|
+
*/
|
|
7
|
+
export interface Guaranteed_Query_Result<T> {
|
|
8
|
+
map<NT>(handle_value: ($: T) => NT): Guaranteed_Query_Result<NT>;
|
|
9
|
+
/**
|
|
10
|
+
* maps the current async value into a new async value
|
|
11
|
+
* @param handle_value callback that transforms the actual value into a new Async_Value
|
|
12
|
+
*/
|
|
13
|
+
then<NT>(handle_value: ($: T) => Guaranteed_Query_Result<NT>): Guaranteed_Query_Result<NT>;
|
|
14
|
+
process_guaranteed(handle_value: ($i: Guaranteed_Procedure_Context, $: T) => Guaranteed_Procedure_Context): Guaranteed_Procedure_Context;
|
|
15
|
+
process_unguaranteed<E>(handle_value: ($i: Ungaranteed_Procedure_Context<E>, $: T) => Ungaranteed_Procedure_Context<E>): Ungaranteed_Procedure_Context<E>;
|
|
16
|
+
/**
|
|
17
|
+
* This method is only to be used by resources
|
|
18
|
+
*/
|
|
19
|
+
__start(on_value: ($: T) => void): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
import { Guaranteed_Procedure_Context } from "./Guaranteed_Procedure_Context";
|
|
3
|
+
export interface Ungaranteed_Procedure_Context<E> {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* executes a command when an exception has occurred,
|
|
7
|
+
* but stays in the ungaranteed context
|
|
8
|
+
*
|
|
9
|
+
* this is useful when you want to do some cleanup
|
|
10
|
+
* or logging in case of an exception,
|
|
11
|
+
* but still want to propagate the exception further
|
|
12
|
+
*
|
|
13
|
+
* note that this is different from `catch`,
|
|
14
|
+
* which would switch to the guaranteed context
|
|
15
|
+
*/
|
|
16
|
+
process_exception_deprecated<NE>(handle: ($i: Guaranteed_Procedure_Context, $: E) => Guaranteed_Procedure_Context, map: ($: E) => NE): Ungaranteed_Procedure_Context<NE>;
|
|
17
|
+
throw_exception<E>($: E): Ungaranteed_Procedure_Context<E>;
|
|
18
|
+
catch(handle_exception: ($i: Guaranteed_Procedure_Context, $: E) => Guaranteed_Procedure_Context): Guaranteed_Procedure_Context;
|
|
19
|
+
execute_unguaranteed(handle: ($i: Ungaranteed_Procedure_Context<E>) => Ungaranteed_Procedure_Context<E>): Ungaranteed_Procedure_Context<E>;
|
|
20
|
+
execute(handle: ($i: Guaranteed_Procedure_Context) => Guaranteed_Procedure_Context): Ungaranteed_Procedure_Context<E>;
|
|
21
|
+
execute_dictionary_unguaranteed<E2>($: _et.Dictionary<Ungaranteed_Procedure_Context<E2>>, aggregate_exceptions: ($: _et.Dictionary<E2>) => E): Ungaranteed_Procedure_Context<E>;
|
|
22
|
+
execute_multiple_unguaranteed<E2>($: _et.Array<Ungaranteed_Procedure_Context<E2>>, aggregate_exceptions: ($: _et.Array<E2>) => E): Ungaranteed_Procedure_Context<E>;
|
|
23
|
+
__start(on_success: () => void, on_exception: ($: E) => void): void;
|
|
24
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface
|
|
5
|
-
map<NT>(handle_value: ($: T) => NT):
|
|
6
|
-
map_exception<NE>(handle_exception: ($: E) => NE):
|
|
7
|
-
then<NT>(handle_value: ($: T) =>
|
|
8
|
-
catch(handle_exception: ($: E) =>
|
|
1
|
+
import { Guaranteed_Procedure_Context } from "./Guaranteed_Procedure_Context";
|
|
2
|
+
import { Guaranteed_Query_Result } from "./Guaranteed_Query_Result";
|
|
3
|
+
import { Ungaranteed_Procedure_Context } from "./Unguaranteed_Procedure_Context";
|
|
4
|
+
export interface Unguaranteed_Query_Result<T, E> {
|
|
5
|
+
map<NT>(handle_value: ($: T) => NT): Unguaranteed_Query_Result<NT, E>;
|
|
6
|
+
map_exception<NE>(handle_exception: ($: E) => NE): Unguaranteed_Query_Result<T, NE>;
|
|
7
|
+
then<NT>(handle_value: ($: T) => Unguaranteed_Query_Result<NT, E>): Unguaranteed_Query_Result<NT, E>;
|
|
8
|
+
catch(handle_exception: ($: E) => Guaranteed_Query_Result<T>): Guaranteed_Query_Result<T>;
|
|
9
9
|
/**
|
|
10
10
|
* processes the queried data by executing a command.
|
|
11
11
|
*
|
|
@@ -19,6 +19,6 @@ export interface Unsafe_Query_Result<T, E> {
|
|
|
19
19
|
* @param map_exception the handler that will map the exception of the query into a new exception value of the command's exception type
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
process<NE>(handle_exception: ($i:
|
|
22
|
+
process<NE>(handle_exception: ($i: Guaranteed_Procedure_Context, $: E) => Guaranteed_Procedure_Context, map_exception: ($: E) => NE, handle_value: ($i: Ungaranteed_Procedure_Context<NE>, $: T) => Ungaranteed_Procedure_Context<NE>): Ungaranteed_Procedure_Context<NE>;
|
|
23
23
|
__start(on_value: ($: T) => void, on_exception: ($: E) => void): void;
|
|
24
24
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
export * from "./Guaranteed_Procedure_Context";
|
|
2
|
+
export * from "./Unguaranteed_Procedure_Context";
|
|
3
|
+
export * from "./Guaranteed_Query_Result";
|
|
4
|
+
export * from "./Unguaranteed_Query_Result";
|
|
5
|
+
export * from "./merge_2_guaranteed_query_results";
|
|
6
|
+
export * from "./run_guaranteed_query";
|
|
7
|
+
export * from "./run_unguaranteed_query";
|
|
8
|
+
export * from "./initialize_guaranteed_procedure_context";
|
|
9
|
+
export * from "./initialize_unguaranteed_procedure_context";
|
|
10
|
+
import { Guaranteed_Procedure_Context } from "./Guaranteed_Procedure_Context";
|
|
11
|
+
import { Ungaranteed_Procedure_Context } from "./Unguaranteed_Procedure_Context";
|
|
12
|
+
import { Guaranteed_Query_Result } from "./Guaranteed_Query_Result";
|
|
13
|
+
import { Unguaranteed_Query_Result } from "./Unguaranteed_Query_Result";
|
|
14
14
|
export declare const query: {
|
|
15
|
-
|
|
16
|
-
'create result': <T>($: T) =>
|
|
15
|
+
guaranteed: {
|
|
16
|
+
'create result': <T>($: T) => Guaranteed_Query_Result<T>;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
'create result': <T, E>($: T) =>
|
|
20
|
-
'raise exception': <T, E>($: E) =>
|
|
18
|
+
unguaranteed: {
|
|
19
|
+
'create result': <T, E>($: T) => Unguaranteed_Query_Result<T, E>;
|
|
20
|
+
'raise exception': <T, E>($: E) => Unguaranteed_Query_Result<T, E>;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
export declare const command: {
|
|
24
|
-
|
|
25
|
-
initialize: () =>
|
|
24
|
+
guaranteed: {
|
|
25
|
+
initialize: () => Guaranteed_Procedure_Context;
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
initialize: <E>() =>
|
|
29
|
-
'raise exception': <E>($: E) =>
|
|
27
|
+
unguaranteed: {
|
|
28
|
+
initialize: <E>() => Ungaranteed_Procedure_Context<E>;
|
|
29
|
+
'raise exception': <E>($: E) => Ungaranteed_Procedure_Context<E>;
|
|
30
30
|
};
|
|
31
31
|
};
|
package/dist/index.js
CHANGED
|
@@ -15,39 +15,39 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.command = exports.query = void 0;
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
26
|
-
__exportStar(require("./
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
18
|
+
__exportStar(require("./Guaranteed_Procedure_Context"), exports);
|
|
19
|
+
__exportStar(require("./Unguaranteed_Procedure_Context"), exports);
|
|
20
|
+
__exportStar(require("./Guaranteed_Query_Result"), exports);
|
|
21
|
+
__exportStar(require("./Unguaranteed_Query_Result"), exports);
|
|
22
|
+
__exportStar(require("./merge_2_guaranteed_query_results"), exports);
|
|
23
|
+
__exportStar(require("./run_guaranteed_query"), exports);
|
|
24
|
+
__exportStar(require("./run_unguaranteed_query"), exports);
|
|
25
|
+
__exportStar(require("./initialize_guaranteed_procedure_context"), exports);
|
|
26
|
+
__exportStar(require("./initialize_unguaranteed_procedure_context"), exports);
|
|
27
|
+
const initialize_guaranteed_procedure_context_1 = require("./initialize_guaranteed_procedure_context");
|
|
28
|
+
const initialize_unguaranteed_procedure_context_1 = require("./initialize_unguaranteed_procedure_context");
|
|
29
|
+
const run_guaranteed_query_1 = require("./run_guaranteed_query");
|
|
30
|
+
const run_unguaranteed_query_1 = require("./run_unguaranteed_query");
|
|
31
31
|
exports.query = {
|
|
32
|
-
'
|
|
32
|
+
'guaranteed': {
|
|
33
33
|
'create result': ($) => {
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, run_guaranteed_query_1.__run_guaranteed_query)({
|
|
35
35
|
'execute': (on_value) => {
|
|
36
36
|
on_value($);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
'
|
|
41
|
+
'unguaranteed': {
|
|
42
42
|
'create result': ($) => {
|
|
43
|
-
return (0,
|
|
43
|
+
return (0, run_unguaranteed_query_1.__run_unguaranteed_query)({
|
|
44
44
|
'execute': (on_value) => {
|
|
45
45
|
on_value($);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
},
|
|
49
49
|
'raise exception': ($) => {
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, run_unguaranteed_query_1.__run_unguaranteed_query)({
|
|
51
51
|
'execute': (on_value, on_exception) => {
|
|
52
52
|
on_exception($);
|
|
53
53
|
}
|
|
@@ -56,13 +56,13 @@ exports.query = {
|
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
exports.command = {
|
|
59
|
-
'
|
|
60
|
-
'initialize':
|
|
59
|
+
'guaranteed': {
|
|
60
|
+
'initialize': initialize_guaranteed_procedure_context_1.initialize_guaranteed_procedure_context
|
|
61
61
|
},
|
|
62
|
-
'
|
|
63
|
-
'initialize':
|
|
62
|
+
'unguaranteed': {
|
|
63
|
+
'initialize': initialize_unguaranteed_procedure_context_1.initialize_unguaranteed_procedure_context,
|
|
64
64
|
'raise exception': ($) => {
|
|
65
|
-
return (0,
|
|
65
|
+
return (0, initialize_unguaranteed_procedure_context_1.__execute_unguaranteed_action)({
|
|
66
66
|
'execute': (on_success, on_exception) => {
|
|
67
67
|
on_exception($);
|
|
68
68
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Guaranteed_Procedure_Context } from "./Guaranteed_Procedure_Context";
|
|
2
|
+
type Executer = {
|
|
3
|
+
'execute': (on_finished: () => void) => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* returns an {@link Async_Value }
|
|
7
|
+
* @param executer the function that produces the eventual value
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function __execute_guaranteed_action(executer: Executer): Guaranteed_Procedure_Context;
|
|
11
|
+
export declare const initialize_guaranteed_procedure_context: () => Guaranteed_Procedure_Context;
|
|
12
|
+
export {};
|
package/dist/{initialize_safe_procedure_context.js → initialize_guaranteed_procedure_context.js}
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
class
|
|
3
|
+
exports.initialize_guaranteed_procedure_context = void 0;
|
|
4
|
+
exports.__execute_guaranteed_action = __execute_guaranteed_action;
|
|
5
|
+
class Guaranteed_Procedure_Context_Class {
|
|
6
6
|
constructor(executer) {
|
|
7
7
|
this.executer = executer;
|
|
8
8
|
}
|
|
9
9
|
execute(handle) {
|
|
10
|
-
return
|
|
10
|
+
return __execute_guaranteed_action({
|
|
11
11
|
'execute': (on_finished) => {
|
|
12
12
|
this.executer.execute(() => {
|
|
13
|
-
handle((0, exports.
|
|
13
|
+
handle((0, exports.initialize_guaranteed_procedure_context)()).__start(on_finished);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -24,14 +24,14 @@ class Safe_Command_Result_Class {
|
|
|
24
24
|
* @param executer the function that produces the eventual value
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
28
|
-
return new
|
|
27
|
+
function __execute_guaranteed_action(executer) {
|
|
28
|
+
return new Guaranteed_Procedure_Context_Class(executer);
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
return new
|
|
30
|
+
const initialize_guaranteed_procedure_context = () => {
|
|
31
|
+
return new Guaranteed_Procedure_Context_Class({
|
|
32
32
|
'execute': (on_finished) => {
|
|
33
33
|
on_finished(); //nothing to do, call on_finished immediately
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
exports.
|
|
37
|
+
exports.initialize_guaranteed_procedure_context = initialize_guaranteed_procedure_context;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ungaranteed_Procedure_Context } from "./Unguaranteed_Procedure_Context";
|
|
2
2
|
/**
|
|
3
3
|
* this function contains the body in which the async value or exception is executed
|
|
4
4
|
* after the execution, either the on_value or on_exception callback will be called
|
|
@@ -13,6 +13,6 @@ type Executer<E> = {
|
|
|
13
13
|
* @param executer the function that produces the eventual value
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
17
|
-
export declare const
|
|
16
|
+
export declare function __execute_unguaranteed_action<E>(executer: Executer<E>): Ungaranteed_Procedure_Context<E>;
|
|
17
|
+
export declare const initialize_unguaranteed_procedure_context: <E>() => Ungaranteed_Procedure_Context<E>;
|
|
18
18
|
export {};
|
package/dist/{initialize_unsafe_procedure_context.js → initialize_unguaranteed_procedure_context.js}
RENAMED
|
@@ -23,35 +23,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
26
|
+
exports.initialize_unguaranteed_procedure_context = void 0;
|
|
27
|
+
exports.__execute_unguaranteed_action = __execute_unguaranteed_action;
|
|
28
28
|
const _ei = __importStar(require("exupery-core-internals"));
|
|
29
|
-
const
|
|
29
|
+
const initialize_guaranteed_procedure_context_1 = require("./initialize_guaranteed_procedure_context");
|
|
30
30
|
const create_asynchronous_processes_monitor_1 = require("./create_asynchronous_processes_monitor");
|
|
31
|
-
class
|
|
31
|
+
class Unguaranteed_Command_Result_Class {
|
|
32
32
|
constructor(executer) {
|
|
33
33
|
this.executer = executer;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
return new
|
|
35
|
+
process_exception_deprecated(handle, map) {
|
|
36
|
+
return new Unguaranteed_Command_Result_Class({
|
|
37
37
|
'execute': (new_on_success, new_on_exception) => {
|
|
38
38
|
this.executer.execute(new_on_success, ($) => {
|
|
39
|
-
handle((0,
|
|
39
|
+
handle((0, initialize_guaranteed_procedure_context_1.initialize_guaranteed_procedure_context)(), $).__start(() => new_on_exception(map($)));
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
catch(handle_exception) {
|
|
45
|
-
return (0,
|
|
45
|
+
return (0, initialize_guaranteed_procedure_context_1.__execute_guaranteed_action)({
|
|
46
46
|
'execute': (new_on_success) => {
|
|
47
47
|
this.executer.execute(new_on_success, ($) => {
|
|
48
|
-
handle_exception((0,
|
|
48
|
+
handle_exception((0, initialize_guaranteed_procedure_context_1.initialize_guaranteed_procedure_context)(), $).__start(new_on_success);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
throw_exception($) {
|
|
54
|
-
return
|
|
54
|
+
return __execute_unguaranteed_action({
|
|
55
55
|
'execute': (on_finished, on_exception) => {
|
|
56
56
|
this.executer.execute(() => {
|
|
57
57
|
on_exception($);
|
|
@@ -59,27 +59,27 @@ class Unsafe_Command_Result_Class {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
return new
|
|
62
|
+
execute_unguaranteed(handle) {
|
|
63
|
+
return new Unguaranteed_Command_Result_Class({
|
|
64
64
|
'execute': (new_on_success, new_on_exception) => {
|
|
65
65
|
this.executer.execute(() => {
|
|
66
|
-
handle((0, exports.
|
|
66
|
+
handle((0, exports.initialize_unguaranteed_procedure_context)()).__start(new_on_success, new_on_exception);
|
|
67
67
|
}, new_on_exception);
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
execute(handle) {
|
|
72
|
-
return new
|
|
72
|
+
return new Unguaranteed_Command_Result_Class({
|
|
73
73
|
'execute': (new_on_success, new_on_exception) => {
|
|
74
74
|
this.executer.execute(() => {
|
|
75
|
-
handle((0,
|
|
75
|
+
handle((0, initialize_guaranteed_procedure_context_1.initialize_guaranteed_procedure_context)()).__start(new_on_success);
|
|
76
76
|
}, new_on_exception);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
execute_dictionary_unguaranteed($, aggregate_exceptions) {
|
|
81
81
|
let exceptions = {};
|
|
82
|
-
return
|
|
82
|
+
return __execute_unguaranteed_action({
|
|
83
83
|
'execute': (on_success, on_exception) => {
|
|
84
84
|
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
85
85
|
$.map(($, key) => {
|
|
@@ -102,9 +102,9 @@ class Unsafe_Command_Result_Class {
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
execute_multiple_unguaranteed($, aggregate_exceptions) {
|
|
106
106
|
let exceptions = [];
|
|
107
|
-
return
|
|
107
|
+
return __execute_unguaranteed_action({
|
|
108
108
|
'execute': (on_success, on_exception) => {
|
|
109
109
|
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
110
110
|
$.map(($) => {
|
|
@@ -136,14 +136,14 @@ class Unsafe_Command_Result_Class {
|
|
|
136
136
|
* @param executer the function that produces the eventual value
|
|
137
137
|
* @returns
|
|
138
138
|
*/
|
|
139
|
-
function
|
|
140
|
-
return new
|
|
139
|
+
function __execute_unguaranteed_action(executer) {
|
|
140
|
+
return new Unguaranteed_Command_Result_Class(executer);
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
return new
|
|
142
|
+
const initialize_unguaranteed_procedure_context = () => {
|
|
143
|
+
return new Unguaranteed_Command_Result_Class({
|
|
144
144
|
'execute': (on_success, on_exception) => {
|
|
145
145
|
on_success(); //nothing to do, call on_finished immediately
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
};
|
|
149
|
-
exports.
|
|
149
|
+
exports.initialize_unguaranteed_procedure_context = initialize_unguaranteed_procedure_context;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Guaranteed_Query_Result } from "./Guaranteed_Query_Result";
|
|
2
|
+
export type Sync_Tuple_2<T1, T2> = {
|
|
3
|
+
readonly 'first': T1;
|
|
4
|
+
readonly 'second': T2;
|
|
5
|
+
};
|
|
6
|
+
export declare function merge_2_unguaranteed_query_results<T1, T2>(first: Guaranteed_Query_Result<T1>, second: Guaranteed_Query_Result<T2>): Guaranteed_Query_Result<Sync_Tuple_2<T1, T2>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return (0,
|
|
3
|
+
exports.merge_2_unguaranteed_query_results = merge_2_unguaranteed_query_results;
|
|
4
|
+
const run_guaranteed_query_1 = require("./run_guaranteed_query");
|
|
5
|
+
function merge_2_unguaranteed_query_results(first, second) {
|
|
6
|
+
return (0, run_guaranteed_query_1.__run_guaranteed_query)({
|
|
7
7
|
'execute': (on_value) => {
|
|
8
8
|
let element_1_is_set = false;
|
|
9
9
|
let element_2_is_set = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Guaranteed_Query_Result } from "./Guaranteed_Query_Result";
|
|
2
2
|
type Executer<T> = {
|
|
3
3
|
'execute': (on_value: ($: T) => void) => void;
|
|
4
4
|
};
|
|
@@ -7,5 +7,5 @@ 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 __run_guaranteed_query<T>(executer: Executer<T>): Guaranteed_Query_Result<T>;
|
|
11
11
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
class
|
|
3
|
+
exports.__run_guaranteed_query = __run_guaranteed_query;
|
|
4
|
+
const initialize_guaranteed_procedure_context_1 = require("./initialize_guaranteed_procedure_context");
|
|
5
|
+
const initialize_unguaranteed_procedure_context_1 = require("./initialize_unguaranteed_procedure_context");
|
|
6
|
+
class Guaranteed_Query_Result_Class {
|
|
7
7
|
constructor(executer) {
|
|
8
8
|
this.executer = executer;
|
|
9
9
|
}
|
|
10
10
|
map(handle_value) {
|
|
11
|
-
return
|
|
11
|
+
return __run_guaranteed_query({
|
|
12
12
|
'execute': (on_value) => {
|
|
13
13
|
this.executer.execute((value) => {
|
|
14
14
|
on_value(handle_value(value));
|
|
@@ -17,7 +17,7 @@ class Safe_Query_Result_Class {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
then(handle_value) {
|
|
20
|
-
return
|
|
20
|
+
return __run_guaranteed_query({
|
|
21
21
|
'execute': (on_value) => {
|
|
22
22
|
this.executer.execute((value) => {
|
|
23
23
|
handle_value(value).__start(on_value);
|
|
@@ -25,20 +25,20 @@ class Safe_Query_Result_Class {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
return (0,
|
|
28
|
+
process_guaranteed(handle_value) {
|
|
29
|
+
return (0, initialize_guaranteed_procedure_context_1.__execute_guaranteed_action)({
|
|
30
30
|
'execute': (on_success) => {
|
|
31
31
|
this.executer.execute((value) => {
|
|
32
|
-
handle_value((0,
|
|
32
|
+
handle_value((0, initialize_guaranteed_procedure_context_1.initialize_guaranteed_procedure_context)(), value).__start(on_success);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
return (0,
|
|
37
|
+
process_unguaranteed(handle_value) {
|
|
38
|
+
return (0, initialize_unguaranteed_procedure_context_1.__execute_unguaranteed_action)({
|
|
39
39
|
'execute': (on_success, on_exception) => {
|
|
40
40
|
this.executer.execute((value) => {
|
|
41
|
-
handle_value((0,
|
|
41
|
+
handle_value((0, initialize_unguaranteed_procedure_context_1.initialize_unguaranteed_procedure_context)(), value).__start(on_success, on_exception);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
});
|
|
@@ -52,6 +52,6 @@ class Safe_Query_Result_Class {
|
|
|
52
52
|
* @param executer the function that produces the eventual value
|
|
53
53
|
* @returns
|
|
54
54
|
*/
|
|
55
|
-
function
|
|
56
|
-
return new
|
|
55
|
+
function __run_guaranteed_query(executer) {
|
|
56
|
+
return new Guaranteed_Query_Result_Class(executer);
|
|
57
57
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Unguaranteed_Query_Result } from "./Unguaranteed_Query_Result";
|
|
2
2
|
/**
|
|
3
3
|
* this function contains the body in which the async value or exception is executed
|
|
4
4
|
* after the execution, either the on_value or on_exception callback will be called
|
|
@@ -13,5 +13,5 @@ type Executer<T, E> = {
|
|
|
13
13
|
* @param executer the function that produces the eventual value
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function __run_unguaranteed_query<T, E>(executer: Executer<T, E>): Unguaranteed_Query_Result<T, E>;
|
|
17
17
|
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
class
|
|
3
|
+
exports.__run_unguaranteed_query = __run_unguaranteed_query;
|
|
4
|
+
const run_guaranteed_query_1 = require("./run_guaranteed_query");
|
|
5
|
+
const initialize_guaranteed_procedure_context_1 = require("./initialize_guaranteed_procedure_context");
|
|
6
|
+
const initialize_unguaranteed_procedure_context_1 = require("./initialize_unguaranteed_procedure_context");
|
|
7
|
+
class Unguaranteed_Query_Result_Class {
|
|
8
8
|
constructor(executer) {
|
|
9
9
|
this.executer = executer;
|
|
10
10
|
}
|
|
11
11
|
map(handle_value) {
|
|
12
|
-
return new
|
|
12
|
+
return new Unguaranteed_Query_Result_Class({
|
|
13
13
|
'execute': (on_value, on_exception) => {
|
|
14
14
|
this.executer.execute(($) => {
|
|
15
15
|
on_value(handle_value($));
|
|
@@ -18,7 +18,7 @@ class Unsafe_Query_Result_Class {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
then(handle_value) {
|
|
21
|
-
return new
|
|
21
|
+
return new Unguaranteed_Query_Result_Class({
|
|
22
22
|
'execute': (new_on_value, new_on_exception) => {
|
|
23
23
|
this.executer.execute(($) => {
|
|
24
24
|
handle_value($).__start(new_on_value, new_on_exception);
|
|
@@ -27,7 +27,7 @@ class Unsafe_Query_Result_Class {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
map_exception(handle_exception) {
|
|
30
|
-
return new
|
|
30
|
+
return new Unguaranteed_Query_Result_Class({
|
|
31
31
|
'execute': (on_value, on_exception) => {
|
|
32
32
|
this.executer.execute(on_value, ($) => {
|
|
33
33
|
on_exception(handle_exception($));
|
|
@@ -36,7 +36,7 @@ class Unsafe_Query_Result_Class {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
catch(handle_exception) {
|
|
39
|
-
return (0,
|
|
39
|
+
return (0, run_guaranteed_query_1.__run_guaranteed_query)({
|
|
40
40
|
'execute': (on_value) => {
|
|
41
41
|
this.executer.execute(on_value, ($) => {
|
|
42
42
|
handle_exception($).__start(on_value);
|
|
@@ -45,12 +45,12 @@ class Unsafe_Query_Result_Class {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
process(handle_exception, map_exception, handle_value) {
|
|
48
|
-
return (0,
|
|
48
|
+
return (0, initialize_unguaranteed_procedure_context_1.__execute_unguaranteed_action)({
|
|
49
49
|
'execute': (on_success, on_exception) => {
|
|
50
50
|
this.executer.execute((value) => {
|
|
51
|
-
handle_value((0,
|
|
51
|
+
handle_value((0, initialize_unguaranteed_procedure_context_1.initialize_unguaranteed_procedure_context)(), value).__start(on_success, on_exception);
|
|
52
52
|
}, (exception) => {
|
|
53
|
-
handle_exception((0,
|
|
53
|
+
handle_exception((0, initialize_guaranteed_procedure_context_1.initialize_guaranteed_procedure_context)(), exception).__start(() => on_exception(map_exception(exception)));
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -64,6 +64,6 @@ class Unsafe_Query_Result_Class {
|
|
|
64
64
|
* @param executer the function that produces the eventual value
|
|
65
65
|
* @returns
|
|
66
66
|
*/
|
|
67
|
-
function
|
|
68
|
-
return new
|
|
67
|
+
function __run_unguaranteed_query(executer) {
|
|
68
|
+
return new Unguaranteed_Query_Result_Class(executer);
|
|
69
69
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Safe_Procedure_Context } from "./Safe_Procedure_Context";
|
|
2
|
-
import { Unsafe_Procedure_Context } from "./Unsafe_Procedure_Context";
|
|
3
|
-
/**
|
|
4
|
-
* A value that will asynchronously become available.
|
|
5
|
-
* Similar to the concept of a promise, but with a smaller API.
|
|
6
|
-
*/
|
|
7
|
-
export interface Safe_Query_Result<T> {
|
|
8
|
-
map<NT>(handle_value: ($: T) => NT): Safe_Query_Result<NT>;
|
|
9
|
-
/**
|
|
10
|
-
* maps the current async value into a new async value
|
|
11
|
-
* @param handle_value callback that transforms the actual value into a new Async_Value
|
|
12
|
-
*/
|
|
13
|
-
then<NT>(handle_value: ($: T) => Safe_Query_Result<NT>): Safe_Query_Result<NT>;
|
|
14
|
-
process_safe(handle_value: ($i: Safe_Procedure_Context, $: T) => Safe_Procedure_Context): Safe_Procedure_Context;
|
|
15
|
-
process_unsafe<E>(handle_value: ($i: Unsafe_Procedure_Context<E>, $: T) => Unsafe_Procedure_Context<E>): Unsafe_Procedure_Context<E>;
|
|
16
|
-
/**
|
|
17
|
-
* This method is only to be used by resources
|
|
18
|
-
*/
|
|
19
|
-
__start(on_value: ($: T) => void): void;
|
|
20
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
import { Safe_Procedure_Context } from "./Safe_Procedure_Context";
|
|
3
|
-
export interface Unsafe_Procedure_Context<E> {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* executes a command when an exception has occurred,
|
|
7
|
-
* but stays in the unsafe context
|
|
8
|
-
*
|
|
9
|
-
* this is useful when you want to do some cleanup
|
|
10
|
-
* or logging in case of an exception,
|
|
11
|
-
* but still want to propagate the exception further
|
|
12
|
-
*
|
|
13
|
-
* note that this is different from `catch`,
|
|
14
|
-
* which would switch to the safe context
|
|
15
|
-
*/
|
|
16
|
-
process_exception<NE>(handle: ($i: Safe_Procedure_Context, $: E) => Safe_Procedure_Context, map: ($: E) => NE): Unsafe_Procedure_Context<NE>;
|
|
17
|
-
throw_exception<E>($: E): Unsafe_Procedure_Context<E>;
|
|
18
|
-
catch(handle_exception: ($i: Safe_Procedure_Context, $: E) => Safe_Procedure_Context): Safe_Procedure_Context;
|
|
19
|
-
execute_unsafe(handle: ($i: Unsafe_Procedure_Context<E>) => Unsafe_Procedure_Context<E>): Unsafe_Procedure_Context<E>;
|
|
20
|
-
execute(handle: ($i: Safe_Procedure_Context) => Safe_Procedure_Context): Unsafe_Procedure_Context<E>;
|
|
21
|
-
execute_dictionary_unsafe<E2>($: _et.Dictionary<Unsafe_Procedure_Context<E2>>, aggregate_exceptions: ($: _et.Dictionary<E2>) => E): Unsafe_Procedure_Context<E>;
|
|
22
|
-
execute_multiple_unsafe<E2>($: _et.Array<Unsafe_Procedure_Context<E2>>, aggregate_exceptions: ($: _et.Array<E2>) => E): Unsafe_Procedure_Context<E>;
|
|
23
|
-
__start(on_success: () => void, on_exception: ($: E) => void): void;
|
|
24
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Safe_Procedure_Context } from "./Safe_Procedure_Context";
|
|
2
|
-
type Executer = {
|
|
3
|
-
'execute': (on_finished: () => void) => void;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* returns an {@link Async_Value }
|
|
7
|
-
* @param executer the function that produces the eventual value
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function __execute_safe_action(executer: Executer): Safe_Procedure_Context;
|
|
11
|
-
export declare const initialize_safe_procedure_context: () => Safe_Procedure_Context;
|
|
12
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Safe_Query_Result } from "./Safe_Query_Result";
|
|
2
|
-
export type Sync_Tuple_2<T1, T2> = {
|
|
3
|
-
readonly 'first': T1;
|
|
4
|
-
readonly 'second': T2;
|
|
5
|
-
};
|
|
6
|
-
export declare function merge_2_safe_query_results<T1, T2>(first: Safe_Query_Result<T1>, second: Safe_Query_Result<T2>): Safe_Query_Result<Sync_Tuple_2<T1, T2>>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|