exupery-core-async 0.1.20 → 0.1.22

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,4 +1,4 @@
1
1
  export interface Safe_Command_Result {
2
- then(handle: () => Safe_Command_Result): Safe_Command_Result;
2
+ then(handle: (init: Safe_Command_Result) => Safe_Command_Result): Safe_Command_Result;
3
3
  __start(on_finished: () => void): void;
4
4
  }
@@ -11,8 +11,8 @@ export interface Safe_Query_Result<T> {
11
11
  * @param handle_value callback that transforms the actual value into a new Async_Value
12
12
  */
13
13
  then<NT>(handle_value: ($: T) => Safe_Query_Result<NT>): Safe_Query_Result<NT>;
14
- process_safe(handle_value: ($: T) => Safe_Command_Result): Safe_Command_Result;
15
- process_unsafe<E>(handle_value: ($: T) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
14
+ process_safe(handle_value: ($: T, init: Safe_Command_Result) => Safe_Command_Result): Safe_Command_Result;
15
+ process_unsafe<E>(handle_value: ($: T, init: Unsafe_Command_Result<E>) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
16
16
  /**
17
17
  * This method is only to be used by resources
18
18
  */
@@ -13,11 +13,11 @@ export interface Unsafe_Command_Result<E> {
13
13
  * note that this is different from `catch`,
14
14
  * which would switch to the safe context
15
15
  */
16
- process_exception<NE>(handle: ($: E) => Safe_Command_Result, map: ($: E) => NE): Unsafe_Command_Result<NE>;
16
+ process_exception<NE>(handle: ($: E, init: Safe_Command_Result) => Safe_Command_Result, map: ($: E) => NE): Unsafe_Command_Result<NE>;
17
17
  throw_exception<E>($: E): Unsafe_Command_Result<E>;
18
- catch(handle_exception: ($: E) => Safe_Command_Result): Safe_Command_Result;
19
- then(handle: () => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
20
- then_safe(handle: () => Safe_Command_Result): Unsafe_Command_Result<E>;
18
+ catch(handle_exception: ($: E, init: Safe_Command_Result) => Safe_Command_Result): Safe_Command_Result;
19
+ then(handle: (init: Unsafe_Command_Result<E>) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
20
+ then_safe(handle: (init: Safe_Command_Result) => Safe_Command_Result): Unsafe_Command_Result<E>;
21
21
  then_dictionary<E2>($: _et.Dictionary<Unsafe_Command_Result<E2>>, aggregate_exceptions: ($: _et.Dictionary<E2>) => E): Unsafe_Command_Result<E>;
22
22
  then_multiple<E2>($: _et.Array<Unsafe_Command_Result<E2>>, aggregate_exceptions: ($: _et.Array<E2>) => E): Unsafe_Command_Result<E>;
23
23
  __start(on_success: () => void, on_exception: ($: E) => void): void;
@@ -19,6 +19,6 @@ export interface Unsafe_Query_Result<T, E> {
19
19
  * @param map_exception the handler that will map the exception of the query into a new exception value of the command's exception type
20
20
  *
21
21
  */
22
- process<NE>(handle_exception: ($: E) => Safe_Command_Result, map_exception: ($: E) => NE, handle_value: ($: T) => Unsafe_Command_Result<NE>): Unsafe_Command_Result<NE>;
22
+ process<NE>(handle_exception: ($: E, init: Safe_Command_Result) => Safe_Command_Result, map_exception: ($: E) => NE, handle_value: ($: T, init: Unsafe_Command_Result<NE>) => Unsafe_Command_Result<NE>): Unsafe_Command_Result<NE>;
23
23
  __start(on_value: ($: T) => void, on_exception: ($: E) => void): void;
24
24
  }
@@ -8,4 +8,5 @@ type Executer = {
8
8
  * @returns
9
9
  */
10
10
  export declare function __execute_safe_command(executer: Executer): Safe_Command_Result;
11
+ export declare const initialize_safe_command: () => Safe_Command_Result;
11
12
  export {};
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialize_safe_command = void 0;
3
4
  exports.__execute_safe_command = __execute_safe_command;
4
5
  class Safe_Command_Result_Class {
5
6
  constructor(executer) {
@@ -9,7 +10,7 @@ class Safe_Command_Result_Class {
9
10
  return __execute_safe_command({
10
11
  'execute': (on_finished) => {
11
12
  this.executer.execute(() => {
12
- handle().__start(on_finished);
13
+ handle((0, exports.initialize_safe_command)()).__start(on_finished);
13
14
  });
14
15
  }
15
16
  });
@@ -26,3 +27,11 @@ class Safe_Command_Result_Class {
26
27
  function __execute_safe_command(executer) {
27
28
  return new Safe_Command_Result_Class(executer);
28
29
  }
30
+ const initialize_safe_command = () => {
31
+ return __execute_safe_command({
32
+ 'execute': (on_success) => {
33
+ on_success();
34
+ }
35
+ });
36
+ };
37
+ exports.initialize_safe_command = initialize_safe_command;
@@ -14,4 +14,5 @@ type Executer<E> = {
14
14
  * @returns
15
15
  */
16
16
  export declare function __execute_unsafe_command<E>(executer: Executer<E>): Unsafe_Command_Result<E>;
17
+ export declare const initialize_unsafe_command: <E>() => Unsafe_Command_Result<E>;
17
18
  export {};
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.initialize_unsafe_command = void 0;
26
27
  exports.__execute_unsafe_command = __execute_unsafe_command;
27
28
  const _ei = __importStar(require("exupery-core-internals"));
28
29
  const execute_safe_command_1 = require("./execute_safe_command");
@@ -35,7 +36,7 @@ class Unsafe_Command_Result_Class {
35
36
  return new Unsafe_Command_Result_Class({
36
37
  'execute': (new_on_success, new_on_exception) => {
37
38
  this.executer.execute(new_on_success, ($) => {
38
- handle($).__start(() => new_on_exception(map($)));
39
+ handle($, (0, execute_safe_command_1.initialize_safe_command)()).__start(() => new_on_exception(map($)));
39
40
  });
40
41
  }
41
42
  });
@@ -44,7 +45,7 @@ class Unsafe_Command_Result_Class {
44
45
  return (0, execute_safe_command_1.__execute_safe_command)({
45
46
  'execute': (new_on_success) => {
46
47
  this.executer.execute(new_on_success, ($) => {
47
- handle_exception($).__start(new_on_success);
48
+ handle_exception($, (0, execute_safe_command_1.initialize_safe_command)()).__start(new_on_success);
48
49
  });
49
50
  }
50
51
  });
@@ -62,7 +63,7 @@ class Unsafe_Command_Result_Class {
62
63
  return new Unsafe_Command_Result_Class({
63
64
  'execute': (new_on_success, new_on_exception) => {
64
65
  this.executer.execute(() => {
65
- handle().__start(new_on_success, new_on_exception);
66
+ handle((0, exports.initialize_unsafe_command)()).__start(new_on_success, new_on_exception);
66
67
  }, new_on_exception);
67
68
  }
68
69
  });
@@ -71,7 +72,7 @@ class Unsafe_Command_Result_Class {
71
72
  return new Unsafe_Command_Result_Class({
72
73
  'execute': (new_on_success, new_on_exception) => {
73
74
  this.executer.execute(() => {
74
- handle().__start(new_on_success);
75
+ handle((0, execute_safe_command_1.initialize_safe_command)()).__start(new_on_success);
75
76
  }, new_on_exception);
76
77
  }
77
78
  });
@@ -138,3 +139,11 @@ class Unsafe_Command_Result_Class {
138
139
  function __execute_unsafe_command(executer) {
139
140
  return new Unsafe_Command_Result_Class(executer);
140
141
  }
142
+ const initialize_unsafe_command = () => {
143
+ return __execute_unsafe_command({
144
+ 'execute': (on_success) => {
145
+ on_success();
146
+ }
147
+ });
148
+ };
149
+ exports.initialize_unsafe_command = initialize_unsafe_command;
package/dist/index.js CHANGED
@@ -57,22 +57,10 @@ exports.query = {
57
57
  };
58
58
  exports.command = {
59
59
  'safe': {
60
- 'initialize': () => {
61
- return (0, execute_safe_command_1.__execute_safe_command)({
62
- 'execute': (on_success) => {
63
- on_success();
64
- }
65
- });
66
- }
60
+ 'initialize': execute_safe_command_1.initialize_safe_command
67
61
  },
68
62
  'unsafe': {
69
- 'initialize': () => {
70
- return (0, execute_unsafe_command_1.__execute_unsafe_command)({
71
- 'execute': (on_success) => {
72
- on_success();
73
- }
74
- });
75
- },
63
+ 'initialize': execute_unsafe_command_1.initialize_unsafe_command,
76
64
  'raise exception': ($) => {
77
65
  return (0, execute_unsafe_command_1.__execute_unsafe_command)({
78
66
  'execute': (on_success, on_exception) => {
@@ -29,7 +29,7 @@ class Safe_Query_Result_Class {
29
29
  return (0, execute_safe_command_1.__execute_safe_command)({
30
30
  'execute': (on_success) => {
31
31
  this.executer.execute((value) => {
32
- handle_value(value).__start(on_success);
32
+ handle_value(value, (0, execute_safe_command_1.initialize_safe_command)()).__start(on_success);
33
33
  });
34
34
  }
35
35
  });
@@ -38,7 +38,7 @@ class Safe_Query_Result_Class {
38
38
  return (0, execute_unsafe_command_1.__execute_unsafe_command)({
39
39
  'execute': (on_success, on_exception) => {
40
40
  this.executer.execute((value) => {
41
- handle_value(value).__start(on_success, on_exception);
41
+ handle_value(value, (0, execute_unsafe_command_1.initialize_unsafe_command)()).__start(on_success, on_exception);
42
42
  });
43
43
  }
44
44
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.__run_unsafe_query = __run_unsafe_query;
4
4
  const run_safe_query_1 = require("./run_safe_query");
5
+ const execute_safe_command_1 = require("./execute_safe_command");
5
6
  const execute_unsafe_command_1 = require("./execute_unsafe_command");
6
7
  class Unsafe_Query_Result_Class {
7
8
  constructor(executer) {
@@ -47,9 +48,9 @@ class Unsafe_Query_Result_Class {
47
48
  return (0, execute_unsafe_command_1.__execute_unsafe_command)({
48
49
  'execute': (on_success, on_exception) => {
49
50
  this.executer.execute((value) => {
50
- handle_value(value).__start(on_success, on_exception);
51
+ handle_value(value, (0, execute_unsafe_command_1.initialize_unsafe_command)()).__start(on_success, on_exception);
51
52
  }, (exception) => {
52
- handle_exception(exception).__start(() => on_exception(map_exception(exception)));
53
+ handle_exception(exception, (0, execute_safe_command_1.initialize_safe_command)()).__start(() => on_exception(map_exception(exception)));
53
54
  });
54
55
  }
55
56
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",