@driveflux/result 4.1.1 → 4.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -34
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,17 +1,15 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
1
  export class Err {
2
+ val;
3
+ metadata;
4
+ static EMPTY = new Err(undefined);
5
+ ok;
6
+ err;
7
+ constructor(val, metadata){
8
+ this.val = val;
9
+ this.metadata = metadata;
10
+ this.ok = false;
11
+ this.err = true;
12
+ }
15
13
  /**
16
14
  * If the result has a value returns that value. Otherwise returns the passed in value.
17
15
  * @param val the value to replace the error with
@@ -30,19 +28,19 @@ export class Err {
30
28
  mapErr(mapper) {
31
29
  return new Err(mapper(this.val));
32
30
  }
31
+ }
32
+ export class Ok {
33
+ val;
34
+ metadata;
35
+ static EMPTY = new Ok(undefined);
36
+ ok;
37
+ err;
33
38
  constructor(val, metadata){
34
- _define_property(this, "val", void 0);
35
- _define_property(this, "metadata", void 0);
36
- _define_property(this, "ok", void 0);
37
- _define_property(this, "err", void 0);
38
39
  this.val = val;
39
40
  this.metadata = metadata;
40
- this.ok = false;
41
- this.err = true;
41
+ this.ok = true;
42
+ this.err = false;
42
43
  }
43
- }
44
- _define_property(Err, "EMPTY", new Err(undefined));
45
- export class Ok {
46
44
  /**
47
45
  * If the result has a value returns that value. Otherwise returns the passed in value.
48
46
  * @param val the value to replace the error with
@@ -61,18 +59,7 @@ export class Ok {
61
59
  mapErr(_mapper) {
62
60
  return this;
63
61
  }
64
- constructor(val, metadata){
65
- _define_property(this, "val", void 0);
66
- _define_property(this, "metadata", void 0);
67
- _define_property(this, "ok", void 0);
68
- _define_property(this, "err", void 0);
69
- this.val = val;
70
- this.metadata = metadata;
71
- this.ok = true;
72
- this.err = false;
73
- }
74
62
  }
75
- _define_property(Ok, "EMPTY", new Ok(undefined));
76
63
  export function Results(...results) {
77
64
  const okResult = [];
78
65
  for (const result of results){
@@ -91,9 +78,9 @@ export const isErrorWithResult = (response)=>{
91
78
  return response.result && isResult(response.result);
92
79
  };
93
80
  export class ErrorWithResult extends Error {
81
+ result;
94
82
  constructor(result){
95
83
  super('');
96
- _define_property(this, "result", void 0);
97
84
  this.result = result;
98
85
  }
99
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/result",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -16,7 +16,7 @@
16
16
  "@driveflux/problem": "4.1.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@driveflux/fab": "2.1.1",
19
+ "@driveflux/fab": "2.1.2",
20
20
  "@driveflux/tsconfig": "1.1.2",
21
21
  "@swc/cli": "^0.4.0",
22
22
  "@swc/core": "1.7.0",