exupery-core-internals 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,7 +1,6 @@
1
1
  import * as _et from "exupery-core-types";
2
2
  /**
3
3
  * returns a Exupery array
4
- * why is this not the constructor? to call a constructor, you have to use the keyword 'new'. Exupery doesn't use the concept of a class so that keyword should be avoided
5
4
 
6
5
  * @param source An array literal
7
6
  * @returns
@@ -38,15 +38,14 @@ class Array_Class {
38
38
  }
39
39
  /**
40
40
  * returns a Exupery array
41
- * why is this not the constructor? to call a constructor, you have to use the keyword 'new'. Exupery doesn't use the concept of a class so that keyword should be avoided
42
41
 
43
42
  * @param source An array literal
44
43
  * @returns
45
44
  */
46
45
  function array_literal(source) {
47
- const data = source.slice(); //create a copy
48
- if (!(data instanceof Array)) {
46
+ if (!(source instanceof Array)) {
49
47
  throw new Error("invalid input in 'array_literal'");
50
48
  }
51
- return new Array_Class(source);
49
+ const data = source.slice(); //create a copy
50
+ return new Array_Class(data);
52
51
  }
package/dist/index.d.ts CHANGED
@@ -8,4 +8,3 @@ export * from "./imp/public/switch_state";
8
8
  export * from "./imp/public/get_location_info";
9
9
  export * from "./imp/public/set";
10
10
  export * from "./imp/public/not_set";
11
- export * from "./imp/public/Error";
package/dist/index.js CHANGED
@@ -24,4 +24,3 @@ __exportStar(require("./imp/public/switch_state"), exports);
24
24
  __exportStar(require("./imp/public/get_location_info"), exports);
25
25
  __exportStar(require("./imp/public/set"), exports);
26
26
  __exportStar(require("./imp/public/not_set"), exports);
27
- __exportStar(require("./imp/public/Error"), exports);
@@ -0,0 +1,13 @@
1
+ export interface Unguaranteed_Transformation_Result<T, E> {
2
+ /**
3
+ * @param set what to do when the value was set, returns the new type
4
+ * @param not_set what to do when the value was not set, returns the new type
5
+ */
6
+ 'process result'(success: ($: T) => void, exception: ($: E) => void): void;
7
+ map<NT, NE>(handle_value: ($: T) => NT, handle_exception: ($: E) => NE): Unguaranteed_Transformation_Result<NT, NE>;
8
+ transform<NT>(handle_value: ($: T) => NT, handle_exception: ($: E) => NT): NT;
9
+ }
10
+ export declare namespace transformation {
11
+ const failed: <T, E>(exception: E) => Unguaranteed_Transformation_Result<T, E>;
12
+ const successful: <T, E>(value: T) => Unguaranteed_Transformation_Result<T, E>;
13
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformation = void 0;
4
+ var transformation;
5
+ (function (transformation) {
6
+ transformation.failed = (exception) => {
7
+ return {
8
+ 'process result': (success, exception_handler) => {
9
+ exception_handler(exception);
10
+ },
11
+ 'transform': (success, exception_handler) => {
12
+ return exception_handler(exception);
13
+ },
14
+ 'map': (handle_value, handle_exception) => {
15
+ return transformation.failed(handle_exception(exception));
16
+ }
17
+ };
18
+ };
19
+ transformation.successful = (value) => {
20
+ return {
21
+ 'process result': (success, exception_handler) => {
22
+ success(value);
23
+ },
24
+ 'transform': (success, exception_handler) => {
25
+ return success(value);
26
+ },
27
+ 'map': (handle_value, handle_exception) => {
28
+ return transformation.successful(handle_value(value));
29
+ }
30
+ };
31
+ };
32
+ })(transformation || (exports.transformation = transformation = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-internals",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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.5"
18
+ "exupery-core-types": "^0.1.6"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^18.15.3"
@@ -1,4 +0,0 @@
1
- export declare class Error<Type> {
2
- type: Type;
3
- constructor(type: Type);
4
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Error = void 0;
4
- class Error {
5
- constructor(type) {
6
- this.type = type;
7
- this.type = type;
8
- }
9
- }
10
- exports.Error = Error;