exupery-core-async 0.1.7 → 0.1.9

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,3 +1,5 @@
1
+ import { Safe_Command_Result } from "./Safe_Command_Result";
2
+ import { Unsafe_Command_Result } from "./Unsafe_Command_Result";
1
3
  /**
2
4
  * A value that will asynchronously become available.
3
5
  * Similar to the concept of a promise, but with a smaller API.
@@ -9,6 +11,8 @@ export interface Safe_Query_Result<T> {
9
11
  * @param handle_value callback that transforms the actual value into a new Async_Value
10
12
  */
11
13
  then<NT>(handle_value: ($: T) => Safe_Query_Result<NT>): Safe_Query_Result<NT>;
14
+ execute_safe_command(handle_value: ($: T) => Safe_Command_Result): Safe_Command_Result;
15
+ execute_unsafe_command<E>(handle_value: ($: T) => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
12
16
  /**
13
17
  * This method is only to be used by resources
14
18
  */
@@ -1,6 +1,8 @@
1
+ import * as _et from 'exupery-core-types';
1
2
  export interface Unsafe_Command_Result<E> {
2
3
  map_exception<NE>(handle_exception: ($: E) => NE): Unsafe_Command_Result<NE>;
3
4
  if_exception_then<NE>(handle_exception: ($: E) => Unsafe_Command_Result<NE>): Unsafe_Command_Result<NE>;
4
5
  then(handle: () => Unsafe_Command_Result<E>): Unsafe_Command_Result<E>;
6
+ do_dictionary<E2>($: _et.Dictionary<Unsafe_Command_Result<E2>>, aggregate_exceptions: ($: _et.Dictionary<E2>) => E): Unsafe_Command_Result<E>;
5
7
  __start(on_success: () => void, on_exception: ($: E) => void): void;
6
8
  }
@@ -1,7 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.__execute_unsafe_command = __execute_unsafe_command;
27
+ const _ei = __importStar(require("exupery-core-internals"));
4
28
  const execute_safe_command_1 = require("./execute_safe_command");
29
+ const create_asynchronous_processes_monitor_1 = require("./create_asynchronous_processes_monitor");
5
30
  class Unsafe_Command_Result_Class {
6
31
  constructor(executer) {
7
32
  this.executer = executer;
@@ -33,6 +58,31 @@ class Unsafe_Command_Result_Class {
33
58
  }
34
59
  });
35
60
  }
61
+ do_dictionary($, aggregate_exceptions) {
62
+ let exceptions = {};
63
+ return __execute_unsafe_command({
64
+ 'execute': (on_success, on_exception) => {
65
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
66
+ $.map(($, key) => {
67
+ monitor['report process started']();
68
+ $.__start(() => {
69
+ monitor['report process finished']();
70
+ }, (e) => {
71
+ exceptions[key] = e;
72
+ monitor['report process finished']();
73
+ });
74
+ });
75
+ }, () => {
76
+ if (Object.keys(exceptions).length === 0) {
77
+ on_success();
78
+ }
79
+ else {
80
+ on_exception(aggregate_exceptions(_ei.dictionary_literal(exceptions)));
81
+ }
82
+ });
83
+ }
84
+ });
85
+ }
36
86
  catch(handle_exception) {
37
87
  return (0, execute_safe_command_1.__execute_safe_command)({
38
88
  'execute': (on_success) => {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as _et from "exupery-core-types";
2
1
  export * from "./Safe_Command_Result";
3
2
  export * from "./Unsafe_Command_Result";
4
3
  export * from "./Safe_Query_Result";
@@ -12,13 +11,13 @@ import { Safe_Command_Result } from "./Safe_Command_Result";
12
11
  import { Unsafe_Command_Result } from "./Unsafe_Command_Result";
13
12
  import { Safe_Query_Result } from "./Safe_Query_Result";
14
13
  import { Unsafe_Query_Result } from "./Unsafe_Query_Result";
15
- import { Dictionary } from "exupery-core-types";
16
14
  export declare const query: {
17
15
  safe: {
18
16
  'create result': <T>($: T) => Safe_Query_Result<T>;
19
17
  };
20
18
  unsafe: {
21
19
  'create result': <T, E>($: T) => Unsafe_Query_Result<T, E>;
20
+ 'create exception': <T, E>($: E) => Unsafe_Query_Result<T, E>;
22
21
  };
23
22
  };
24
23
  export declare const command: {
@@ -27,6 +26,6 @@ export declare const command: {
27
26
  };
28
27
  unsafe: {
29
28
  'create result': <E>() => Unsafe_Command_Result<E>;
30
- dictionary: <T, E>($: _et.Dictionary<T>, handle_entry: ($: T, key: string) => Unsafe_Command_Result<E>) => Unsafe_Command_Result<Dictionary<E>>;
29
+ 'create exception': <E>($: E) => Unsafe_Command_Result<E>;
31
30
  };
32
31
  };
package/dist/index.js CHANGED
@@ -10,24 +10,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
17
  exports.command = exports.query = void 0;
30
- const _ei = __importStar(require("exupery-core-internals"));
31
18
  __exportStar(require("./Safe_Command_Result"), exports);
32
19
  __exportStar(require("./Unsafe_Command_Result"), exports);
33
20
  __exportStar(require("./Safe_Query_Result"), exports);
@@ -41,7 +28,6 @@ const execute_safe_command_1 = require("./execute_safe_command");
41
28
  const execute_unsafe_command_1 = require("./execute_unsafe_command");
42
29
  const run_safe_query_1 = require("./run_safe_query");
43
30
  const run_unsafe_query_1 = require("./run_unsafe_query");
44
- const create_asynchronous_processes_monitor_1 = require("./create_asynchronous_processes_monitor");
45
31
  exports.query = {
46
32
  'safe': {
47
33
  'create result': ($) => {
@@ -59,6 +45,13 @@ exports.query = {
59
45
  on_value($);
60
46
  }
61
47
  });
48
+ },
49
+ 'create exception': ($) => {
50
+ return (0, run_unsafe_query_1.__run_unsafe_query)({
51
+ 'execute': (on_value, on_exception) => {
52
+ on_exception($);
53
+ }
54
+ });
62
55
  }
63
56
  },
64
57
  };
@@ -80,32 +73,13 @@ exports.command = {
80
73
  }
81
74
  });
82
75
  },
83
- 'dictionary': ($, handle_entry) => {
76
+ 'create exception': ($) => {
84
77
  return (0, execute_unsafe_command_1.__execute_unsafe_command)({
85
78
  'execute': (on_success, on_exception) => {
86
- let exceptions = {};
87
- (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
88
- $.map(($, key) => {
89
- monitor['report process started']();
90
- handle_entry($, key).__start(() => {
91
- monitor['report process finished']();
92
- }, (e) => {
93
- exceptions[key] = e;
94
- monitor['report process finished']();
95
- });
96
- });
97
- }, () => {
98
- if (Object.keys(exceptions).length === 0) {
99
- on_success();
100
- }
101
- else {
102
- on_exception(_ei.dictionary_literal(exceptions));
103
- }
104
- });
105
- on_success();
79
+ on_exception($);
106
80
  }
107
81
  });
108
- }
82
+ },
109
83
  },
110
84
  };
111
85
  // //array
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.__run_safe_query = __run_safe_query;
4
+ const execute_safe_command_1 = require("./execute_safe_command");
5
+ const execute_unsafe_command_1 = require("./execute_unsafe_command");
4
6
  class Safe_Query_Result_Class {
5
7
  constructor(executer) {
6
8
  this.executer = executer;
@@ -23,6 +25,24 @@ class Safe_Query_Result_Class {
23
25
  }
24
26
  });
25
27
  }
28
+ execute_safe_command(handle_value) {
29
+ return (0, execute_safe_command_1.__execute_safe_command)({
30
+ 'execute': (on_success) => {
31
+ this.executer.execute((value) => {
32
+ handle_value(value).__start(on_success);
33
+ });
34
+ }
35
+ });
36
+ }
37
+ execute_unsafe_command(handle_value) {
38
+ return (0, execute_unsafe_command_1.__execute_unsafe_command)({
39
+ 'execute': (on_success, on_exception) => {
40
+ this.executer.execute((value) => {
41
+ handle_value(value).__start(on_success, on_exception);
42
+ });
43
+ }
44
+ });
45
+ }
26
46
  __start(on_value) {
27
47
  this.executer.execute(on_value);
28
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",