exupery-core-async 0.3.3 → 0.3.5

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.
@@ -8,5 +8,4 @@ type Executer = {
8
8
  * @returns
9
9
  */
10
10
  export declare function __create_guaranted_procedure(executer: Executer): Guaranteed_Procedure_Promise;
11
- export declare const initialize_no_op_guaranteed_procedure: () => Guaranteed_Procedure_Promise;
12
11
  export {};
@@ -1,23 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialize_no_op_guaranteed_procedure = void 0;
4
3
  exports.__create_guaranted_procedure = __create_guaranted_procedure;
5
- class Guaranteed_Procedure_Class {
4
+ class Guaranteed_Procedure_Promise_Class {
6
5
  constructor(executer) {
7
6
  this.executer = executer;
8
7
  }
9
- x_execute(get_action, get_parameters, get_resources) {
10
- return __create_guaranted_procedure({
11
- 'execute': (on_finished) => {
12
- this.executer.execute(() => {
13
- const action = get_action();
14
- const params = get_parameters();
15
- const resources = get_resources();
16
- action(params, resources).__start(on_finished);
17
- });
18
- }
19
- });
20
- }
21
8
  __start(on_finished) {
22
9
  this.executer.execute(on_finished);
23
10
  }
@@ -28,13 +15,5 @@ class Guaranteed_Procedure_Class {
28
15
  * @returns
29
16
  */
30
17
  function __create_guaranted_procedure(executer) {
31
- return new Guaranteed_Procedure_Class(executer);
18
+ return new Guaranteed_Procedure_Promise_Class(executer);
32
19
  }
33
- const initialize_no_op_guaranteed_procedure = () => {
34
- return new Guaranteed_Procedure_Class({
35
- 'execute': (on_finished) => {
36
- on_finished(); //nothing to do, call on_finished immediately
37
- }
38
- });
39
- };
40
- exports.initialize_no_op_guaranteed_procedure = initialize_no_op_guaranteed_procedure;
@@ -14,5 +14,4 @@ type Executer<E> = {
14
14
  * @returns
15
15
  */
16
16
  export declare function __create_unguaranteed_procedure<E>(executer: Executer<E>): Unguaranteed_Procedure_Promise<E>;
17
- export declare const initialize_no_op_unguaranteed_procedure: <E>() => Unguaranteed_Procedure_Promise<E>;
18
17
  export {};
@@ -1,14 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialize_no_op_unguaranteed_procedure = void 0;
4
3
  exports.__create_unguaranteed_procedure = __create_unguaranteed_procedure;
5
- class Unguaranteed_Procedure_Class {
4
+ class Unguaranteed_Procedure_Promise_Class {
6
5
  constructor(executer) {
7
6
  this.executer = executer;
8
7
  }
9
8
  __start(on_success, on_exception) {
10
9
  this.executer.execute(on_success, on_exception);
11
10
  }
11
+ map_error(handle_error) {
12
+ return new Unguaranteed_Procedure_Promise_Class({
13
+ 'execute': (on_success, on_exception) => {
14
+ this.executer.execute(on_success, (error) => {
15
+ on_exception(handle_error(error));
16
+ });
17
+ }
18
+ });
19
+ }
12
20
  }
13
21
  /**
14
22
  * returns an {@link Async_Value }
@@ -16,13 +24,5 @@ class Unguaranteed_Procedure_Class {
16
24
  * @returns
17
25
  */
18
26
  function __create_unguaranteed_procedure(executer) {
19
- return new Unguaranteed_Procedure_Class(executer);
27
+ return new Unguaranteed_Procedure_Promise_Class(executer);
20
28
  }
21
- const initialize_no_op_unguaranteed_procedure = () => {
22
- return new Unguaranteed_Procedure_Class({
23
- 'execute': (on_success, on_exception) => {
24
- on_success(); //nothing to do, call on_finished immediately
25
- }
26
- });
27
- };
28
- exports.initialize_no_op_unguaranteed_procedure = initialize_no_op_unguaranteed_procedure;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.__create_guaranteed_query = __create_guaranteed_query;
4
- class Guaranteed_Query_Result_Class {
4
+ class Guaranteed_Query_Result_Promise_Class {
5
5
  constructor(executer) {
6
6
  this.executer = executer;
7
7
  }
@@ -33,5 +33,5 @@ class Guaranteed_Query_Result_Class {
33
33
  * @returns
34
34
  */
35
35
  function __create_guaranteed_query(executer) {
36
- return new Guaranteed_Query_Result_Class(executer);
36
+ return new Guaranteed_Query_Result_Promise_Class(executer);
37
37
  }
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.__create_unguaranteed_query = __create_unguaranteed_query;
4
4
  const create_guaranteed_query_1 = require("./create_guaranteed_query");
5
- class Unguaranteed_Query_Result_Class {
5
+ class Unguaranteed_Query_Result_Promise_Class {
6
6
  constructor(executer) {
7
7
  this.executer = executer;
8
8
  }
9
9
  map_(handle_value) {
10
- return new Unguaranteed_Query_Result_Class({
10
+ return new Unguaranteed_Query_Result_Promise_Class({
11
11
  'execute': (on_value, on_exception) => {
12
12
  this.executer.execute(($) => {
13
13
  on_value(handle_value($));
@@ -16,7 +16,7 @@ class Unguaranteed_Query_Result_Class {
16
16
  });
17
17
  }
18
18
  then(handle_value) {
19
- return new Unguaranteed_Query_Result_Class({
19
+ return new Unguaranteed_Query_Result_Promise_Class({
20
20
  'execute': (new_on_value, new_on_exception) => {
21
21
  this.executer.execute(($) => {
22
22
  handle_value($).__start(new_on_value);
@@ -25,7 +25,7 @@ class Unguaranteed_Query_Result_Class {
25
25
  });
26
26
  }
27
27
  then_unguaranteed(handle_value) {
28
- return new Unguaranteed_Query_Result_Class({
28
+ return new Unguaranteed_Query_Result_Promise_Class({
29
29
  'execute': (new_on_value, new_on_exception) => {
30
30
  this.executer.execute(($) => {
31
31
  handle_value($).__start(new_on_value, new_on_exception);
@@ -34,7 +34,7 @@ class Unguaranteed_Query_Result_Class {
34
34
  });
35
35
  }
36
36
  map_exception_(handle_exception) {
37
- return new Unguaranteed_Query_Result_Class({
37
+ return new Unguaranteed_Query_Result_Promise_Class({
38
38
  'execute': (on_value, on_exception) => {
39
39
  this.executer.execute(on_value, ($) => {
40
40
  on_exception(handle_exception($));
@@ -61,5 +61,5 @@ class Unguaranteed_Query_Result_Class {
61
61
  * @returns
62
62
  */
63
63
  function __create_unguaranteed_query(executer) {
64
- return new Unguaranteed_Query_Result_Class(executer);
64
+ return new Unguaranteed_Query_Result_Promise_Class(executer);
65
65
  }
package/dist/index.d.ts CHANGED
@@ -8,8 +8,6 @@ export * from "./algorithms/query/create_unguaranteed_query";
8
8
  export * from "./algorithms/procedure/initialize_guaranteed_procedure";
9
9
  export * from "./algorithms/procedure/initialize_unguaranteed_procedure";
10
10
  export * from "./shorthands";
11
- import { Guaranteed_Procedure_Promise } from "./types/Guaranteed_Procedure";
12
- import { Unguaranteed_Procedure_Promise } from "./types/Unguaranteed_Procedure";
13
11
  import { Guaranteed_Query_Promise } from "./types/Guaranteed_Query";
14
12
  import { Unguaranteed_Query_Promise } from "./types/Unguaranteed_Query";
15
13
  export declare const query: {
@@ -21,12 +19,3 @@ export declare const query: {
21
19
  'raise exception': <T, E>($: E) => Unguaranteed_Query_Promise<T, E>;
22
20
  };
23
21
  };
24
- export declare const command: {
25
- guaranteed: {
26
- initialize: () => Guaranteed_Procedure_Promise;
27
- };
28
- unguaranteed: {
29
- initialize: <E>() => Unguaranteed_Procedure_Promise<E>;
30
- 'raise exception': <E>($: E) => Unguaranteed_Procedure_Promise<E>;
31
- };
32
- };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.command = exports.query = void 0;
17
+ exports.query = void 0;
18
18
  //types
19
19
  __exportStar(require("./types/Guaranteed_Procedure"), exports);
20
20
  __exportStar(require("./types/Unguaranteed_Procedure"), exports);
@@ -27,8 +27,6 @@ __exportStar(require("./algorithms/query/create_unguaranteed_query"), exports);
27
27
  __exportStar(require("./algorithms/procedure/initialize_guaranteed_procedure"), exports);
28
28
  __exportStar(require("./algorithms/procedure/initialize_unguaranteed_procedure"), exports);
29
29
  __exportStar(require("./shorthands"), exports);
30
- const initialize_guaranteed_procedure_1 = require("./algorithms/procedure/initialize_guaranteed_procedure");
31
- const initialize_unguaranteed_procedure_1 = require("./algorithms/procedure/initialize_unguaranteed_procedure");
32
30
  const create_guaranteed_query_1 = require("./algorithms/query/create_guaranteed_query");
33
31
  const create_unguaranteed_query_1 = require("./algorithms/query/create_unguaranteed_query");
34
32
  exports.query = {
@@ -58,162 +56,3 @@ exports.query = {
58
56
  }
59
57
  },
60
58
  };
61
- exports.command = {
62
- 'guaranteed': {
63
- 'initialize': initialize_guaranteed_procedure_1.initialize_no_op_guaranteed_procedure
64
- },
65
- 'unguaranteed': {
66
- 'initialize': initialize_unguaranteed_procedure_1.initialize_no_op_unguaranteed_procedure,
67
- 'raise exception': ($) => {
68
- return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
69
- 'execute': (on_success, on_exception) => {
70
- on_exception($);
71
- }
72
- });
73
- },
74
- },
75
- };
76
- // //array
77
- // map_async<NT>(
78
- // handle_value: ($: T) => Safe_Query_Result<NT>
79
- // ): Safe_Query_Result<Array<NT>>
80
- // map_async_unsafe<NT, NE>(
81
- // handle_value: ($: T) => Unsafe_Query_Result<NT, NE>
82
- // ): Unsafe_Query_Result<Array<NT>, Array<NE>>
83
- // //dictionary
84
- // /**
85
- // *
86
- // * @param handle_value callback that provides an {@link Safe_Query_Result}. keys are not available.
87
- // */
88
- // query_safe_with_entries<NT>(
89
- // handle_value: ($: T) => Safe_Query_Result<NT>
90
- // ): Safe_Query_Result<Dictionary<NT>>
91
- // query_unsafe_with_entries<NT, NE>(
92
- // handle_value: ($: T) => Unsafe_Query_Result<NT, NE>,
93
- // ): Unsafe_Query_Result<Dictionary<NT>, Dictionary<NE>>
94
- // map_async<NT>(on_entry_value: ($: T) => _et.Async_Value<NT>): _et.Async_Value<_et.Dictionary<NT>> {
95
- // const source = this.source
96
- // const temp: { [key: string]: NT } = {}
97
- // return create_Async_Value(
98
- // {
99
- // 'execute': (on_dictionary_value) => {
100
- // create_asynchronous_processes_monitor(
101
- // (counter) => {
102
- // source.map(($) => {
103
- // counter['report process started']()
104
- // on_entry_value($.value).__start((nv) => {
105
- // temp[$.key] = nv
106
- // counter['report process finished']()
107
- // })
108
- // })
109
- // },
110
- // () => {
111
- // on_dictionary_value(dictionary_literal(temp))
112
- // }
113
- // )
114
- // }
115
- // }
116
- // )
117
- // }
118
- // map_async_unsafe<NT, NE>(on_entry_value: ($: T) => _et.Unsafe_Async_Value<NT, NE>): _et.Unsafe_Async_Value<_et.Dictionary<NT>, _et.Dictionary<NE>> {
119
- // const source = this.source
120
- // const temp_values: { [key: string]: NT } = {}
121
- // const temp_exceptions: { [key: string]: NE } = {}
122
- // return create_Unsafe_Async_Value(
123
- // {
124
- // 'execute': (
125
- // on_dictionary_value,
126
- // on_dictionary_exception,
127
- // ) => {
128
- // create_asynchronous_processes_monitor(
129
- // (counter) => {
130
- // source.map(($) => {
131
- // counter['report process started']()
132
- // on_entry_value($.value).__start(
133
- // (value) => {
134
- // temp_values[$.key] = value
135
- // counter['report process finished']()
136
- // },
137
- // (exception) => {
138
- // temp_exceptions[$.key] = exception
139
- // counter['report process finished']()
140
- // },
141
- // )
142
- // })
143
- // },
144
- // () => {
145
- // if (Object.keys(temp_exceptions).length > 0) {
146
- // on_dictionary_exception(dictionary_literal(temp_exceptions))
147
- // } else {
148
- // on_dictionary_value(dictionary_literal(temp_values))
149
- // }
150
- // }
151
- // )
152
- // }
153
- // }
154
- // )
155
- // }
156
- // map_async<NT>(on_element_value: ($: T) => _et.Async_Value<NT>): _et.Async_Value<_et.Array<NT>> {
157
- // const data = this.data
158
- // return create_Async_Value(
159
- // {
160
- // 'execute': (on_array_value) => {
161
- // const temp: NT[] = []
162
- // create_asynchronous_processes_monitor(
163
- // (registry) => {
164
- // data.map(on_element_value).forEach((v) => {
165
- // registry['report process started']()
166
- // v.__start((v) => {
167
- // temp.push(v)
168
- // registry['report process finished']()
169
- // })
170
- // })
171
- // },
172
- // () => {
173
- // on_array_value(array_literal(temp))
174
- // }
175
- // )
176
- // }
177
- // },
178
- // )
179
- // }
180
- // map_async_unsafe<NT, NE>(
181
- // on_element_value: ($: T) => _et.Unsafe_Async_Value<NT, NE>
182
- // ): _et.Unsafe_Async_Value<_et.Array<NT>, _et.Array<NE>> {
183
- // const data = this.data
184
- // return create_Unsafe_Async_Value(
185
- // {
186
- // 'execute': (
187
- // on_array_value,
188
- // on_array_exception,
189
- // ) => {
190
- // const temp_values: NT[] = []
191
- // const temp_exceptions: NE[] = []
192
- // create_asynchronous_processes_monitor(
193
- // (registry) => {
194
- // data.map(on_element_value).forEach((v) => {
195
- // registry['report process started']()
196
- // v.__start(
197
- // ($) => {
198
- // temp_values.push($)
199
- // registry['report process finished']()
200
- // },
201
- // ($) => {
202
- // temp_exceptions.push($)
203
- // registry['report process finished']()
204
- // }
205
- // )
206
- // })
207
- // },
208
- // () => {
209
- // if (temp_exceptions.length > 0) {
210
- // on_array_exception(array_literal(temp_exceptions))
211
- // } else {
212
- // on_array_value(array_literal(temp_values))
213
- // }
214
- // }
215
- // )
216
- // }
217
- // },
218
- // )
219
- // }
@@ -110,8 +110,8 @@ var up;
110
110
  * @param query u.q
111
111
  */
112
112
  up.action = (action, query, resources) => {
113
- return {
114
- __start: (on_success, on_error) => {
113
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
114
+ 'execute': (on_success, on_error) => {
115
115
  //run the query
116
116
  query.__start((query_result) => {
117
117
  //run the action
@@ -121,7 +121,7 @@ var up;
121
121
  });
122
122
  }, on_error);
123
123
  }
124
- };
124
+ });
125
125
  };
126
126
  /**
127
127
  *
@@ -129,8 +129,8 @@ var up;
129
129
  * @returns
130
130
  */
131
131
  up.sequence = (steps) => {
132
- return {
133
- __start: (on_success, on_error) => {
132
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
133
+ 'execute': (on_success, on_error) => {
134
134
  const length = _ei.array_literal(steps).__get_number_of_elements();
135
135
  const runStep = (index) => {
136
136
  if (index >= length) {
@@ -141,7 +141,7 @@ var up;
141
141
  };
142
142
  runStep(0);
143
143
  }
144
- };
144
+ });
145
145
  };
146
146
  /**
147
147
  *
@@ -150,8 +150,8 @@ var up;
150
150
  * @returns
151
151
  */
152
152
  up.array = (the_array, aggregate_exceptions) => {
153
- return {
154
- __start: (on_success, on_error) => {
153
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
154
+ 'execute': (on_success, on_error) => {
155
155
  const exceptions = [];
156
156
  (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
157
157
  the_array.map(($) => {
@@ -172,7 +172,7 @@ var up;
172
172
  }
173
173
  });
174
174
  }
175
- };
175
+ });
176
176
  };
177
177
  /**
178
178
  *
@@ -181,8 +181,8 @@ var up;
181
181
  * @returns
182
182
  */
183
183
  up.dictionary = (the_dictionary, aggregate_exceptions) => {
184
- return {
185
- __start: (on_success, on_error) => {
184
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
185
+ 'execute': (on_success, on_error) => {
186
186
  const exceptions = {};
187
187
  (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
188
188
  the_dictionary.map(($, key) => {
@@ -203,7 +203,7 @@ var up;
203
203
  }
204
204
  });
205
205
  }
206
- };
206
+ });
207
207
  };
208
208
  })(up || (exports.up = up = {}));
209
209
  var upi;
@@ -1,4 +1,4 @@
1
1
  export type Guaranteed_Procedure<Parameters, Resources> = ($: Parameters, $r: Resources) => Guaranteed_Procedure_Promise;
2
- export interface Guaranteed_Procedure_Promise {
2
+ export type Guaranteed_Procedure_Promise = {
3
3
  __start: (on_finished: () => void) => void;
4
- }
4
+ };
@@ -1,4 +1,5 @@
1
1
  export type Unguaranteed_Procedure<Parameters, Error, Resources> = ($: Parameters, $r: Resources) => Unguaranteed_Procedure_Promise<Error>;
2
- export interface Unguaranteed_Procedure_Promise<Error> {
2
+ export type Unguaranteed_Procedure_Promise<Error> = {
3
3
  __start: (on_success: () => void, on_error: (error: Error) => void) => void;
4
- }
4
+ map_error<NE>(handle_error: (error: Error) => NE): Unguaranteed_Procedure_Promise<NE>;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",