exupery-core-async 0.3.38 → 0.3.40

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,17 +1,28 @@
1
1
  import * as _et from 'exupery-core-types';
2
2
  import { Basic_Command } from './creaters/create_command';
3
3
  export declare namespace p {
4
- const array_parallel: <Error, Element_Error>(the_array: _et.Array<_et.Command_Promise<Element_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Array<Element_Error>, Error>) => _et.Command_Promise<Error>;
5
- const array_serie: <Error>(array: _et.Array<_et.Command_Promise<Error>>) => _et.Command_Promise<Error>;
6
- const assert_async: <Error>(assertion: _et.Query_Promise<boolean, Error>, error_if_failed: Error) => _et.Command_Promise<Error>;
7
- const assert_sync: <Error>(assertion: boolean, error_if_failed: Error) => _et.Command_Promise<Error>;
8
- const conditional_async: <Error>(precondition: _et.Query_Promise<boolean, Error>, procedure: _et.Command_Promise<Error>) => _et.Command_Promise<Error>;
9
- const conditional_sync: <Error>(precondition: boolean, procedure: _et.Command_Promise<Error>) => _et.Command_Promise<Error>;
10
- const conditional_on_processor: <Procedure_Input, Error>(precondition: _et.Process_Result<Procedure_Input, Error>, procedure: Basic_Command<Procedure_Input, Error>) => _et.Command_Promise<Error>;
11
- const conditional_on_refiner: <Procedure_Input, Refinement_Error, Error>(precondition: _et.Refinement_Result<Procedure_Input, Refinement_Error>, error_transformer: _et.Transformer_Without_Parameters<Refinement_Error, Error>, procedure: Basic_Command<Procedure_Input, Error>) => _et.Command_Promise<Error>;
12
- const dictionary_serie: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>, transform_error: _et.Transformer_Without_Parameters<_et.Key_Value_Pair<Entry_Error>, Error>) => _et.Command_Promise<Error>;
13
- const dictionary_parallel: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Dictionary<Entry_Error>, Error>) => _et.Command_Promise<Error>;
14
- const dictionary_parallel_without_transforming_the_error: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>) => _et.Command_Promise<_et.Dictionary<Entry_Error>>;
15
- const execute_with_async_data: <Parameters, Error>(procedure: _et.Command<Parameters, Error>, query: _et.Query_Promise<Parameters, Error>) => _et.Command_Promise<Error>;
4
+ namespace assert {
5
+ const direct: <Error>(assertion: boolean, error_if_failed: Error) => _et.Command_Promise<Error>;
6
+ const query: <Error>(assertion: _et.Query_Promise<boolean, Error>, error_if_failed: Error) => _et.Command_Promise<Error>;
7
+ }
8
+ namespace conditional {
9
+ const direct: <Error>(precondition: boolean, procedure: _et.Command_Promise<Error>) => _et.Command_Promise<Error>;
10
+ const query: <Error>(precondition: _et.Query_Promise<boolean, Error>, procedure: _et.Command_Promise<Error>) => _et.Command_Promise<Error>;
11
+ const procedure: <Procedure_Input, Error>(precondition: _et.Process_Result<Procedure_Input, Error>, procedure: Basic_Command<Procedure_Input, Error>) => _et.Command_Promise<Error>;
12
+ }
13
+ namespace execute {
14
+ const direct: <Parameters, Error, Procedure_Error>(procedure: _et.Command<Parameters, Procedure_Error>, error_transformer: _et.Transformer_Without_Parameters<Procedure_Error, Error>, parameters: Parameters) => _et.Command_Promise<Error>;
15
+ const query: <Parameters, Error, Procedure_Error>(procedure: _et.Command<Parameters, Procedure_Error>, error_transformer: _et.Transformer_Without_Parameters<Procedure_Error, Error>, query: _et.Query_Promise<Parameters, Error>) => _et.Command_Promise<Error>;
16
+ }
17
+ namespace list {
18
+ const parallel: <Error, Element_Error>(the_array: _et.Array<_et.Command_Promise<Element_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Array<Element_Error>, Error>) => _et.Command_Promise<Error>;
19
+ const serie: <Error>(array: _et.Array<_et.Command_Promise<Error>>) => _et.Command_Promise<Error>;
20
+ }
21
+ namespace dictionary {
22
+ const parallel: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Dictionary<Entry_Error>, Error>) => _et.Command_Promise<Error>;
23
+ const serie: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>, transform_error: _et.Transformer_Without_Parameters<_et.Key_Value_Pair<Entry_Error>, Error>) => _et.Command_Promise<Error>;
24
+ const parallel_without_transforming_the_error: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>) => _et.Command_Promise<_et.Dictionary<Entry_Error>>;
25
+ }
16
26
  const sequence: <Error>(steps: _et.Command_Promise<Error>[]) => _et.Command_Promise<Error>;
27
+ const if_refiner_succeeds_deprecated: <Procedure_Input, Refinement_Error, Error>(precondition: _et.Refinement_Result<Procedure_Input, Refinement_Error>, error_transformer: _et.Transformer_Without_Parameters<Refinement_Error, Error>, procedure: Basic_Command<Procedure_Input, Error>) => _et.Command_Promise<Error>;
17
28
  }
@@ -29,213 +29,221 @@ const create_command_promise_1 = require("./creaters/create_command_promise");
29
29
  const create_asynchronous_processes_monitor_1 = require("../create_asynchronous_processes_monitor");
30
30
  var p;
31
31
  (function (p) {
32
- p.array_parallel = (the_array, aggregate_errors) => {
33
- return (0, create_command_promise_1.__create_command_promise)({
34
- 'execute': (on_success, on_error) => {
35
- const errors = [];
36
- (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
37
- the_array.map(($) => {
38
- monitor['report process started']();
39
- $.__start(() => {
40
- monitor['report process finished']();
41
- }, (e) => {
42
- errors.push(e);
43
- monitor['report process finished']();
44
- });
45
- });
46
- }, () => {
47
- if (errors.length === 0) {
48
- on_success();
49
- }
50
- else {
51
- on_error(aggregate_errors(_ei.array_literal(errors)));
52
- }
53
- });
54
- }
55
- });
56
- };
57
- p.array_serie = (array) => {
58
- return (0, create_command_promise_1.__create_command_promise)({
59
- 'execute': (on_success, on_error) => {
60
- let current = 0;
61
- const do_next = () => {
62
- array.__get_element_at(current).transform(($) => {
63
- current += 1;
64
- $.__start(() => {
65
- do_next();
66
- }, on_error);
67
- }, () => {
68
- on_success();
69
- });
70
- };
71
- do_next();
72
- }
73
- });
74
- };
75
- p.assert_async = (assertion, error_if_failed) => {
76
- return (0, create_command_promise_1.__create_command_promise)({
77
- 'execute': (on_success, on_error) => {
78
- assertion.__start(($) => {
79
- if ($) {
80
- on_success();
81
- }
82
- else {
32
+ let assert;
33
+ (function (assert) {
34
+ assert.direct = (assertion, error_if_failed) => {
35
+ return (0, create_command_promise_1.__create_command_promise)({
36
+ 'execute': (on_success, on_error) => {
37
+ if (!assertion) {
83
38
  on_error(error_if_failed);
39
+ return;
84
40
  }
85
- }, ($) => {
86
- on_error($);
87
- });
88
- }
89
- });
90
- };
91
- p.assert_sync = (assertion, error_if_failed) => {
92
- return (0, create_command_promise_1.__create_command_promise)({
93
- 'execute': (on_success, on_error) => {
94
- if (!assertion) {
95
- on_error(error_if_failed);
96
- return;
41
+ on_success();
97
42
  }
98
- on_success();
99
- }
100
- });
101
- };
102
- p.conditional_async = (precondition, procedure) => {
103
- return (0, create_command_promise_1.__create_command_promise)({
104
- 'execute': (on_success, on_error) => {
105
- precondition.__start(($) => {
106
- if ($) {
43
+ });
44
+ };
45
+ assert.query = (assertion, error_if_failed) => {
46
+ return (0, create_command_promise_1.__create_command_promise)({
47
+ 'execute': (on_success, on_error) => {
48
+ assertion.__start(($) => {
49
+ if ($) {
50
+ on_success();
51
+ }
52
+ else {
53
+ on_error(error_if_failed);
54
+ }
55
+ }, ($) => {
56
+ on_error($);
57
+ });
58
+ }
59
+ });
60
+ };
61
+ })(assert = p.assert || (p.assert = {}));
62
+ let conditional;
63
+ (function (conditional) {
64
+ conditional.direct = (precondition, procedure) => {
65
+ return (0, create_command_promise_1.__create_command_promise)({
66
+ 'execute': (on_success, on_error) => {
67
+ if (precondition) {
107
68
  procedure.__start(on_success, on_error);
108
69
  }
109
70
  else {
110
71
  on_success();
111
72
  }
112
- }, on_error);
113
- }
114
- });
115
- };
116
- p.conditional_sync = (precondition, procedure) => {
117
- return (0, create_command_promise_1.__create_command_promise)({
118
- 'execute': (on_success, on_error) => {
119
- if (precondition) {
120
- procedure.__start(on_success, on_error);
121
73
  }
122
- else {
123
- on_success();
74
+ });
75
+ };
76
+ conditional.query = (precondition, procedure) => {
77
+ return (0, create_command_promise_1.__create_command_promise)({
78
+ 'execute': (on_success, on_error) => {
79
+ precondition.__start(($) => {
80
+ if ($) {
81
+ procedure.__start(on_success, on_error);
82
+ }
83
+ else {
84
+ on_success();
85
+ }
86
+ }, on_error);
124
87
  }
125
- }
126
- });
127
- };
128
- p.conditional_on_processor = (precondition, procedure) => {
129
- return (0, create_command_promise_1.__create_command_promise)({
130
- 'execute': (on_success, on_error) => {
131
- precondition.__extract_data(($) => {
132
- procedure($).__start(on_success, on_error);
133
- }, on_error);
134
- }
135
- });
136
- };
137
- p.conditional_on_refiner = (precondition, error_transformer, procedure) => {
138
- return (0, create_command_promise_1.__create_command_promise)({
139
- 'execute': (on_success, on_error) => {
140
- precondition.process(($) => {
141
- procedure($).__start(on_success, on_error);
142
- }, (e) => {
143
- on_error(error_transformer(e));
144
- });
145
- }
146
- });
147
- };
148
- p.dictionary_serie = (dictionary, transform_error) => {
149
- return (0, create_command_promise_1.__create_command_promise)({
150
- 'execute': (on_success, on_error) => {
151
- const op_dictionary_to_list_based_on_insertion_order = (dict) => {
152
- const temp = [];
153
- dict.map(($, key) => {
154
- temp.push({ key, value: $ });
155
- });
156
- return _ei.array_literal(temp);
157
- };
158
- const as_list = op_dictionary_to_list_based_on_insertion_order(dictionary);
159
- let current = 0;
160
- const do_next = () => {
161
- as_list.__get_element_at(current).transform(($) => {
162
- const key = $.key;
163
- current += 1;
164
- $.value.__start(() => {
165
- do_next();
166
- }, ($) => {
167
- on_error(transform_error({
168
- 'value': $,
169
- 'key': key,
170
- }));
88
+ });
89
+ };
90
+ conditional.procedure = (precondition, procedure) => {
91
+ return (0, create_command_promise_1.__create_command_promise)({
92
+ 'execute': (on_success, on_error) => {
93
+ precondition.__extract_data(($) => {
94
+ procedure($).__start(on_success, on_error);
95
+ }, on_error);
96
+ }
97
+ });
98
+ };
99
+ })(conditional = p.conditional || (p.conditional = {}));
100
+ let execute;
101
+ (function (execute) {
102
+ execute.direct = (procedure, error_transformer, parameters) => {
103
+ return procedure['execute with synchronous data'](parameters, error_transformer);
104
+ };
105
+ execute.query = (procedure, error_transformer, query) => {
106
+ return (0, create_command_promise_1.__create_command_promise)({
107
+ 'execute': (on_success, on_error) => {
108
+ query.__start((query_result) => {
109
+ procedure['execute with synchronous data'](query_result, error_transformer).__start(on_success, on_error);
110
+ }, on_error);
111
+ }
112
+ });
113
+ };
114
+ })(execute = p.execute || (p.execute = {}));
115
+ let list;
116
+ (function (list) {
117
+ list.parallel = (the_array, aggregate_errors) => {
118
+ return (0, create_command_promise_1.__create_command_promise)({
119
+ 'execute': (on_success, on_error) => {
120
+ const errors = [];
121
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
122
+ the_array.map(($) => {
123
+ monitor['report process started']();
124
+ $.__start(() => {
125
+ monitor['report process finished']();
126
+ }, (e) => {
127
+ errors.push(e);
128
+ monitor['report process finished']();
129
+ });
171
130
  });
172
131
  }, () => {
173
- on_success();
132
+ if (errors.length === 0) {
133
+ on_success();
134
+ }
135
+ else {
136
+ on_error(aggregate_errors(_ei.array_literal(errors)));
137
+ }
174
138
  });
175
- };
176
- do_next();
177
- }
178
- });
179
- };
180
- p.dictionary_parallel = (dictionary, aggregate_errors) => {
181
- return (0, create_command_promise_1.__create_command_promise)({
182
- 'execute': (on_success, on_error) => {
183
- const errors = {};
184
- (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
185
- dictionary.map(($, key) => {
186
- monitor['report process started']();
187
- $.__start(() => {
188
- monitor['report process finished']();
189
- }, (e) => {
190
- errors[key] = e;
191
- monitor['report process finished']();
139
+ }
140
+ });
141
+ };
142
+ list.serie = (array) => {
143
+ return (0, create_command_promise_1.__create_command_promise)({
144
+ 'execute': (on_success, on_error) => {
145
+ let current = 0;
146
+ const do_next = () => {
147
+ array.__get_element_at(current).transform(($) => {
148
+ current += 1;
149
+ $.__start(() => {
150
+ do_next();
151
+ }, on_error);
152
+ }, () => {
153
+ on_success();
154
+ });
155
+ };
156
+ do_next();
157
+ }
158
+ });
159
+ };
160
+ })(list = p.list || (p.list = {}));
161
+ let dictionary;
162
+ (function (dictionary_1) {
163
+ dictionary_1.parallel = (dictionary, aggregate_errors) => {
164
+ return (0, create_command_promise_1.__create_command_promise)({
165
+ 'execute': (on_success, on_error) => {
166
+ const errors = {};
167
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
168
+ dictionary.map(($, key) => {
169
+ monitor['report process started']();
170
+ $.__start(() => {
171
+ monitor['report process finished']();
172
+ }, (e) => {
173
+ errors[key] = e;
174
+ monitor['report process finished']();
175
+ });
192
176
  });
177
+ }, () => {
178
+ if (Object.keys(errors).length === 0) {
179
+ on_success();
180
+ }
181
+ else {
182
+ on_error(aggregate_errors(_ei.dictionary_literal(errors)));
183
+ }
193
184
  });
194
- }, () => {
195
- if (Object.keys(errors).length === 0) {
196
- on_success();
197
- }
198
- else {
199
- on_error(aggregate_errors(_ei.dictionary_literal(errors)));
200
- }
201
- });
202
- }
203
- });
204
- };
205
- p.dictionary_parallel_without_transforming_the_error = (dictionary) => {
206
- return (0, create_command_promise_1.__create_command_promise)({
207
- 'execute': (on_success, on_error) => {
208
- const errors = {};
209
- (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
210
- dictionary.map(($, key) => {
211
- monitor['report process started']();
212
- $.__start(() => {
213
- monitor['report process finished']();
214
- }, (e) => {
215
- errors[key] = e;
216
- monitor['report process finished']();
185
+ }
186
+ });
187
+ };
188
+ dictionary_1.serie = (dictionary, transform_error) => {
189
+ return (0, create_command_promise_1.__create_command_promise)({
190
+ 'execute': (on_success, on_error) => {
191
+ const op_dictionary_to_list_based_on_insertion_order = (dict) => {
192
+ const temp = [];
193
+ dict.map(($, key) => {
194
+ temp.push({ key, value: $ });
195
+ });
196
+ return _ei.array_literal(temp);
197
+ };
198
+ const as_list = op_dictionary_to_list_based_on_insertion_order(dictionary);
199
+ let current = 0;
200
+ const do_next = () => {
201
+ as_list.__get_element_at(current).transform(($) => {
202
+ const key = $.key;
203
+ current += 1;
204
+ $.value.__start(() => {
205
+ do_next();
206
+ }, ($) => {
207
+ on_error(transform_error({
208
+ 'value': $,
209
+ 'key': key,
210
+ }));
211
+ });
212
+ }, () => {
213
+ on_success();
214
+ });
215
+ };
216
+ do_next();
217
+ }
218
+ });
219
+ };
220
+ dictionary_1.parallel_without_transforming_the_error = (dictionary) => {
221
+ return (0, create_command_promise_1.__create_command_promise)({
222
+ 'execute': (on_success, on_error) => {
223
+ const errors = {};
224
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
225
+ dictionary.map(($, key) => {
226
+ monitor['report process started']();
227
+ $.__start(() => {
228
+ monitor['report process finished']();
229
+ }, (e) => {
230
+ errors[key] = e;
231
+ monitor['report process finished']();
232
+ });
217
233
  });
234
+ }, () => {
235
+ if (Object.keys(errors).length === 0) {
236
+ on_success();
237
+ }
238
+ else {
239
+ on_error(_ei.dictionary_literal(errors));
240
+ }
218
241
  });
219
- }, () => {
220
- if (Object.keys(errors).length === 0) {
221
- on_success();
222
- }
223
- else {
224
- on_error(_ei.dictionary_literal(errors));
225
- }
226
- });
227
- }
228
- });
229
- };
230
- p.execute_with_async_data = (procedure, query) => {
231
- return (0, create_command_promise_1.__create_command_promise)({
232
- 'execute': (on_success, on_error) => {
233
- query.__start((query_result) => {
234
- procedure['execute with synchronous data without error transformation'](query_result).__start(on_success, on_error);
235
- }, on_error);
236
- }
237
- });
238
- };
242
+ }
243
+ });
244
+ };
245
+ })(dictionary = p.dictionary || (p.dictionary = {}));
246
+ // Sequencing function:
239
247
  p.sequence = (steps) => {
240
248
  return (0, create_command_promise_1.__create_command_promise)({
241
249
  'execute': (on_success, on_error) => {
@@ -251,4 +259,15 @@ var p;
251
259
  }
252
260
  });
253
261
  };
262
+ p.if_refiner_succeeds_deprecated = (precondition, error_transformer, procedure) => {
263
+ return (0, create_command_promise_1.__create_command_promise)({
264
+ 'execute': (on_success, on_error) => {
265
+ precondition.process(($) => {
266
+ procedure($).__start(on_success, on_error);
267
+ }, (e) => {
268
+ on_error(error_transformer(e));
269
+ });
270
+ }
271
+ });
272
+ };
254
273
  })(p || (exports.p = p = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.3.38",
3
+ "version": "0.3.40",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",