@aeriajs/common 0.0.24 → 0.0.25
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.
- package/dist/arraysIntersects.mjs +6 -7
- package/dist/checkForUndefined.mjs +6 -5
- package/dist/convertConditionToQuery.mjs +53 -68
- package/dist/date.mjs +31 -96
- package/dist/deepClone.mjs +3 -2
- package/dist/deepMerge.mjs +30 -62
- package/dist/dynamicImport.mjs +12 -145
- package/dist/either.mjs +24 -27
- package/dist/evaluateCondition.mjs +56 -59
- package/dist/formatValue.mjs +46 -55
- package/dist/freshItem.mjs +32 -129
- package/dist/getMissingProperties.mjs +36 -44
- package/dist/getReferenceProperty.mjs +9 -10
- package/dist/getValueFromPath.mjs +6 -5
- package/dist/http.mjs +39 -220
- package/dist/index.mjs +1 -0
- package/dist/isReference.mjs +3 -2
- package/dist/isRequired.mjs +13 -12
- package/dist/pipe.mjs +21 -255
- package/dist/schema.mjs +61 -64
- package/dist/serialize.mjs +4 -36
- package/package.json +3 -3
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}) : arr.includes(subject);
|
|
1
|
+
"use strict";
|
|
2
|
+
export const arraysIntersects = (subject, arr) => {
|
|
3
|
+
if (!arr) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
return Array.isArray(subject) ? subject.some((e) => arr.includes(e)) : arr.includes(subject);
|
|
8
7
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
export const checkForUndefined = (property, propertyName, what) => {
|
|
3
|
+
if (property.readOnly || property.isTimestamp) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
return what[propertyName] === null || what[propertyName] === void 0 || what[propertyName] === "";
|
|
6
7
|
};
|
|
@@ -1,72 +1,57 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
"use strict";
|
|
14
2
|
import { getValueFromPath } from "./getValueFromPath.mjs";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} : term2;
|
|
48
|
-
}
|
|
3
|
+
const convertExpression = (condition, subject) => {
|
|
4
|
+
const term2 = "term2" in condition ? typeof condition.term2 === "string" && condition.term2.startsWith("$.") ? getValueFromPath(subject, condition.term2.split("$.")[1]) : condition.term2 : null;
|
|
5
|
+
switch (condition.operator) {
|
|
6
|
+
case "truthy":
|
|
7
|
+
return {
|
|
8
|
+
$ne: [
|
|
9
|
+
null,
|
|
10
|
+
void 0
|
|
11
|
+
]
|
|
12
|
+
};
|
|
13
|
+
case "equal":
|
|
14
|
+
return term2;
|
|
15
|
+
case "gt":
|
|
16
|
+
return {
|
|
17
|
+
$gt: term2
|
|
18
|
+
};
|
|
19
|
+
case "lt":
|
|
20
|
+
return {
|
|
21
|
+
$lt: term2
|
|
22
|
+
};
|
|
23
|
+
case "gte":
|
|
24
|
+
return {
|
|
25
|
+
$gte: term2
|
|
26
|
+
};
|
|
27
|
+
case "lte":
|
|
28
|
+
return {
|
|
29
|
+
$lte: term2
|
|
30
|
+
};
|
|
31
|
+
case "in": {
|
|
32
|
+
return Array.isArray(term2) ? {
|
|
33
|
+
$in: term2
|
|
34
|
+
} : term2;
|
|
49
35
|
}
|
|
36
|
+
}
|
|
50
37
|
};
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return _define_property({}, condition.term1, convertExpression(condition, subject));
|
|
38
|
+
export const convertConditionToQuery = (condition, subject) => {
|
|
39
|
+
if ("or" in condition) {
|
|
40
|
+
return {
|
|
41
|
+
$or: condition.or.map((sub) => convertConditionToQuery(sub, subject))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if ("and" in condition) {
|
|
45
|
+
return {
|
|
46
|
+
$and: condition.and.map((sub) => convertConditionToQuery(sub, subject))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if ("not" in condition) {
|
|
50
|
+
return {
|
|
51
|
+
$not: convertConditionToQuery(condition.not, subject)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
[condition.term1]: convertExpression(condition, subject)
|
|
56
|
+
};
|
|
72
57
|
};
|
package/dist/date.mjs
CHANGED
|
@@ -1,101 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
|
-
function _instanceof(left, right) {
|
|
10
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
11
|
-
return !!right[Symbol.hasInstance](left);
|
|
12
|
-
} else {
|
|
13
|
-
return left instanceof right;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function _iterable_to_array_limit(arr, i) {
|
|
17
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
18
|
-
if (_i == null) return;
|
|
19
|
-
var _arr = [];
|
|
20
|
-
var _n = true;
|
|
21
|
-
var _d = false;
|
|
22
|
-
var _s, _e;
|
|
23
|
-
try {
|
|
24
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
25
|
-
_arr.push(_s.value);
|
|
26
|
-
if (i && _arr.length === i) break;
|
|
27
|
-
}
|
|
28
|
-
} catch (err) {
|
|
29
|
-
_d = true;
|
|
30
|
-
_e = err;
|
|
31
|
-
} finally{
|
|
32
|
-
try {
|
|
33
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
34
|
-
} finally{
|
|
35
|
-
if (_d) throw _e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return _arr;
|
|
39
|
-
}
|
|
40
|
-
function _non_iterable_rest() {
|
|
41
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
42
|
-
}
|
|
43
|
-
function _sliced_to_array(arr, i) {
|
|
44
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
45
|
-
}
|
|
46
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
47
|
-
if (!o) return;
|
|
48
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
49
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
50
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
51
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
52
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
53
|
-
}
|
|
54
|
-
var rtf = new Intl.RelativeTimeFormat(undefined, {
|
|
55
|
-
numeric: "auto"
|
|
1
|
+
"use strict";
|
|
2
|
+
const rtf = new Intl.RelativeTimeFormat(void 0, {
|
|
3
|
+
numeric: "auto"
|
|
56
4
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
5
|
+
const units = {
|
|
6
|
+
year: 31536e6,
|
|
7
|
+
month: 2628e6,
|
|
8
|
+
day: 864e5,
|
|
9
|
+
hour: 36e5,
|
|
10
|
+
minute: 6e3,
|
|
11
|
+
second: 1e3
|
|
64
12
|
};
|
|
65
|
-
export
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
13
|
+
export const formatDateTime = function(date, options) {
|
|
14
|
+
const target = date instanceof Date ? date : new Date(date);
|
|
15
|
+
if (isNaN(target.getDate())) {
|
|
16
|
+
return "-";
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
hours,
|
|
20
|
+
hoursOnly,
|
|
21
|
+
locale = "navigator" in globalThis ? navigator.language : "en-US"
|
|
22
|
+
} = options || {};
|
|
23
|
+
if (hoursOnly) {
|
|
24
|
+
return target.toLocaleTimeString();
|
|
25
|
+
}
|
|
26
|
+
return hours ? target.toLocaleString(locale) : target.toLocaleDateString(locale);
|
|
75
27
|
};
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var _step_value = _sliced_to_array(_step.value, 2), u = _step_value[0], value = _step_value[1];
|
|
83
|
-
if (Math.abs(elapsed) > value || u === "second") {
|
|
84
|
-
return rtf.format(-1 * Math.round(elapsed / value), u);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
} catch (err) {
|
|
88
|
-
_didIteratorError = true;
|
|
89
|
-
_iteratorError = err;
|
|
90
|
-
} finally{
|
|
91
|
-
try {
|
|
92
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
93
|
-
_iterator.return();
|
|
94
|
-
}
|
|
95
|
-
} finally{
|
|
96
|
-
if (_didIteratorError) {
|
|
97
|
-
throw _iteratorError;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
28
|
+
export const getRelativeTimeFromNow = function(target) {
|
|
29
|
+
const now = /* @__PURE__ */ new Date();
|
|
30
|
+
const elapsed = now - target;
|
|
31
|
+
for (const [u, value] of Object.entries(units)) {
|
|
32
|
+
if (Math.abs(elapsed) > value || u === "second") {
|
|
33
|
+
return rtf.format(-1 * Math.round(elapsed / value), u);
|
|
100
34
|
}
|
|
35
|
+
}
|
|
101
36
|
};
|
package/dist/deepClone.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
export const deepClone = (obj) => {
|
|
3
|
+
return typeof structuredClone === "function" && typeof window === "undefined" ? structuredClone(obj) : JSON.parse(JSON.stringify(obj));
|
|
3
4
|
};
|
package/dist/deepMerge.mjs
CHANGED
|
@@ -1,66 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
export const deepMerge = (left, right, options) => {
|
|
3
|
+
const result = Object.assign({}, left);
|
|
4
|
+
const { arrays = true } = options || {};
|
|
5
|
+
for (const key in right) {
|
|
6
|
+
const leftVal = result[key];
|
|
7
|
+
const rightVal = right[key];
|
|
8
|
+
if (options?.callback) {
|
|
9
|
+
const res = options.callback(key, leftVal, rightVal);
|
|
10
|
+
if (res !== void 0) {
|
|
11
|
+
result[key] = res;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
26
|
-
if (!o) return;
|
|
27
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
28
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
30
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
31
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
32
|
-
}
|
|
33
|
-
export var deepMerge = function(left, right, options) {
|
|
34
|
-
var result = Object.assign({}, left);
|
|
35
|
-
var _ref = options || {}, _ref_arrays = _ref.arrays, arrays = _ref_arrays === void 0 ? true : _ref_arrays;
|
|
36
|
-
for(var key in right){
|
|
37
|
-
var leftVal = result[key];
|
|
38
|
-
var rightVal = right[key];
|
|
39
|
-
if (options === null || options === void 0 ? void 0 : options.callback) {
|
|
40
|
-
var res = options.callback(key, leftVal, rightVal);
|
|
41
|
-
if (res !== undefined) {
|
|
42
|
-
result[key] = res;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (Array.isArray(leftVal) && Array.isArray(rightVal)) {
|
|
47
|
-
var _result_key;
|
|
48
|
-
result[key] = arrays ? (_result_key = result[key]).concat.apply(_result_key, _to_consumable_array(rightVal)) : rightVal;
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (_instanceof(rightVal, Function)) {
|
|
52
|
-
result[key] = rightVal;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (_instanceof(leftVal, Object) && _instanceof(rightVal, Object)) {
|
|
56
|
-
if (rightVal.constructor !== Object) {
|
|
57
|
-
result[key] = rightVal;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
result[key] = deepMerge(leftVal, rightVal, options);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
15
|
+
if (Array.isArray(leftVal) && Array.isArray(rightVal)) {
|
|
16
|
+
result[key] = arrays ? result[key].concat(...rightVal) : rightVal;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (rightVal instanceof Function) {
|
|
20
|
+
result[key] = rightVal;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (leftVal instanceof Object && rightVal instanceof Object) {
|
|
24
|
+
if (rightVal.constructor !== Object) {
|
|
63
25
|
result[key] = rightVal;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
result[key] = deepMerge(leftVal, rightVal, options);
|
|
29
|
+
continue;
|
|
64
30
|
}
|
|
65
|
-
|
|
31
|
+
result[key] = rightVal;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
66
34
|
};
|
package/dist/dynamicImport.mjs
CHANGED
|
@@ -1,145 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _async_to_generator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(undefined);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t, g, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
};
|
|
40
|
-
return g = {
|
|
41
|
-
next: verb(0),
|
|
42
|
-
"throw": verb(1),
|
|
43
|
-
"return": verb(2)
|
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
-
return this;
|
|
46
|
-
}), g;
|
|
47
|
-
function verb(n) {
|
|
48
|
-
return function(v) {
|
|
49
|
-
return step([
|
|
50
|
-
n,
|
|
51
|
-
v
|
|
52
|
-
]);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function step(op) {
|
|
56
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while(_)try {
|
|
58
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
-
if (y = 0, t) op = [
|
|
60
|
-
op[0] & 2,
|
|
61
|
-
t.value
|
|
62
|
-
];
|
|
63
|
-
switch(op[0]){
|
|
64
|
-
case 0:
|
|
65
|
-
case 1:
|
|
66
|
-
t = op;
|
|
67
|
-
break;
|
|
68
|
-
case 4:
|
|
69
|
-
_.label++;
|
|
70
|
-
return {
|
|
71
|
-
value: op[1],
|
|
72
|
-
done: false
|
|
73
|
-
};
|
|
74
|
-
case 5:
|
|
75
|
-
_.label++;
|
|
76
|
-
y = op[1];
|
|
77
|
-
op = [
|
|
78
|
-
0
|
|
79
|
-
];
|
|
80
|
-
continue;
|
|
81
|
-
case 7:
|
|
82
|
-
op = _.ops.pop();
|
|
83
|
-
_.trys.pop();
|
|
84
|
-
continue;
|
|
85
|
-
default:
|
|
86
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
-
_ = 0;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
-
_.label = op[1];
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
-
_.label = t[1];
|
|
96
|
-
t = op;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
if (t && _.label < t[2]) {
|
|
100
|
-
_.label = t[2];
|
|
101
|
-
_.ops.push(op);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
if (t[2]) _.ops.pop();
|
|
105
|
-
_.trys.pop();
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
op = body.call(thisArg, _);
|
|
109
|
-
} catch (e) {
|
|
110
|
-
op = [
|
|
111
|
-
6,
|
|
112
|
-
e
|
|
113
|
-
];
|
|
114
|
-
y = 0;
|
|
115
|
-
} finally{
|
|
116
|
-
f = t = 0;
|
|
117
|
-
}
|
|
118
|
-
if (op[0] & 5) throw op[1];
|
|
119
|
-
return {
|
|
120
|
-
value: op[0] ? op[1] : void 0,
|
|
121
|
-
done: true
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
export var dynamicImport = function() {
|
|
126
|
-
var _ref = _async_to_generator(function(path) {
|
|
127
|
-
var fn;
|
|
128
|
-
return _ts_generator(this, function(_state) {
|
|
129
|
-
try {
|
|
130
|
-
return [
|
|
131
|
-
2,
|
|
132
|
-
require(path)
|
|
133
|
-
];
|
|
134
|
-
} catch (err) {}
|
|
135
|
-
fn = new Function("return (async () => {\n const { pathToFileURL } = await import('url')\n return import(pathToFileURL('".concat(path.replace(/\\/g, "\\\\"), "'))\n })()"));
|
|
136
|
-
return [
|
|
137
|
-
2,
|
|
138
|
-
fn()
|
|
139
|
-
];
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
return function dynamicImport(path) {
|
|
143
|
-
return _ref.apply(this, arguments);
|
|
144
|
-
};
|
|
145
|
-
}();
|
|
1
|
+
"use strict";
|
|
2
|
+
export const dynamicImport = async (path) => {
|
|
3
|
+
try {
|
|
4
|
+
return require(path);
|
|
5
|
+
} catch (err) {
|
|
6
|
+
}
|
|
7
|
+
const fn = new Function(`return (async () => {
|
|
8
|
+
const { pathToFileURL } = await import('url')
|
|
9
|
+
return import(pathToFileURL('${path.replace(/\\/g, "\\\\")}'))
|
|
10
|
+
})()`);
|
|
11
|
+
return fn();
|
|
12
|
+
};
|
package/dist/either.mjs
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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";
|
|
6
12
|
};
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
_tag: "Right",
|
|
10
|
-
value: value
|
|
11
|
-
};
|
|
13
|
+
export const isRight = (either) => {
|
|
14
|
+
return either._tag === "Right";
|
|
12
15
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
16
|
+
export const unwrapEither = (either) => {
|
|
17
|
+
return either.value;
|
|
15
18
|
};
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export var error = left;
|
|
23
|
-
export var ok = right;
|
|
24
|
-
export var unsafe = function(either, message) {
|
|
25
|
-
if (either._tag !== "Right") {
|
|
26
|
-
if (process.env.NODE_ENV !== "production") {
|
|
27
|
-
console.trace(JSON.stringify(either.value, null, 2));
|
|
28
|
-
}
|
|
29
|
-
throw new Error("unsafe threw: ".concat(either.value, " (").concat(message || "-", ")"));
|
|
19
|
+
export const error = left;
|
|
20
|
+
export const ok = right;
|
|
21
|
+
export const unsafe = (either, message) => {
|
|
22
|
+
if (either._tag !== "Right") {
|
|
23
|
+
if (true) {
|
|
24
|
+
console.trace(JSON.stringify(either.value, null, 2));
|
|
30
25
|
}
|
|
31
|
-
|
|
26
|
+
throw new Error(`unsafe threw: ${either.value} (${message || "-"})`);
|
|
27
|
+
}
|
|
28
|
+
return either.value;
|
|
32
29
|
};
|