@aeriajs/common 0.0.59 → 0.0.61

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.
@@ -0,0 +1,8 @@
1
+ import type { EndpointError } from '@aeriajs/types';
2
+ import { Result } from './result.js';
3
+ export declare const endpointError: <const TEndpointError extends EndpointError>(value: TEndpointError) => {
4
+ readonly _tag: "Error";
5
+ readonly error: TEndpointError;
6
+ readonly result: undefined;
7
+ };
8
+ export declare const isEndpointError: (object: EndpointError | any) => object is Result.Error<EndpointError<any>>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEndpointError = exports.endpointError = void 0;
4
+ const types_1 = require("@aeriajs/types");
5
+ const result_js_1 = require("./result.js");
6
+ const endpointError = (value) => {
7
+ return result_js_1.Result.error(Object.assign({
8
+ [types_1.ERROR_SYMBOL]: true,
9
+ }, value));
10
+ };
11
+ exports.endpointError = endpointError;
12
+ const isEndpointError = (object) => {
13
+ return object
14
+ && object.error
15
+ && (types_1.ERROR_SYMBOL in object.error || types_1.ERROR_SYMBOL_DESCRIPTION in object.error);
16
+ };
17
+ exports.isEndpointError = isEndpointError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ import { ERROR_SYMBOL, ERROR_SYMBOL_DESCRIPTION } from "@aeriajs/types";
3
+ import { Result } from "./result.mjs";
4
+ export const endpointError = (value) => {
5
+ return Result.error(Object.assign({
6
+ [ERROR_SYMBOL]: true
7
+ }, value));
8
+ };
9
+ export const isEndpointError = (object) => {
10
+ return object && object.error && (ERROR_SYMBOL in object.error || ERROR_SYMBOL_DESCRIPTION in object.error);
11
+ };
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ export * from './date.js';
5
5
  export * from './deepClone.js';
6
6
  export * from './deepMerge.js';
7
7
  export * from './dynamicImport.js';
8
- export * from './either.js';
9
- export * from './error.js';
8
+ export * from './result.js';
9
+ export * from './endpointError.js';
10
10
  export * from './evaluateCondition.js';
11
11
  export * from './formatValue.js';
12
12
  export * from './freshItem.js';
@@ -14,6 +14,7 @@ export * from './getMissingProperties.js';
14
14
  export * from './getReferenceProperty.js';
15
15
  export * from './getValueFromPath.js';
16
16
  export * from './http.js';
17
+ export * from './isEmptyObject.js';
17
18
  export * from './isGranted.js';
18
19
  export * from './isObjectId.js';
19
20
  export * from './isReference.js';
package/dist/index.js CHANGED
@@ -21,8 +21,8 @@ __exportStar(require("./date.js"), exports);
21
21
  __exportStar(require("./deepClone.js"), exports);
22
22
  __exportStar(require("./deepMerge.js"), exports);
23
23
  __exportStar(require("./dynamicImport.js"), exports);
24
- __exportStar(require("./either.js"), exports);
25
- __exportStar(require("./error.js"), exports);
24
+ __exportStar(require("./result.js"), exports);
25
+ __exportStar(require("./endpointError.js"), exports);
26
26
  __exportStar(require("./evaluateCondition.js"), exports);
27
27
  __exportStar(require("./formatValue.js"), exports);
28
28
  __exportStar(require("./freshItem.js"), exports);
@@ -30,6 +30,7 @@ __exportStar(require("./getMissingProperties.js"), exports);
30
30
  __exportStar(require("./getReferenceProperty.js"), exports);
31
31
  __exportStar(require("./getValueFromPath.js"), exports);
32
32
  __exportStar(require("./http.js"), exports);
33
+ __exportStar(require("./isEmptyObject.js"), exports);
33
34
  __exportStar(require("./isGranted.js"), exports);
34
35
  __exportStar(require("./isObjectId.js"), exports);
35
36
  __exportStar(require("./isReference.js"), exports);
package/dist/index.mjs CHANGED
@@ -6,8 +6,8 @@ export * from "./date.mjs";
6
6
  export * from "./deepClone.mjs";
7
7
  export * from "./deepMerge.mjs";
8
8
  export * from "./dynamicImport.mjs";
9
- export * from "./either.mjs";
10
- export * from "./error.mjs";
9
+ export * from "./result.mjs";
10
+ export * from "./endpointError.mjs";
11
11
  export * from "./evaluateCondition.mjs";
12
12
  export * from "./formatValue.mjs";
13
13
  export * from "./freshItem.mjs";
@@ -15,6 +15,7 @@ export * from "./getMissingProperties.mjs";
15
15
  export * from "./getReferenceProperty.mjs";
16
16
  export * from "./getValueFromPath.mjs";
17
17
  export * from "./http.mjs";
18
+ export * from "./isEmptyObject.mjs";
18
19
  export * from "./isGranted.mjs";
19
20
  export * from "./isObjectId.mjs";
20
21
  export * from "./isReference.mjs";
@@ -0,0 +1 @@
1
+ export declare const isEmptyObject: (object: any) => any;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmptyObject = void 0;
4
+ const isEmptyObject = (object) => {
5
+ return object && Object.keys(object).length === 0 && object.constructor === Object;
6
+ };
7
+ exports.isEmptyObject = isEmptyObject;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ export const isEmptyObject = (object) => {
3
+ return object && Object.keys(object).length === 0 && object.constructor === Object;
4
+ };
@@ -0,0 +1,17 @@
1
+ import type { Result as R } from '@aeriajs/types/result';
2
+ export declare namespace Result {
3
+ type Error<T> = R.Error<T>;
4
+ type Result<T> = R.Result<T>;
5
+ type Either<Error, Result> = R.Either<Error, Result>;
6
+ const error: <const TValue>(value: TValue) => {
7
+ readonly _tag: "Error";
8
+ readonly error: TValue;
9
+ readonly result: undefined;
10
+ };
11
+ const result: <const TValue>(value: TValue) => {
12
+ readonly _tag: "Result";
13
+ readonly error: undefined;
14
+ readonly result: TValue;
15
+ };
16
+ }
17
+ export declare const throwIfError: <TValue>(either: R.Either<unknown, TValue>, message?: any) => NonNullable<TValue>;
package/dist/result.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwIfError = exports.Result = void 0;
4
+ var Result;
5
+ (function (Result) {
6
+ Result.error = (value) => ({
7
+ _tag: 'Error',
8
+ error: value,
9
+ result: undefined,
10
+ });
11
+ Result.result = (value) => ({
12
+ _tag: 'Result',
13
+ error: undefined,
14
+ result: value,
15
+ });
16
+ })(Result || (exports.Result = Result = {}));
17
+ const throwIfError = (either, message) => {
18
+ if (!either.result) {
19
+ if (process.env.NODE_ENV !== 'production') {
20
+ console.trace(JSON.stringify(either.error, null, 2));
21
+ }
22
+ throw new Error(`throwIfError threw: ${either.error} ${message
23
+ ? `(${message})`
24
+ : ''}`);
25
+ }
26
+ return either.result;
27
+ };
28
+ exports.throwIfError = throwIfError;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ export var Result;
3
+ ((Result2) => {
4
+ Result2.error = (value) => ({
5
+ _tag: "Error",
6
+ error: value,
7
+ result: void 0
8
+ });
9
+ Result2.result = (value) => ({
10
+ _tag: "Result",
11
+ error: void 0,
12
+ result: value
13
+ });
14
+ })(Result || (Result = {}));
15
+ export const throwIfError = (either, message) => {
16
+ if (!either.result) {
17
+ if (true) {
18
+ console.trace(JSON.stringify(either.error, null, 2));
19
+ }
20
+ throw new Error(`throwIfError threw: ${either.error} ${message ? `(${message})` : ""}`);
21
+ }
22
+ return either.result;
23
+ };
package/dist/schema.d.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  import type { Property, ObjectToSchema, HTTPStatus } from '@aeriajs/types';
2
2
  export declare const fromLiteral: <const TObject, TRequired extends (keyof TObject & string)[]>(object: TObject, required?: TRequired) => ObjectToSchema<TObject, TRequired>;
3
- export declare const leftSchema: <const TObject extends Property>(object: TObject) => {
3
+ export declare const errorSchema: <const TObject extends Property>(object: TObject) => {
4
4
  readonly type: "object";
5
5
  readonly properties: {
6
6
  readonly _tag: {
7
- readonly const: "Left";
7
+ readonly const: "Error";
8
8
  };
9
- readonly value: Property;
9
+ readonly error: Property;
10
10
  };
11
11
  };
12
- export declare const rightSchema: <const TObject extends Property>(object: TObject) => {
12
+ export declare const resultSchema: <const TObject extends Property>(object: TObject) => {
13
13
  readonly type: "object";
14
14
  readonly properties: {
15
15
  readonly _tag: {
16
- readonly const: "Right";
16
+ readonly const: "Result";
17
17
  };
18
- readonly value: Property;
18
+ readonly result: Property;
19
19
  };
20
20
  };
21
- export declare const errorSchema: <const THTTPStatus extends HTTPStatus[], const TCode extends string[]>(error: {
21
+ export declare const endpointErrorSchema: <const THTTPStatus extends HTTPStatus[], const TCode extends string[]>(error: {
22
22
  httpStatus: THTTPStatus;
23
23
  code: TCode;
24
24
  }) => {
@@ -27,51 +27,15 @@ export declare const errorSchema: <const THTTPStatus extends HTTPStatus[], const
27
27
  readonly _tag: {
28
28
  readonly const: "Error";
29
29
  };
30
- readonly value: {
31
- readonly type: "object";
32
- readonly required: readonly ["httpStatus", "code"];
33
- readonly properties: {
34
- readonly httpStatus: {
35
- readonly enum: THTTPStatus;
36
- };
37
- readonly code: {
38
- readonly enum: TCode;
39
- };
40
- readonly message: {
41
- readonly type: "string";
42
- };
43
- readonly details: {
44
- readonly type: "object";
45
- readonly variable: true;
46
- };
47
- };
48
- };
30
+ readonly error: Property;
49
31
  };
50
32
  };
51
- export declare const genericErrorSchema: () => {
33
+ export declare const genericEndpointErrorSchema: () => {
52
34
  readonly type: "object";
53
35
  readonly properties: {
54
36
  readonly _tag: {
55
37
  readonly const: "Error";
56
38
  };
57
- readonly value: {
58
- readonly type: "object";
59
- readonly required: readonly ["httpStatus", "code"];
60
- readonly properties: {
61
- readonly httpStatus: {
62
- readonly type: "number";
63
- };
64
- readonly code: {
65
- readonly type: "string";
66
- };
67
- readonly message: {
68
- readonly type: "string";
69
- };
70
- readonly details: {
71
- readonly type: "object";
72
- readonly variable: true;
73
- };
74
- };
75
- };
39
+ readonly error: Property;
76
40
  };
77
41
  };
package/dist/schema.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genericErrorSchema = exports.errorSchema = exports.rightSchema = exports.leftSchema = exports.fromLiteral = void 0;
3
+ exports.genericEndpointErrorSchema = exports.endpointErrorSchema = exports.resultSchema = exports.errorSchema = exports.fromLiteral = void 0;
4
4
  const mapValueToProperty = (value) => {
5
5
  if (value.constructor === Object) {
6
6
  return Object.assign({
@@ -48,93 +48,77 @@ const fromLiteral = (object, required) => {
48
48
  };
49
49
  };
50
50
  exports.fromLiteral = fromLiteral;
51
- const leftSchema = (object) => {
51
+ const errorSchema = (object) => {
52
52
  return {
53
53
  type: 'object',
54
54
  properties: {
55
55
  _tag: {
56
- const: 'Left',
56
+ const: 'Error',
57
57
  },
58
- value: object,
58
+ error: object,
59
59
  },
60
60
  };
61
61
  };
62
- exports.leftSchema = leftSchema;
63
- const rightSchema = (object) => {
62
+ exports.errorSchema = errorSchema;
63
+ const resultSchema = (object) => {
64
64
  return {
65
65
  type: 'object',
66
66
  properties: {
67
67
  _tag: {
68
- const: 'Right',
68
+ const: 'Result',
69
69
  },
70
- value: object,
70
+ result: object,
71
71
  },
72
72
  };
73
73
  };
74
- exports.rightSchema = rightSchema;
75
- const errorSchema = (error) => {
76
- return {
74
+ exports.resultSchema = resultSchema;
75
+ const endpointErrorSchema = (error) => {
76
+ return (0, exports.errorSchema)({
77
77
  type: 'object',
78
+ required: [
79
+ 'httpStatus',
80
+ 'code',
81
+ ],
78
82
  properties: {
79
- _tag: {
80
- const: 'Error',
83
+ httpStatus: {
84
+ enum: error.httpStatus,
85
+ },
86
+ code: {
87
+ enum: error.code,
81
88
  },
82
- value: {
89
+ message: {
90
+ type: 'string',
91
+ },
92
+ details: {
83
93
  type: 'object',
84
- required: [
85
- 'httpStatus',
86
- 'code',
87
- ],
88
- properties: {
89
- httpStatus: {
90
- enum: error.httpStatus,
91
- },
92
- code: {
93
- enum: error.code,
94
- },
95
- message: {
96
- type: 'string',
97
- },
98
- details: {
99
- type: 'object',
100
- variable: true,
101
- },
102
- },
94
+ variable: true,
103
95
  },
104
96
  },
105
- };
97
+ });
106
98
  };
107
- exports.errorSchema = errorSchema;
108
- const genericErrorSchema = () => {
109
- return {
99
+ exports.endpointErrorSchema = endpointErrorSchema;
100
+ const genericEndpointErrorSchema = () => {
101
+ return (0, exports.errorSchema)({
110
102
  type: 'object',
103
+ required: [
104
+ 'httpStatus',
105
+ 'code',
106
+ ],
111
107
  properties: {
112
- _tag: {
113
- const: 'Error',
108
+ httpStatus: {
109
+ type: 'number',
114
110
  },
115
- value: {
111
+ code: {
112
+ type: 'string',
113
+ },
114
+ message: {
115
+ type: 'string',
116
+ },
117
+ details: {
116
118
  type: 'object',
117
- required: [
118
- 'httpStatus',
119
- 'code',
120
- ],
121
- properties: {
122
- httpStatus: {
123
- type: 'number',
124
- },
125
- code: {
126
- type: 'string',
127
- },
128
- message: {
129
- type: 'string',
130
- },
131
- details: {
132
- type: 'object',
133
- variable: true,
134
- },
135
- },
119
+ variable: true,
136
120
  },
137
121
  },
138
- };
122
+ });
139
123
  };
140
- exports.genericErrorSchema = genericErrorSchema;
124
+ exports.genericEndpointErrorSchema = genericEndpointErrorSchema;
package/dist/schema.mjs CHANGED
@@ -45,89 +45,73 @@ export const fromLiteral = (object, required) => {
45
45
  properties
46
46
  };
47
47
  };
48
- export const leftSchema = (object) => {
48
+ export const errorSchema = (object) => {
49
49
  return {
50
50
  type: "object",
51
51
  properties: {
52
52
  _tag: {
53
- const: "Left"
53
+ const: "Error"
54
54
  },
55
- value: object
55
+ error: object
56
56
  }
57
57
  };
58
58
  };
59
- export const rightSchema = (object) => {
59
+ export const resultSchema = (object) => {
60
60
  return {
61
61
  type: "object",
62
62
  properties: {
63
63
  _tag: {
64
- const: "Right"
64
+ const: "Result"
65
65
  },
66
- value: object
66
+ result: object
67
67
  }
68
68
  };
69
69
  };
70
- export const errorSchema = (error) => {
71
- return {
70
+ export const endpointErrorSchema = (error) => {
71
+ return errorSchema({
72
72
  type: "object",
73
+ required: [
74
+ "httpStatus",
75
+ "code"
76
+ ],
73
77
  properties: {
74
- _tag: {
75
- const: "Error"
78
+ httpStatus: {
79
+ enum: error.httpStatus
76
80
  },
77
- value: {
81
+ code: {
82
+ enum: error.code
83
+ },
84
+ message: {
85
+ type: "string"
86
+ },
87
+ details: {
78
88
  type: "object",
79
- required: [
80
- "httpStatus",
81
- "code"
82
- ],
83
- properties: {
84
- httpStatus: {
85
- enum: error.httpStatus
86
- },
87
- code: {
88
- enum: error.code
89
- },
90
- message: {
91
- type: "string"
92
- },
93
- details: {
94
- type: "object",
95
- variable: true
96
- }
97
- }
89
+ variable: true
98
90
  }
99
91
  }
100
- };
92
+ });
101
93
  };
102
- export const genericErrorSchema = () => {
103
- return {
94
+ export const genericEndpointErrorSchema = () => {
95
+ return errorSchema({
104
96
  type: "object",
97
+ required: [
98
+ "httpStatus",
99
+ "code"
100
+ ],
105
101
  properties: {
106
- _tag: {
107
- const: "Error"
102
+ httpStatus: {
103
+ type: "number"
108
104
  },
109
- value: {
105
+ code: {
106
+ type: "string"
107
+ },
108
+ message: {
109
+ type: "string"
110
+ },
111
+ details: {
110
112
  type: "object",
111
- required: [
112
- "httpStatus",
113
- "code"
114
- ],
115
- properties: {
116
- httpStatus: {
117
- type: "number"
118
- },
119
- code: {
120
- type: "string"
121
- },
122
- message: {
123
- type: "string"
124
- },
125
- details: {
126
- type: "object",
127
- variable: true
128
- }
129
- }
113
+ variable: true
130
114
  }
131
115
  }
132
- };
116
+ });
133
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/common",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  "bson": "^6.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@aeriajs/types": "^0.0.55",
34
+ "@aeriajs/types": "^0.0.57",
35
35
  "bson": "^6.5.0"
36
36
  },
37
37
  "scripts": {
package/dist/either.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { Either, Left, Right } from '@aeriajs/types';
2
- export declare const left: <const TValue>(value: TValue) => Left<TValue>;
3
- export declare const right: <const TValue>(value: TValue) => Right<TValue>;
4
- export declare const isLeft: <TValue>(either: Either<TValue, any>) => either is Left<TValue>;
5
- export declare const isRight: <TValue>(either: Either<any, TValue>) => either is Right<TValue>;
6
- export declare const unwrapEither: <L, R>(either: Either<L, R>) => L | R;
7
- export declare const throwIfLeft: <L, R>(either: Either<L, R>, message?: any) => R;
package/dist/either.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwIfLeft = exports.unwrapEither = exports.isRight = exports.isLeft = exports.right = exports.left = void 0;
4
- const left = (value) => ({
5
- _tag: 'Left',
6
- value,
7
- });
8
- exports.left = left;
9
- const right = (value) => ({
10
- _tag: 'Right',
11
- value,
12
- });
13
- exports.right = right;
14
- const isLeft = (either) => {
15
- return either._tag === 'Left';
16
- };
17
- exports.isLeft = isLeft;
18
- const isRight = (either) => {
19
- return either._tag === 'Right';
20
- };
21
- exports.isRight = isRight;
22
- const unwrapEither = (either) => {
23
- return either.value;
24
- };
25
- exports.unwrapEither = unwrapEither;
26
- const throwIfLeft = (either, message) => {
27
- if (either._tag !== 'Right') {
28
- if (process.env.NODE_ENV !== 'production') {
29
- console.trace(JSON.stringify(either.value, null, 2));
30
- }
31
- throw new Error(`throwIfLeft threw: ${either.value} (${message || '-'})`);
32
- }
33
- return either.value;
34
- };
35
- exports.throwIfLeft = throwIfLeft;
package/dist/either.mjs DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- export const left = (value) => ({
3
- _tag: "Left",
4
- value
5
- });
6
- export const right = (value) => ({
7
- _tag: "Right",
8
- value
9
- });
10
- export const isLeft = (either) => {
11
- return either._tag === "Left";
12
- };
13
- export const isRight = (either) => {
14
- return either._tag === "Right";
15
- };
16
- export const unwrapEither = (either) => {
17
- return either.value;
18
- };
19
- export const throwIfLeft = (either, message) => {
20
- if (either._tag !== "Right") {
21
- if (true) {
22
- console.trace(JSON.stringify(either.value, null, 2));
23
- }
24
- throw new Error(`throwIfLeft threw: ${either.value} (${message || "-"})`);
25
- }
26
- return either.value;
27
- };
package/dist/error.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { EndpointError, EndpointErrorContent } from '@aeriajs/types';
2
- export declare const error: <const TEndpointErrorContent extends EndpointErrorContent>(value: TEndpointErrorContent) => EndpointError & {
3
- value: TEndpointErrorContent;
4
- };
5
- export declare const isError: (object: EndpointError | any) => object is EndpointError<any>;
6
- export declare const unwrapError: <TEndpointErrorContent extends EndpointErrorContent>(error: EndpointError<TEndpointErrorContent>) => TEndpointErrorContent;
7
- export declare const throwIfError: <TValue>(value: TValue, message?: any) => Exclude<TValue, EndpointError<any>>;
package/dist/error.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwIfError = exports.unwrapError = exports.isError = exports.error = void 0;
4
- const types_1 = require("@aeriajs/types");
5
- const error = (value) => {
6
- const wrappedError = {
7
- [types_1.ERROR_SYMBOL]: true,
8
- _tag: 'Error',
9
- value,
10
- };
11
- return wrappedError;
12
- };
13
- exports.error = error;
14
- const isError = (object) => {
15
- return object
16
- && typeof object === 'object'
17
- && (types_1.ERROR_SYMBOL in object || types_1.ERROR_SYMBOL_DESCRIPTION in object);
18
- };
19
- exports.isError = isError;
20
- const unwrapError = (error) => {
21
- return error.value;
22
- };
23
- exports.unwrapError = unwrapError;
24
- const throwIfError = (value, message) => {
25
- if ((0, exports.isError)(value)) {
26
- const error = (0, exports.unwrapError)(value);
27
- if (process.env.NODE_ENV !== 'production') {
28
- console.trace(JSON.stringify(error, null, 2));
29
- }
30
- throw new Error(`throwIfLeft threw: ${error.code} (${message || '-'})`);
31
- }
32
- return value;
33
- };
34
- exports.throwIfError = throwIfError;
package/dist/error.mjs DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- import { ERROR_SYMBOL, ERROR_SYMBOL_DESCRIPTION } from "@aeriajs/types";
3
- export const error = (value) => {
4
- const wrappedError = {
5
- [ERROR_SYMBOL]: true,
6
- _tag: "Error",
7
- value
8
- };
9
- return wrappedError;
10
- };
11
- export const isError = (object) => {
12
- return object && typeof object === "object" && (ERROR_SYMBOL in object || ERROR_SYMBOL_DESCRIPTION in object);
13
- };
14
- export const unwrapError = (error2) => {
15
- return error2.value;
16
- };
17
- export const throwIfError = (value, message) => {
18
- if (isError(value)) {
19
- const error2 = unwrapError(value);
20
- if (true) {
21
- console.trace(JSON.stringify(error2, null, 2));
22
- }
23
- throw new Error(`throwIfLeft threw: ${error2.code} (${message || "-"})`);
24
- }
25
- return value;
26
- };