exupery-core-async 0.3.37 → 0.3.39

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
+ const transformer: <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>;
13
+ }
14
+ namespace execute {
15
+ const direct: <Parameters, Error>(procedure: _et.Command<Parameters, Error>, parameters: Parameters) => _et.Command_Promise<Error>;
16
+ const query: <Parameters, Error>(procedure: _et.Command<Parameters, Error>, query: _et.Query_Promise<Parameters, Error>) => _et.Command_Promise<Error>;
17
+ }
18
+ namespace list {
19
+ 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>;
20
+ const serie: <Error>(array: _et.Array<_et.Command_Promise<Error>>) => _et.Command_Promise<Error>;
21
+ }
22
+ namespace dictionary {
23
+ 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>;
24
+ 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>;
25
+ const parallel_without_transforming_the_error: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Command_Promise<Entry_Error>>) => _et.Command_Promise<_et.Dictionary<Entry_Error>>;
26
+ }
16
27
  const sequence: <Error>(steps: _et.Command_Promise<Error>[]) => _et.Command_Promise<Error>;
17
28
  }
@@ -29,213 +29,232 @@ 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: $ });
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.transformer = (precondition, error_transformer, procedure) => {
100
+ return (0, create_command_promise_1.__create_command_promise)({
101
+ 'execute': (on_success, on_error) => {
102
+ precondition.process(($) => {
103
+ procedure($).__start(on_success, on_error);
104
+ }, (e) => {
105
+ on_error(error_transformer(e));
155
106
  });
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
- }));
107
+ }
108
+ });
109
+ };
110
+ })(conditional = p.conditional || (p.conditional = {}));
111
+ let execute;
112
+ (function (execute) {
113
+ execute.direct = (procedure, parameters) => {
114
+ return procedure['execute with synchronous data without error transformation'](parameters);
115
+ };
116
+ execute.query = (procedure, query) => {
117
+ return (0, create_command_promise_1.__create_command_promise)({
118
+ 'execute': (on_success, on_error) => {
119
+ query.__start((query_result) => {
120
+ procedure['execute with synchronous data without error transformation'](query_result).__start(on_success, on_error);
121
+ }, on_error);
122
+ }
123
+ });
124
+ };
125
+ })(execute = p.execute || (p.execute = {}));
126
+ let list;
127
+ (function (list) {
128
+ list.parallel = (the_array, aggregate_errors) => {
129
+ return (0, create_command_promise_1.__create_command_promise)({
130
+ 'execute': (on_success, on_error) => {
131
+ const errors = [];
132
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
133
+ the_array.map(($) => {
134
+ monitor['report process started']();
135
+ $.__start(() => {
136
+ monitor['report process finished']();
137
+ }, (e) => {
138
+ errors.push(e);
139
+ monitor['report process finished']();
140
+ });
171
141
  });
172
142
  }, () => {
173
- on_success();
143
+ if (errors.length === 0) {
144
+ on_success();
145
+ }
146
+ else {
147
+ on_error(aggregate_errors(_ei.array_literal(errors)));
148
+ }
174
149
  });
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']();
150
+ }
151
+ });
152
+ };
153
+ list.serie = (array) => {
154
+ return (0, create_command_promise_1.__create_command_promise)({
155
+ 'execute': (on_success, on_error) => {
156
+ let current = 0;
157
+ const do_next = () => {
158
+ array.__get_element_at(current).transform(($) => {
159
+ current += 1;
160
+ $.__start(() => {
161
+ do_next();
162
+ }, on_error);
163
+ }, () => {
164
+ on_success();
165
+ });
166
+ };
167
+ do_next();
168
+ }
169
+ });
170
+ };
171
+ })(list = p.list || (p.list = {}));
172
+ let dictionary;
173
+ (function (dictionary_1) {
174
+ dictionary_1.parallel = (dictionary, aggregate_errors) => {
175
+ return (0, create_command_promise_1.__create_command_promise)({
176
+ 'execute': (on_success, on_error) => {
177
+ const errors = {};
178
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
179
+ dictionary.map(($, key) => {
180
+ monitor['report process started']();
181
+ $.__start(() => {
182
+ monitor['report process finished']();
183
+ }, (e) => {
184
+ errors[key] = e;
185
+ monitor['report process finished']();
186
+ });
192
187
  });
188
+ }, () => {
189
+ if (Object.keys(errors).length === 0) {
190
+ on_success();
191
+ }
192
+ else {
193
+ on_error(aggregate_errors(_ei.dictionary_literal(errors)));
194
+ }
193
195
  });
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']();
196
+ }
197
+ });
198
+ };
199
+ dictionary_1.serie = (dictionary, transform_error) => {
200
+ return (0, create_command_promise_1.__create_command_promise)({
201
+ 'execute': (on_success, on_error) => {
202
+ const op_dictionary_to_list_based_on_insertion_order = (dict) => {
203
+ const temp = [];
204
+ dict.map(($, key) => {
205
+ temp.push({ key, value: $ });
206
+ });
207
+ return _ei.array_literal(temp);
208
+ };
209
+ const as_list = op_dictionary_to_list_based_on_insertion_order(dictionary);
210
+ let current = 0;
211
+ const do_next = () => {
212
+ as_list.__get_element_at(current).transform(($) => {
213
+ const key = $.key;
214
+ current += 1;
215
+ $.value.__start(() => {
216
+ do_next();
217
+ }, ($) => {
218
+ on_error(transform_error({
219
+ 'value': $,
220
+ 'key': key,
221
+ }));
222
+ });
223
+ }, () => {
224
+ on_success();
225
+ });
226
+ };
227
+ do_next();
228
+ }
229
+ });
230
+ };
231
+ dictionary_1.parallel_without_transforming_the_error = (dictionary) => {
232
+ return (0, create_command_promise_1.__create_command_promise)({
233
+ 'execute': (on_success, on_error) => {
234
+ const errors = {};
235
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
236
+ dictionary.map(($, key) => {
237
+ monitor['report process started']();
238
+ $.__start(() => {
239
+ monitor['report process finished']();
240
+ }, (e) => {
241
+ errors[key] = e;
242
+ monitor['report process finished']();
243
+ });
217
244
  });
245
+ }, () => {
246
+ if (Object.keys(errors).length === 0) {
247
+ on_success();
248
+ }
249
+ else {
250
+ on_error(_ei.dictionary_literal(errors));
251
+ }
218
252
  });
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
- };
253
+ }
254
+ });
255
+ };
256
+ })(dictionary = p.dictionary || (p.dictionary = {}));
257
+ // Sequencing function:
239
258
  p.sequence = (steps) => {
240
259
  return (0, create_command_promise_1.__create_command_promise)({
241
260
  'execute': (on_success, on_error) => {
@@ -4,5 +4,4 @@ export declare namespace q {
4
4
  const dictionary_parallel_without_error_aggregation: <Result, Error>($: _et.Dictionary<_et.Query_Promise<Result, Error>>) => _et.Query_Promise<_et.Dictionary<Result>, _et.Dictionary<Error>>;
5
5
  const fixed: <Result, Error>(result: Result) => _et.Query_Promise<Result, Error>;
6
6
  const raise_error: <T, E>($: E) => _et.Query_Promise<T, E>;
7
- const transform: <In, Out, Error>(query: _et.Query_Promise<In, Error>, transform: ($: In) => Out) => _et.Query_Promise<Out, Error>;
8
7
  }
@@ -104,16 +104,4 @@ var q;
104
104
  }
105
105
  });
106
106
  };
107
- q.transform = (//probably better to use the method on the query itself
108
- query, transform) => {
109
- return (0, create_query_promise_1.__create_query_promise)({
110
- 'execute': (on_success, on_error) => {
111
- query.__start(($) => {
112
- on_success(transform($));
113
- }, (e) => {
114
- on_error(e);
115
- });
116
- }
117
- });
118
- };
119
107
  })(q || (exports.q = q = {}));
@@ -1,2 +1,2 @@
1
1
  import * as _et from 'exupery-core-types';
2
- export declare const __create_query: <Parameters, Result, Error, Resources>(handler: ($: Parameters) => _et.Query_Promise<Result, Error>) => _et.Query<Parameters, Result, Error>;
2
+ export declare const __create_query: <Parameters, Result, Error, Resources>(handler: _et.Query<Parameters, Result, Error>) => _et.Query<Parameters, Result, Error>;
@@ -1,16 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.__create_query = void 0;
4
- const create_query_promise_1 = require("./create_query_promise");
5
4
  const __create_query = (handler) => {
6
- return {
7
- 'execute': (parameters) => {
8
- return (0, create_query_promise_1.__create_query_promise)({
9
- 'execute': (on_success, on_error) => {
10
- handler(parameters).__start(on_success, on_error);
11
- }
12
- });
13
- }
14
- };
5
+ return handler;
15
6
  };
16
7
  exports.__create_query = __create_query;
@@ -9,7 +9,7 @@ class Query_Result_Promise_Class {
9
9
  return new Query_Result_Promise_Class({
10
10
  'execute': (on_result, on_error) => {
11
11
  this.executer.execute(($) => {
12
- query.execute($).__start(on_result, on_error);
12
+ query($).__start(on_result, on_error);
13
13
  }, on_error);
14
14
  }
15
15
  });
@@ -18,7 +18,7 @@ class Query_Result_Promise_Class {
18
18
  return new Query_Result_Promise_Class({
19
19
  'execute': (on_result, on_error) => {
20
20
  this.executer.execute(on_result, ($) => {
21
- query.__start(($) => {
21
+ query($).__start(($) => {
22
22
  on_error($);
23
23
  }, ($) => {
24
24
  on_error(transform_rework_error($));
@@ -31,9 +31,9 @@ class Query_Result_Promise_Class {
31
31
  return new Query_Result_Promise_Class({
32
32
  'execute': (on_result, on_error) => {
33
33
  this.executer.execute(($) => {
34
- queries.result.execute($).__start(on_result, on_error);
34
+ queries.result($).__start(on_result, on_error);
35
35
  }, ($) => {
36
- queries.error.execute($).__start(on_result, on_error);
36
+ queries.error($).__start(on_result, on_error);
37
37
  });
38
38
  }
39
39
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.3.37",
3
+ "version": "0.3.39",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",