exupery-core-async 0.3.19 → 0.3.20

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.
@@ -7,10 +7,10 @@ const __create_procedure_primed_with_resources = (handler) => {
7
7
  'execute with synchronous data': handler,
8
8
  'execute with asynchronous data': (query) => {
9
9
  return (0, create_procedure_promise_1.__create_procedure_promise)({
10
- 'execute': (on_success, on_exception) => {
10
+ 'execute': (on_success, on_error) => {
11
11
  query.__start(($) => {
12
- handler($).__start(on_success, on_exception);
13
- }, on_exception);
12
+ handler($).__start(on_success, on_error);
13
+ }, on_error);
14
14
  }
15
15
  });
16
16
  }
@@ -1,12 +1,12 @@
1
1
  import * as _et from "exupery-core-types";
2
2
  /**
3
3
  * this function contains the body in which the async value or exception is executed
4
- * after the execution, either the on_value or on_exception callback will be called
4
+ * after the execution, either the on_value or on_error callback will be called
5
5
  * @param on_value the callback to call when a value is produced
6
- * @param on_exception the callback to call when an error is produced
6
+ * @param on_error the callback to call when an error is produced
7
7
  */
8
8
  type Executer<E> = {
9
- 'execute': (on_success: () => void, on_exception: ($: E) => void) => void;
9
+ 'execute': (on_success: () => void, on_error: ($: E) => void) => void;
10
10
  };
11
11
  /**
12
12
  * returns an {@link Async_Value }
@@ -5,14 +5,14 @@ class Procedure_Promise_Class {
5
5
  constructor(executer) {
6
6
  this.executer = executer;
7
7
  }
8
- __start(on_success, on_exception) {
9
- this.executer.execute(on_success, on_exception);
8
+ __start(on_success, on_error) {
9
+ this.executer.execute(on_success, on_error);
10
10
  }
11
11
  map_error(handle_error) {
12
12
  return new Procedure_Promise_Class({
13
- 'execute': (on_success, on_exception) => {
13
+ 'execute': (on_success, on_error) => {
14
14
  this.executer.execute(on_success, (error) => {
15
- on_exception(handle_error(error));
15
+ on_error(handle_error(error));
16
16
  });
17
17
  }
18
18
  });
@@ -1,12 +1,12 @@
1
1
  import * as _et from "exupery-core-types";
2
2
  /**
3
3
  * this function contains the body in which the async value or exception is executed
4
- * after the execution, either the on_value or on_exception callback will be called
4
+ * after the execution, either the on_value or on_error callback will be called
5
5
  * @param on_value the callback to call when a value is produced
6
- * @param on_exception the callback to call when an error is produced
6
+ * @param on_error the callback to call when an error is produced
7
7
  */
8
8
  type Executer<T, E> = {
9
- 'execute': (on_value: ($: T) => void, on_exception: ($: E) => void) => void;
9
+ 'execute': (on_value: ($: T) => void, on_error: ($: E) => void) => void;
10
10
  };
11
11
  /**
12
12
  * returns an {@link Async_Value }
@@ -5,35 +5,35 @@ class Query_Result_Promise_Class {
5
5
  constructor(executer) {
6
6
  this.executer = executer;
7
7
  }
8
- map_(handle_value) {
8
+ then(handle_value) {
9
9
  return new Query_Result_Promise_Class({
10
- 'execute': (on_value, on_exception) => {
10
+ 'execute': (on_value, on_error) => {
11
11
  this.executer.execute(($) => {
12
- on_value(handle_value($));
13
- }, on_exception);
12
+ handle_value($).__start(on_value, on_error);
13
+ }, on_error);
14
14
  }
15
15
  });
16
16
  }
17
- then(handle_value) {
17
+ map_exception(handle_exception) {
18
18
  return new Query_Result_Promise_Class({
19
- 'execute': (new_on_value, new_on_exception) => {
20
- this.executer.execute(($) => {
21
- handle_value($).__start(new_on_value, new_on_exception);
22
- }, new_on_exception);
19
+ 'execute': (on_value, on_error) => {
20
+ this.executer.execute(on_value, ($) => {
21
+ on_error(handle_exception($));
22
+ });
23
23
  }
24
24
  });
25
25
  }
26
- map_exception_(handle_exception) {
26
+ process(processor) {
27
27
  return new Query_Result_Promise_Class({
28
- 'execute': (on_value, on_exception) => {
29
- this.executer.execute(on_value, ($) => {
30
- on_exception(handle_exception($));
31
- });
28
+ 'execute': (on_value, on_error) => {
29
+ this.executer.execute(($) => {
30
+ processor($).__extract_data(on_value, on_error);
31
+ }, on_error);
32
32
  }
33
33
  });
34
34
  }
35
- __start(on_value, on_exception) {
36
- this.executer.execute(on_value, on_exception);
35
+ __start(on_value, on_error) {
36
+ this.executer.execute(on_value, on_error);
37
37
  }
38
38
  }
39
39
  /**
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ export * from "./algorithms/query/create_query_promise";
4
4
  export * from "./algorithms/procedure/create_procedure";
5
5
  export * from "./algorithms/procedure/create_procedure_promise";
6
6
  export * from "./algorithms/procedure/create_procedure_primed_with_resources";
7
- export * from "./process_result";
8
7
  export * from "./shorthands";
9
8
  export * from "./procedure/assert_async";
10
9
  export * from "./procedure/assert_sync";
package/dist/index.js CHANGED
@@ -22,7 +22,6 @@ __exportStar(require("./algorithms/query/create_query_promise"), exports);
22
22
  __exportStar(require("./algorithms/procedure/create_procedure"), exports);
23
23
  __exportStar(require("./algorithms/procedure/create_procedure_promise"), exports);
24
24
  __exportStar(require("./algorithms/procedure/create_procedure_primed_with_resources"), exports);
25
- __exportStar(require("./process_result"), exports);
26
25
  __exportStar(require("./shorthands"), exports);
27
26
  // procedure exports
28
27
  __exportStar(require("./procedure/assert_async"), exports);
@@ -50,8 +49,8 @@ exports.query = {
50
49
  },
51
50
  'raise exception': ($) => {
52
51
  return (0, create_query_promise_1.__create_query_promise)({
53
- 'execute': (on_value, on_exception) => {
54
- on_exception($);
52
+ 'execute': (on_value, on_error) => {
53
+ on_error($);
55
54
  }
56
55
  });
57
56
  }
@@ -4,18 +4,18 @@ exports.assert_async = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const assert_async = (assertion, procedure) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  assertion.__start(($) => {
9
9
  if ($) {
10
10
  procedure.__start(on_success, ($) => {
11
- on_exception(['procedure error', $]);
11
+ on_error(['procedure error', $]);
12
12
  });
13
13
  }
14
14
  else {
15
- on_exception(['assertion failed', null]);
15
+ on_error(['assertion failed', null]);
16
16
  }
17
17
  }, ($) => {
18
- on_exception(['assertion error', $]);
18
+ on_error(['assertion error', $]);
19
19
  });
20
20
  }
21
21
  });
@@ -4,13 +4,13 @@ exports.assert_sync = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const assert_sync = (assertion, procedure) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  if (!assertion) {
9
- on_exception(['assertion failed', null]);
9
+ on_error(['assertion failed', null]);
10
10
  return;
11
11
  }
12
12
  procedure.__start(on_success, ($) => {
13
- on_exception(['procedure error', $]);
13
+ on_error(['procedure error', $]);
14
14
  });
15
15
  }
16
16
  });
@@ -4,18 +4,18 @@ exports.conditional_async = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const conditional_async = (precondition, procedure) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  precondition.__start(($) => {
9
9
  if ($) {
10
10
  procedure.__start(on_success, (e) => {
11
- on_exception(['procedure', e]);
11
+ on_error(['procedure', e]);
12
12
  });
13
13
  }
14
14
  else {
15
15
  on_success();
16
16
  }
17
17
  }, ($) => {
18
- on_exception(['precondition', $]);
18
+ on_error(['precondition', $]);
19
19
  });
20
20
  }
21
21
  });
@@ -5,7 +5,7 @@ const query_dictionary_1 = require("../query/query_dictionary");
5
5
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
6
6
  const conditional_multiple = (preconditions, procedure) => {
7
7
  return (0, create_procedure_promise_1.__create_procedure_promise)({
8
- 'execute': (on_success, on_exception) => {
8
+ 'execute': (on_success, on_error) => {
9
9
  (0, query_dictionary_1.query_dictionary)(preconditions).__start(($) => {
10
10
  let has_errors = false;
11
11
  $.map(($) => {
@@ -16,7 +16,7 @@ const conditional_multiple = (preconditions, procedure) => {
16
16
  if (!has_errors) {
17
17
  // all preconditions passed
18
18
  procedure.__start(on_success, (e) => {
19
- on_exception(['procedure', e]);
19
+ on_error(['procedure', e]);
20
20
  });
21
21
  }
22
22
  else {
@@ -24,7 +24,7 @@ const conditional_multiple = (preconditions, procedure) => {
24
24
  on_success();
25
25
  }
26
26
  }, ($) => {
27
- on_exception(['preconditions', $]);
27
+ on_error(['preconditions', $]);
28
28
  });
29
29
  }
30
30
  });
@@ -4,9 +4,9 @@ exports.conditional_sync = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const conditional_sync = (precondition, procedure) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  if (precondition) {
9
- procedure.__start(on_success, on_exception);
9
+ procedure.__start(on_success, on_error);
10
10
  }
11
11
  else {
12
12
  on_success();
@@ -35,7 +35,7 @@ const op_dictionary_to_list_based_on_insertion_order = (dict) => {
35
35
  };
36
36
  const dictionary_sequence = (steps) => {
37
37
  return (0, create_procedure_promise_1.__create_procedure_promise)({
38
- 'execute': (on_success, on_exception) => {
38
+ 'execute': (on_success, on_error) => {
39
39
  const as_list = op_dictionary_to_list_based_on_insertion_order(steps);
40
40
  let current = 0;
41
41
  const do_next = () => {
@@ -45,7 +45,7 @@ const dictionary_sequence = (steps) => {
45
45
  $.value.__start(() => {
46
46
  do_next();
47
47
  }, ($) => {
48
- on_exception({
48
+ on_error({
49
49
  'error': $,
50
50
  'step': key,
51
51
  });
@@ -4,10 +4,10 @@ exports.execute_with_async_data = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const execute_with_async_data = (procedure, query) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  query.__start((query_result) => {
9
- procedure["execute with synchronous data"](query_result).__start(on_success, on_exception);
10
- }, on_exception);
9
+ procedure["execute with synchronous data"](query_result).__start(on_success, on_error);
10
+ }, on_error);
11
11
  }
12
12
  });
13
13
  };
@@ -28,7 +28,7 @@ const _ei = __importStar(require("exupery-core-internals"));
28
28
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
29
29
  const procedure_dictionary = ($) => {
30
30
  return (0, create_procedure_promise_1.__create_procedure_promise)({
31
- 'execute': (on_success, on_exception) => {
31
+ 'execute': (on_success, on_error) => {
32
32
  let count_down = $.__get_number_of_entries();
33
33
  let has_errors = false;
34
34
  const errors = {};
@@ -36,7 +36,7 @@ const procedure_dictionary = ($) => {
36
36
  count_down -= 1;
37
37
  if (count_down === 0) {
38
38
  if (has_errors) {
39
- on_exception(_ei.dictionary_literal(errors));
39
+ on_error(_ei.dictionary_literal(errors));
40
40
  }
41
41
  else {
42
42
  on_success();
@@ -4,14 +4,14 @@ exports.sequence = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const sequence = (steps) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  let current = 0;
9
9
  const do_next = () => {
10
10
  steps.__get_element_at(current).transform(($) => {
11
11
  current += 1;
12
12
  $.__start(() => {
13
13
  do_next();
14
- }, on_exception);
14
+ }, on_error);
15
15
  }, () => {
16
16
  on_success();
17
17
  });
@@ -4,17 +4,17 @@ exports.three_steps = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const three_steps = (step_1, step_2, step_3) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  step_1.__start(() => {
9
9
  step_2.__start(() => {
10
10
  step_3.__start(on_success, (error) => {
11
- on_exception(['step3', error]);
11
+ on_error(['step3', error]);
12
12
  });
13
13
  }, (error) => {
14
- on_exception(['step2', error]);
14
+ on_error(['step2', error]);
15
15
  });
16
16
  }, (error) => {
17
- on_exception(['step1', error]);
17
+ on_error(['step1', error]);
18
18
  });
19
19
  }
20
20
  });
@@ -4,13 +4,13 @@ exports.two_steps = void 0;
4
4
  const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
5
5
  const two_steps = (step_1, step_2) => {
6
6
  return (0, create_procedure_promise_1.__create_procedure_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  step_1.__start(() => {
9
9
  step_2.__start(on_success, (error) => {
10
- on_exception(['step2', error]);
10
+ on_error(['step2', error]);
11
11
  });
12
12
  }, (error) => {
13
- on_exception(['step1', error]);
13
+ on_error(['step1', error]);
14
14
  });
15
15
  }
16
16
  });
@@ -28,7 +28,7 @@ const _ei = __importStar(require("exupery-core-internals"));
28
28
  const create_query_promise_1 = require("../algorithms/query/create_query_promise");
29
29
  const query_dictionary = ($) => {
30
30
  return (0, create_query_promise_1.__create_query_promise)({
31
- 'execute': (on_success, on_exception) => {
31
+ 'execute': (on_success, on_error) => {
32
32
  let count_down = $.__get_number_of_entries();
33
33
  let has_errors = false;
34
34
  const errors = {};
@@ -37,7 +37,7 @@ const query_dictionary = ($) => {
37
37
  count_down -= 1;
38
38
  if (count_down === 0) {
39
39
  if (has_errors) {
40
- on_exception(_ei.dictionary_literal(errors));
40
+ on_error(_ei.dictionary_literal(errors));
41
41
  }
42
42
  else {
43
43
  on_success(_ei.dictionary_literal(results));
@@ -4,11 +4,11 @@ exports.transform_query = void 0;
4
4
  const create_query_promise_1 = require("../algorithms/query/create_query_promise");
5
5
  const transform_query = (query, transform) => {
6
6
  return (0, create_query_promise_1.__create_query_promise)({
7
- 'execute': (on_success, on_exception) => {
7
+ 'execute': (on_success, on_error) => {
8
8
  query.__start(($) => {
9
9
  on_success(transform($));
10
10
  }, (e) => {
11
- on_exception(e);
11
+ on_error(e);
12
12
  });
13
13
  }
14
14
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",
@@ -1,3 +0,0 @@
1
- import * as _et from 'exupery-core-types';
2
- export declare const create_process_result: <Data, Error>($: Data) => _et.Process_Result<Data, Error>;
3
- export declare const create_failed_process_result: <Data, Error>($: Error) => _et.Process_Result<Data, Error>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create_failed_process_result = exports.create_process_result = void 0;
4
- const create_process_result = ($) => {
5
- return {
6
- 'transform': (transformer) => {
7
- return (0, exports.create_process_result)(transformer($));
8
- },
9
- 'transform with parameters': (transformer, parameters) => {
10
- return (0, exports.create_process_result)(transformer($, parameters));
11
- },
12
- 'refine': (refiner, map_error) => {
13
- return refiner($).transform(($) => (0, exports.create_process_result)($), ($) => (0, exports.create_failed_process_result)(map_error($)));
14
- },
15
- 'refine with parameters': (refiner, parameters, map_error) => {
16
- return refiner($, parameters).transform(($) => (0, exports.create_process_result)($), ($) => (0, exports.create_failed_process_result)(map_error($)));
17
- },
18
- '__extract_data': (success, exception) => {
19
- success($);
20
- }
21
- };
22
- };
23
- exports.create_process_result = create_process_result;
24
- const create_failed_process_result = ($) => {
25
- return {
26
- 'transform': () => {
27
- return (0, exports.create_failed_process_result)($);
28
- },
29
- 'transform with parameters': () => {
30
- return (0, exports.create_failed_process_result)($);
31
- },
32
- 'refine': () => {
33
- return (0, exports.create_failed_process_result)($);
34
- },
35
- 'refine with parameters': () => {
36
- return (0, exports.create_failed_process_result)($);
37
- },
38
- '__extract_data': (success, exception) => {
39
- exception($);
40
- }
41
- };
42
- };
43
- exports.create_failed_process_result = create_failed_process_result;