exupery-core-internals 0.1.2 → 0.1.3

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.
@@ -27,19 +27,21 @@ class Array_Class {
27
27
  // })
28
28
  function array(array, $v) {
29
29
  const mapped = array.map($v);
30
- return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)(($c) => {
31
- const temp = [];
32
- (0, create_async_registry_1.create_async_registry)((registry) => {
33
- mapped.forEach((v) => {
34
- registry.register();
35
- v.__execute((v) => {
36
- temp.push(v);
37
- registry.report_finished();
30
+ return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
31
+ 'execute': (on_value) => {
32
+ const temp = [];
33
+ (0, create_async_registry_1.create_async_registry)((registry) => {
34
+ mapped.forEach((v) => {
35
+ registry.register();
36
+ v.__start((v) => {
37
+ temp.push(v);
38
+ registry.report_finished();
39
+ });
38
40
  });
41
+ }, () => {
42
+ on_value(array_literal(temp));
39
43
  });
40
- }, () => {
41
- $c(array_literal(temp));
42
- });
44
+ }
43
45
  });
44
46
  }
45
47
  return array(this.data, $v);
@@ -1,8 +1,10 @@
1
1
  import * as pt from "exupery-core-types";
2
- import { Execute } from "../types/Execute";
2
+ export type Executer<T> = {
3
+ 'execute': (on_value: ($: T) => void) => void;
4
+ };
3
5
  /**
4
6
  * returns an {@link Async_Value }
5
- * @param execute the function that produces the eventual value
7
+ * @param executer the function that produces the eventual value
6
8
  * @returns
7
9
  */
8
- export declare function cast_to_async_value_imp<T>(execute: Execute<T>): pt.Async_Value<T>;
10
+ export declare function cast_to_async_value_imp<T>(executer: Executer<T>): pt.Async_Value<T>;
@@ -2,28 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cast_to_async_value_imp = cast_to_async_value_imp;
4
4
  class Async_Value_Class {
5
- constructor(execute) {
6
- this.execute = execute;
5
+ constructor(executer) {
6
+ this.executer = executer;
7
7
  }
8
- map($v) {
9
- function rewrite(source, rewrite) {
10
- return cast_to_async_value_imp(((cb) => {
11
- source((v) => {
12
- rewrite(v).__execute(cb);
8
+ map(handle_value) {
9
+ return cast_to_async_value_imp({
10
+ 'execute': (on_value) => {
11
+ this.executer.execute((value) => {
12
+ handle_value(value).__start(on_value);
13
13
  });
14
- }));
15
- }
16
- return rewrite(this.execute, $v);
14
+ }
15
+ });
17
16
  }
18
- __execute($i) {
19
- this.execute($i);
17
+ __start(on_value) {
18
+ this.executer.execute(on_value);
20
19
  }
21
20
  }
22
21
  /**
23
22
  * returns an {@link Async_Value }
24
- * @param execute the function that produces the eventual value
23
+ * @param executer the function that produces the eventual value
25
24
  * @returns
26
25
  */
27
- function cast_to_async_value_imp(execute) {
28
- return new Async_Value_Class(execute);
26
+ function cast_to_async_value_imp(executer) {
27
+ return new Async_Value_Class(executer);
29
28
  }
@@ -29,19 +29,21 @@ class Dictionary {
29
29
  value: $v($.value),
30
30
  };
31
31
  });
32
- return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)((cb) => {
33
- const temp = {};
34
- (0, create_async_registry_1.create_async_registry)((counter) => {
35
- mapped.map(($) => {
36
- counter.register();
37
- $.value.__execute((nv) => {
38
- temp[$.key] = nv;
39
- counter.report_finished();
32
+ return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
33
+ 'execute': (on_value) => {
34
+ const temp = {};
35
+ (0, create_async_registry_1.create_async_registry)((counter) => {
36
+ mapped.map(($) => {
37
+ counter.register();
38
+ $.value.__start((nv) => {
39
+ temp[$.key] = nv;
40
+ counter.report_finished();
41
+ });
40
42
  });
43
+ }, () => {
44
+ on_value(dictionary_literal(temp));
41
45
  });
42
- }, () => {
43
- cb(dictionary_literal(temp));
44
- });
46
+ }
45
47
  });
46
48
  }
47
49
  return imp(this.source, $v);
@@ -8,7 +8,9 @@ const cast_to_async_value_imp_1 = require("./cast_to_async_value_imp");
8
8
  * @returns
9
9
  */
10
10
  function make_async($) {
11
- return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)(($c) => {
12
- $c($);
11
+ return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
12
+ 'execute': (on_value) => {
13
+ on_value($);
14
+ }
13
15
  });
14
16
  }
@@ -3,25 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolve_async_tuple_2 = resolve_async_tuple_2;
4
4
  const cast_to_async_value_imp_1 = require("./cast_to_async_value_imp");
5
5
  function resolve_async_tuple_2(first, second) {
6
- return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)((cb) => {
7
- let element_1_is_set = false;
8
- let element_2_is_set = false;
9
- let elem1;
10
- let elem2;
11
- function wrap_up() {
12
- if (element_1_is_set && element_2_is_set) {
13
- cb({ first: elem1, second: elem2 });
6
+ return (0, cast_to_async_value_imp_1.cast_to_async_value_imp)({
7
+ 'execute': (on_value) => {
8
+ let element_1_is_set = false;
9
+ let element_2_is_set = false;
10
+ let elem1;
11
+ let elem2;
12
+ function wrap_up() {
13
+ if (element_1_is_set && element_2_is_set) {
14
+ on_value({ first: elem1, second: elem2 });
15
+ }
14
16
  }
17
+ first.__start((val) => {
18
+ elem1 = val;
19
+ element_1_is_set = true;
20
+ wrap_up();
21
+ });
22
+ second.__start((val) => {
23
+ elem2 = val;
24
+ element_2_is_set = true;
25
+ wrap_up();
26
+ });
15
27
  }
16
- first.__execute((val) => {
17
- elem1 = val;
18
- element_1_is_set = true;
19
- wrap_up();
20
- });
21
- second.__execute((val) => {
22
- elem2 = val;
23
- element_2_is_set = true;
24
- wrap_up();
25
- });
26
28
  });
27
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-internals",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "ISC",
5
5
  "description": "",
6
6
  "author": "Corno",
@@ -15,7 +15,7 @@
15
15
  "url": "https://github.com/corno/exupery-core/issues"
16
16
  },
17
17
  "dependencies": {
18
- "exupery-core-types": "^0.1.0"
18
+ "exupery-core-types": "^0.1.2"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^18.15.3"
@@ -1,5 +0,0 @@
1
- /**
2
- * function that (eventually) produces a value.
3
- * the value is provided in a callback ($c)
4
- */
5
- export type Execute<T> = ($c: ($: T) => void) => void;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });