exupery-core-async 0.3.27 → 0.3.29

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.
@@ -1,22 +1,12 @@
1
1
  import * as _et from 'exupery-core-types';
2
- export type Assert_Async_Error<Assertion_Error, Procedure_Error> = ['assertion error', Assertion_Error] | ['assertion failed', null] | ['procedure error', Procedure_Error];
3
- export type Assert_Sync_Error<Procedure_Error> = ['assertion failed', null] | ['procedure error', Procedure_Error];
4
- export type Conditional_Async_Error<Precondition_Error, Procedure_Error> = ['precondition', Precondition_Error] | ['procedure', Procedure_Error];
5
- export type Conditional_Multiple_Error<Precondition_Error, Procedure_Error> = ['preconditions', _et.Dictionary<Precondition_Error>] | ['procedure', Procedure_Error];
6
- export type Dictionary_Serie_Error<Err> = {
7
- 'error': Err;
8
- 'step': string;
9
- };
10
2
  export declare namespace p {
11
3
  const array_parallel: <Error, Element_Error>(the_array: _et.Array<_et.Procedure_Promise<Element_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Array<Element_Error>, Error>) => _et.Procedure_Promise<Error>;
12
4
  const array_serie: <Error>(array: _et.Array<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<Error>;
13
- const assert_async: <Assertion_Error, Procedure_Error>(assertion: _et.Query_Promise<boolean, Assertion_Error>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Assert_Async_Error<Assertion_Error, Procedure_Error>>;
14
- const assert_sync: <Assertion_Error, Procedure_Error>(assertion: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Assert_Sync_Error<Procedure_Error>>;
15
- const conditional_async: <Precondition_Error, Procedure_Error>(precondition: _et.Query_Promise<boolean, Precondition_Error>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Conditional_Async_Error<Precondition_Error, Procedure_Error>>;
16
- const conditional_multiple: <Precondition_Error, Procedure_Error>(preconditions: _et.Dictionary<_et.Query_Promise<boolean, Precondition_Error>>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Conditional_Multiple_Error<Precondition_Error, Procedure_Error>>;
17
- const conditional_sync: <Procedure_Error>(precondition: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Procedure_Error>;
18
- const dictionary_serie: <Err>(dictionary: _et.Dictionary<_et.Procedure_Promise<Err>>) => _et.Procedure_Promise<Dictionary_Serie_Error<Err>>;
19
- const dictionary_parallel_without_error_aggregation: <Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<_et.Dictionary<Error>>;
5
+ const assert_async: <Error>(assertion: _et.Query_Promise<boolean, Error>, error_if_failed: Error) => _et.Procedure_Promise<Error>;
6
+ const assert_sync: <Error>(assertion: boolean, error_if_failed: Error) => _et.Procedure_Promise<Error>;
7
+ const conditional_async: <Error>(precondition: _et.Query_Promise<boolean, Error>, procedure: _et.Procedure_Promise<Error>) => _et.Procedure_Promise<Error>;
8
+ const conditional_sync: <Error>(precondition: boolean, procedure: _et.Procedure_Promise<Error>) => _et.Procedure_Promise<Error>;
9
+ const dictionary_serie: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Entry_Error>>, transform_error: _et.Transformer_Without_Parameters<_et.Key_Value_Pair<Entry_Error>, Error>) => _et.Procedure_Promise<Error>;
20
10
  const dictionary_parallel: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Entry_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Dictionary<Entry_Error>, Error>) => _et.Procedure_Promise<Error>;
21
11
  const execute_with_async_data: <Parameters, Error>(procedure: _et.Procedure_Primed_With_Resources<Parameters, Error>, query: _et.Query_Promise<Parameters, Error>) => _et.Procedure_Promise<Error>;
22
12
  const sequence: <Error>(steps: _et.Procedure_Promise<Error>[]) => _et.Procedure_Promise<Error>;
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.p = void 0;
27
27
  const _ei = __importStar(require("exupery-core-internals"));
28
28
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
29
- const query_1 = require("./query");
30
29
  const create_asynchronous_processes_monitor_1 = require("../create_asynchronous_processes_monitor");
31
30
  var p;
32
31
  (function (p) {
@@ -73,34 +72,30 @@ var p;
73
72
  }
74
73
  });
75
74
  };
76
- p.assert_async = (assertion, procedure) => {
75
+ p.assert_async = (assertion, error_if_failed) => {
77
76
  return (0, create_procedure_promise_1.__create_procedure_promise)({
78
77
  'execute': (on_success, on_error) => {
79
78
  assertion.__start(($) => {
80
79
  if ($) {
81
- procedure.__start(on_success, ($) => {
82
- on_error(['procedure error', $]);
83
- });
80
+ on_success();
84
81
  }
85
82
  else {
86
- on_error(['assertion failed', null]);
83
+ on_error(error_if_failed);
87
84
  }
88
85
  }, ($) => {
89
- on_error(['assertion error', $]);
86
+ on_error($);
90
87
  });
91
88
  }
92
89
  });
93
90
  };
94
- p.assert_sync = (assertion, procedure) => {
91
+ p.assert_sync = (assertion, error_if_failed) => {
95
92
  return (0, create_procedure_promise_1.__create_procedure_promise)({
96
93
  'execute': (on_success, on_error) => {
97
94
  if (!assertion) {
98
- on_error(['assertion failed', null]);
95
+ on_error(error_if_failed);
99
96
  return;
100
97
  }
101
- procedure.__start(on_success, ($) => {
102
- on_error(['procedure error', $]);
103
- });
98
+ on_success();
104
99
  }
105
100
  });
106
101
  };
@@ -109,42 +104,12 @@ var p;
109
104
  'execute': (on_success, on_error) => {
110
105
  precondition.__start(($) => {
111
106
  if ($) {
112
- procedure.__start(on_success, (e) => {
113
- on_error(['procedure', e]);
114
- });
115
- }
116
- else {
117
- on_success();
118
- }
119
- }, ($) => {
120
- on_error(['precondition', $]);
121
- });
122
- }
123
- });
124
- };
125
- p.conditional_multiple = (preconditions, procedure) => {
126
- return (0, create_procedure_promise_1.__create_procedure_promise)({
127
- 'execute': (on_success, on_error) => {
128
- query_1.q.dictionary_parallel_without_error_aggregation(preconditions).__start(($) => {
129
- let has_errors = false;
130
- $.map(($) => {
131
- if (!$) {
132
- has_errors = true;
133
- }
134
- });
135
- if (!has_errors) {
136
- // all preconditions passed
137
- procedure.__start(on_success, (e) => {
138
- on_error(['procedure', e]);
139
- });
107
+ procedure.__start(on_success, on_error);
140
108
  }
141
109
  else {
142
- //the preconditions failed, so we are *successfully* skipping the procedure
143
110
  on_success();
144
111
  }
145
- }, ($) => {
146
- on_error(['preconditions', $]);
147
- });
112
+ }, on_error);
148
113
  }
149
114
  });
150
115
  };
@@ -160,7 +125,7 @@ var p;
160
125
  }
161
126
  });
162
127
  };
163
- p.dictionary_serie = (dictionary) => {
128
+ p.dictionary_serie = (dictionary, transform_error) => {
164
129
  return (0, create_procedure_promise_1.__create_procedure_promise)({
165
130
  'execute': (on_success, on_error) => {
166
131
  const op_dictionary_to_list_based_on_insertion_order = (dict) => {
@@ -179,10 +144,10 @@ var p;
179
144
  $.value.__start(() => {
180
145
  do_next();
181
146
  }, ($) => {
182
- on_error({
183
- 'error': $,
184
- 'step': key,
185
- });
147
+ on_error(transform_error({
148
+ 'value': $,
149
+ 'key': key,
150
+ }));
186
151
  });
187
152
  }, () => {
188
153
  on_success();
@@ -192,35 +157,6 @@ var p;
192
157
  }
193
158
  });
194
159
  };
195
- p.dictionary_parallel_without_error_aggregation = (dictionary) => {
196
- return (0, create_procedure_promise_1.__create_procedure_promise)({
197
- 'execute': (on_success, on_error) => {
198
- let count_down = dictionary.__get_number_of_entries();
199
- let has_errors = false;
200
- const errors = {};
201
- const decrement_and_wrap_up_if_done = () => {
202
- count_down -= 1;
203
- if (count_down === 0) {
204
- if (has_errors) {
205
- on_error(_ei.dictionary_literal(errors));
206
- }
207
- else {
208
- on_success();
209
- }
210
- }
211
- };
212
- dictionary.map(($, key) => {
213
- $.__start(() => {
214
- decrement_and_wrap_up_if_done();
215
- }, (e) => {
216
- has_errors = true;
217
- errors[key] = e;
218
- decrement_and_wrap_up_if_done();
219
- });
220
- });
221
- }
222
- });
223
- };
224
160
  p.dictionary_parallel = (dictionary, aggregate_errors) => {
225
161
  return (0, create_procedure_promise_1.__create_procedure_promise)({
226
162
  'execute': (on_success, on_error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.3.27",
3
+ "version": "0.3.29",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",