@ls-stack/utils 3.13.0 → 3.15.0
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/lib/arrayUtils.cjs +5 -2
- package/lib/arrayUtils.js +3 -2
- package/lib/assertions.cjs +42 -34
- package/lib/assertions.d.cts +175 -11
- package/lib/assertions.d.ts +175 -11
- package/lib/assertions.js +2 -1
- package/lib/cache.cjs +7 -4
- package/lib/cache.js +2 -1
- package/lib/{chunk-UTFE4P3P.js → chunk-DMW5Q4T2.js} +1 -1
- package/lib/{chunk-OHHF4CJZ.js → chunk-GKOTKAIV.js} +1 -1
- package/lib/{chunk-U44EKR2F.js → chunk-NH2LCAQS.js} +1 -1
- package/lib/chunk-SSKW673U.js +36 -0
- package/lib/chunk-WS4WEVHU.js +57 -0
- package/lib/concurrentCalls.cjs +20 -14
- package/lib/concurrentCalls.d.cts +2 -0
- package/lib/concurrentCalls.d.ts +2 -0
- package/lib/concurrentCalls.js +5 -2
- package/lib/createThrottleController.cjs +5 -2
- package/lib/createThrottleController.js +3 -2
- package/lib/enhancedMap.cjs +5 -2
- package/lib/enhancedMap.js +3 -2
- package/lib/getCompositeKey.cjs +5 -2
- package/lib/getCompositeKey.js +3 -2
- package/lib/getValueStableKey.cjs +5 -2
- package/lib/getValueStableKey.js +3 -2
- package/lib/interpolate.cjs +2 -2
- package/lib/interpolate.js +2 -1
- package/lib/parallelAsyncCalls.cjs +10 -7
- package/lib/parallelAsyncCalls.js +2 -1
- package/lib/serializeXML.js +3 -2
- package/lib/testUtils.cjs +5 -2
- package/lib/testUtils.js +3 -2
- package/lib/tsResult.cjs +9 -4
- package/lib/tsResult.js +2 -1
- package/lib/typeGuards.cjs +65 -0
- package/lib/typeGuards.d.cts +109 -0
- package/lib/typeGuards.d.ts +109 -0
- package/lib/typeGuards.js +16 -0
- package/lib/typingFnUtils.cjs +10 -3
- package/lib/typingFnUtils.d.cts +25 -2
- package/lib/typingFnUtils.d.ts +25 -2
- package/lib/typingFnUtils.js +7 -2
- package/lib/yamlStringify.cjs +17 -9
- package/lib/yamlStringify.js +7 -2
- package/package.json +5 -1
- package/lib/chunk-3XCS7FVO.js +0 -66
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isFunction,
|
|
3
|
+
isObject,
|
|
4
|
+
isPlainObject,
|
|
5
|
+
isPromise
|
|
6
|
+
} from "./chunk-SSKW673U.js";
|
|
7
|
+
|
|
8
|
+
// src/assertions.ts
|
|
9
|
+
var undefErrMsg = "not undefined assertion failed";
|
|
10
|
+
var nullishErrMsg = "not nullish assertion failed";
|
|
11
|
+
function notUndefined(value, error = undefErrMsg) {
|
|
12
|
+
if (value === void 0) {
|
|
13
|
+
throw typeof error === "function" ? error() : new Error(error);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function notNullish(value, error = nullishErrMsg) {
|
|
18
|
+
if (value === void 0 || value === null) {
|
|
19
|
+
throw typeof error === "function" ? error() : new Error(error);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
function assertIsNotNullish(value, error = nullishErrMsg) {
|
|
24
|
+
if (value === void 0 || value === null) {
|
|
25
|
+
throw typeof error === "function" ? error() : new Error(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function assertIsNotUndefined(value, error = undefErrMsg) {
|
|
29
|
+
if (value === void 0) {
|
|
30
|
+
throw typeof error === "function" ? error() : new Error(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function invariant(condition, error = "Invariant violation") {
|
|
34
|
+
if (!condition) {
|
|
35
|
+
throw typeof error === "function" ? error() : new Error(`Invariant violation: ${error}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function exhaustiveCheck(narrowedType) {
|
|
39
|
+
return new Error("This should never happen");
|
|
40
|
+
}
|
|
41
|
+
var isFunction2 = isFunction;
|
|
42
|
+
var isObject2 = isObject;
|
|
43
|
+
var isPlainObject2 = isPlainObject;
|
|
44
|
+
var isPromise2 = isPromise;
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
notUndefined,
|
|
48
|
+
notNullish,
|
|
49
|
+
assertIsNotNullish,
|
|
50
|
+
assertIsNotUndefined,
|
|
51
|
+
invariant,
|
|
52
|
+
exhaustiveCheck,
|
|
53
|
+
isFunction2 as isFunction,
|
|
54
|
+
isObject2 as isObject,
|
|
55
|
+
isPlainObject2 as isPlainObject,
|
|
56
|
+
isPromise2 as isPromise
|
|
57
|
+
};
|
package/lib/concurrentCalls.cjs
CHANGED
|
@@ -26,12 +26,7 @@ __export(concurrentCalls_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(concurrentCalls_exports);
|
|
27
27
|
var import_t_result = require("t-result");
|
|
28
28
|
|
|
29
|
-
// src/
|
|
30
|
-
function invariant(condition, errorMsg = "Invariant violation") {
|
|
31
|
-
if (!condition) {
|
|
32
|
-
throw new Error(`Invariant violation: ${errorMsg}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
29
|
+
// src/typeGuards.ts
|
|
35
30
|
function isObject(value) {
|
|
36
31
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
32
|
}
|
|
@@ -42,12 +37,21 @@ function isPromise(value) {
|
|
|
42
37
|
return isObject(value) && "then" in value && isFunction(value.then);
|
|
43
38
|
}
|
|
44
39
|
|
|
40
|
+
// src/assertions.ts
|
|
41
|
+
function invariant(condition, error = "Invariant violation") {
|
|
42
|
+
if (!condition) {
|
|
43
|
+
throw typeof error === "function" ? error() : new Error(`Invariant violation: ${error}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var isFunction2 = isFunction;
|
|
47
|
+
var isPromise2 = isPromise;
|
|
48
|
+
|
|
45
49
|
// src/arrayUtils.ts
|
|
46
50
|
function truncateArray(array, maxLength, appendIfTruncated) {
|
|
47
51
|
const truncate = array.length > maxLength;
|
|
48
52
|
const result = truncate ? [...array.slice(0, maxLength)] : array;
|
|
49
53
|
if (truncate && appendIfTruncated) {
|
|
50
|
-
if (
|
|
54
|
+
if (isFunction2(appendIfTruncated)) {
|
|
51
55
|
return [...result, appendIfTruncated(array.length - maxLength)];
|
|
52
56
|
}
|
|
53
57
|
return [...result, appendIfTruncated];
|
|
@@ -76,14 +80,14 @@ var ConcurrentCalls = class {
|
|
|
76
80
|
}
|
|
77
81
|
resultifyAdd(...calls) {
|
|
78
82
|
const processedCalls = calls.map((call) => {
|
|
79
|
-
if (
|
|
83
|
+
if (isPromise2(call)) {
|
|
80
84
|
return call.then((value) => import_t_result.Result.ok(value)).catch((err) => import_t_result.Result.err((0, import_t_result.unknownToError)(err)));
|
|
81
85
|
} else {
|
|
82
86
|
const originalFn = call;
|
|
83
87
|
return async () => {
|
|
84
88
|
try {
|
|
85
89
|
const valueOrPromise = originalFn();
|
|
86
|
-
const value =
|
|
90
|
+
const value = isPromise2(valueOrPromise) ? await valueOrPromise : valueOrPromise;
|
|
87
91
|
return import_t_result.Result.ok(value);
|
|
88
92
|
} catch (err) {
|
|
89
93
|
return import_t_result.Result.err((0, import_t_result.unknownToError)(err));
|
|
@@ -101,7 +105,7 @@ var ConcurrentCalls = class {
|
|
|
101
105
|
const asyncResults = await Promise.all(
|
|
102
106
|
this.#pendingCalls.map(async (fn, i) => {
|
|
103
107
|
try {
|
|
104
|
-
const isP =
|
|
108
|
+
const isP = isPromise2(fn);
|
|
105
109
|
if (delayStart) {
|
|
106
110
|
invariant(
|
|
107
111
|
!isP,
|
|
@@ -131,7 +135,7 @@ var ConcurrentCalls = class {
|
|
|
131
135
|
const settledResults = await Promise.allSettled(
|
|
132
136
|
this.#pendingCalls.map(async (callOrPromise, i) => {
|
|
133
137
|
try {
|
|
134
|
-
const isP =
|
|
138
|
+
const isP = isPromise2(callOrPromise);
|
|
135
139
|
if (delayStart) {
|
|
136
140
|
invariant(
|
|
137
141
|
!isP,
|
|
@@ -186,7 +190,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
186
190
|
}
|
|
187
191
|
resultifyAdd(...items) {
|
|
188
192
|
const processedItems = items.map(({ fn, metadata }) => {
|
|
189
|
-
const cb =
|
|
193
|
+
const cb = isPromise2(fn) ? (0, import_t_result.resultify)(fn) : () => (0, import_t_result.resultify)(async () => {
|
|
190
194
|
const result = await fn();
|
|
191
195
|
return result;
|
|
192
196
|
});
|
|
@@ -210,7 +214,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
210
214
|
if (delayStart) {
|
|
211
215
|
await sleep(delayStart(i));
|
|
212
216
|
}
|
|
213
|
-
const result = await (
|
|
217
|
+
const result = await (isPromise2(call.fn) ? call.fn : call.fn());
|
|
214
218
|
if (!result.ok) {
|
|
215
219
|
throw { metadata: call.metadata, error: result.error };
|
|
216
220
|
}
|
|
@@ -244,6 +248,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
244
248
|
return {
|
|
245
249
|
succeeded: [],
|
|
246
250
|
failed: [],
|
|
251
|
+
failures: [],
|
|
247
252
|
results: [],
|
|
248
253
|
allFailed: false,
|
|
249
254
|
total: 0,
|
|
@@ -256,7 +261,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
256
261
|
if (delayStart) {
|
|
257
262
|
await sleep(delayStart(i));
|
|
258
263
|
}
|
|
259
|
-
const result = await (
|
|
264
|
+
const result = await (isPromise2(call.fn) ? call.fn : call.fn());
|
|
260
265
|
if (!result.ok) {
|
|
261
266
|
throw result.error;
|
|
262
267
|
}
|
|
@@ -294,6 +299,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
294
299
|
return {
|
|
295
300
|
succeeded: succeededProcessing,
|
|
296
301
|
failed: failedProcessing,
|
|
302
|
+
failures: failedProcessing,
|
|
297
303
|
results: resultsProcessing,
|
|
298
304
|
allFailed,
|
|
299
305
|
total,
|
|
@@ -56,7 +56,9 @@ declare class ConcurrentCallsWithMetadata<M extends ValidMetadata, R = unknown,
|
|
|
56
56
|
runAll({ delayStart }?: RunProps): Promise<Result<SucceededCall<R, M>[], FailedCall<M, E>>>;
|
|
57
57
|
runAllSettled({ delayStart }?: RunProps): Promise<{
|
|
58
58
|
allFailed: boolean;
|
|
59
|
+
/** @deprecated Use failures property instead */
|
|
59
60
|
failed: FailedCall<M, E>[];
|
|
61
|
+
failures: FailedCall<M, E>[];
|
|
60
62
|
succeeded: SucceededCall<R, M>[];
|
|
61
63
|
total: number;
|
|
62
64
|
results: SettledResultWithMetadata<R, M, E>[];
|
package/lib/concurrentCalls.d.ts
CHANGED
|
@@ -56,7 +56,9 @@ declare class ConcurrentCallsWithMetadata<M extends ValidMetadata, R = unknown,
|
|
|
56
56
|
runAll({ delayStart }?: RunProps): Promise<Result<SucceededCall<R, M>[], FailedCall<M, E>>>;
|
|
57
57
|
runAllSettled({ delayStart }?: RunProps): Promise<{
|
|
58
58
|
allFailed: boolean;
|
|
59
|
+
/** @deprecated Use failures property instead */
|
|
59
60
|
failed: FailedCall<M, E>[];
|
|
61
|
+
failures: FailedCall<M, E>[];
|
|
60
62
|
succeeded: SucceededCall<R, M>[];
|
|
61
63
|
total: number;
|
|
62
64
|
results: SettledResultWithMetadata<R, M, E>[];
|
package/lib/concurrentCalls.js
CHANGED
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
} from "./chunk-5DZT3Z5Z.js";
|
|
7
7
|
import {
|
|
8
8
|
truncateArray
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DMW5Q4T2.js";
|
|
10
10
|
import {
|
|
11
11
|
invariant,
|
|
12
12
|
isPromise
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WS4WEVHU.js";
|
|
14
|
+
import "./chunk-SSKW673U.js";
|
|
14
15
|
|
|
15
16
|
// src/concurrentCalls.ts
|
|
16
17
|
import { Result, resultify, unknownToError } from "t-result";
|
|
@@ -191,6 +192,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
191
192
|
return {
|
|
192
193
|
succeeded: [],
|
|
193
194
|
failed: [],
|
|
195
|
+
failures: [],
|
|
194
196
|
results: [],
|
|
195
197
|
allFailed: false,
|
|
196
198
|
total: 0,
|
|
@@ -241,6 +243,7 @@ var ConcurrentCallsWithMetadata = class {
|
|
|
241
243
|
return {
|
|
242
244
|
succeeded: succeededProcessing,
|
|
243
245
|
failed: failedProcessing,
|
|
246
|
+
failures: failedProcessing,
|
|
244
247
|
results: resultsProcessing,
|
|
245
248
|
allFailed,
|
|
246
249
|
total,
|
|
@@ -24,11 +24,14 @@ __export(createThrottleController_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(createThrottleController_exports);
|
|
26
26
|
|
|
27
|
-
// src/
|
|
27
|
+
// src/typeGuards.ts
|
|
28
28
|
function isFunction(value) {
|
|
29
29
|
return typeof value === "function";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// src/assertions.ts
|
|
33
|
+
var isFunction2 = isFunction;
|
|
34
|
+
|
|
32
35
|
// src/enhancedMap.ts
|
|
33
36
|
var enhancedMapReject = Symbol();
|
|
34
37
|
var EnhancedMap = class _EnhancedMap extends Map {
|
|
@@ -103,7 +106,7 @@ var EnhancedMap = class _EnhancedMap extends Map {
|
|
|
103
106
|
static from(array, mapFunction) {
|
|
104
107
|
const map = new _EnhancedMap();
|
|
105
108
|
if (!array) return map;
|
|
106
|
-
const isFn =
|
|
109
|
+
const isFn = isFunction2(mapFunction);
|
|
107
110
|
for (const item of array) {
|
|
108
111
|
if (isFn) {
|
|
109
112
|
const result = mapFunction(item);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EnhancedMap
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GKOTKAIV.js";
|
|
4
4
|
import {
|
|
5
5
|
durationObjToMs
|
|
6
6
|
} from "./chunk-5MNYPLZI.js";
|
|
7
7
|
import "./chunk-HTCYUMDR.js";
|
|
8
8
|
import "./chunk-II4R3VVX.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-WS4WEVHU.js";
|
|
10
|
+
import "./chunk-SSKW673U.js";
|
|
10
11
|
|
|
11
12
|
// src/createThrottleController.ts
|
|
12
13
|
function createThrottleController({
|
package/lib/enhancedMap.cjs
CHANGED
|
@@ -25,11 +25,14 @@ __export(enhancedMap_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(enhancedMap_exports);
|
|
27
27
|
|
|
28
|
-
// src/
|
|
28
|
+
// src/typeGuards.ts
|
|
29
29
|
function isFunction(value) {
|
|
30
30
|
return typeof value === "function";
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// src/assertions.ts
|
|
34
|
+
var isFunction2 = isFunction;
|
|
35
|
+
|
|
33
36
|
// src/enhancedMap.ts
|
|
34
37
|
var enhancedMapReject = Symbol();
|
|
35
38
|
var EnhancedMap = class _EnhancedMap extends Map {
|
|
@@ -104,7 +107,7 @@ var EnhancedMap = class _EnhancedMap extends Map {
|
|
|
104
107
|
static from(array, mapFunction) {
|
|
105
108
|
const map = new _EnhancedMap();
|
|
106
109
|
if (!array) return map;
|
|
107
|
-
const isFn =
|
|
110
|
+
const isFn = isFunction2(mapFunction);
|
|
108
111
|
for (const item of array) {
|
|
109
112
|
if (isFn) {
|
|
110
113
|
const result = mapFunction(item);
|
package/lib/enhancedMap.js
CHANGED
package/lib/getCompositeKey.cjs
CHANGED
|
@@ -24,11 +24,14 @@ __export(getCompositeKey_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(getCompositeKey_exports);
|
|
26
26
|
|
|
27
|
-
// src/
|
|
27
|
+
// src/typeGuards.ts
|
|
28
28
|
function isObject(value) {
|
|
29
29
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// src/assertions.ts
|
|
33
|
+
var isObject2 = isObject;
|
|
34
|
+
|
|
32
35
|
// src/getCompositeKey.ts
|
|
33
36
|
function getCompositeKey(input, maxSortingDepth = 3) {
|
|
34
37
|
if (typeof input === "string") return `"${input}`;
|
|
@@ -51,7 +54,7 @@ function stringifyCompact(input, maxSortingDepth, depth, refs) {
|
|
|
51
54
|
result += stringifyCompact(v, maxSortingDepth, depth + 1, refs);
|
|
52
55
|
}
|
|
53
56
|
result += "]";
|
|
54
|
-
} else if (
|
|
57
|
+
} else if (isObject2(input)) {
|
|
55
58
|
let entries = Object.entries(input);
|
|
56
59
|
if (entries.length === 0) {
|
|
57
60
|
result = "{}";
|
package/lib/getCompositeKey.js
CHANGED
|
@@ -24,11 +24,14 @@ __export(getValueStableKey_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(getValueStableKey_exports);
|
|
26
26
|
|
|
27
|
-
// src/
|
|
27
|
+
// src/typeGuards.ts
|
|
28
28
|
function isObject(value) {
|
|
29
29
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// src/assertions.ts
|
|
33
|
+
var isObject2 = isObject;
|
|
34
|
+
|
|
32
35
|
// src/getCompositeKey.ts
|
|
33
36
|
function getCompositeKey(input, maxSortingDepth = 3) {
|
|
34
37
|
if (typeof input === "string") return `"${input}`;
|
|
@@ -51,7 +54,7 @@ function stringifyCompact(input, maxSortingDepth, depth, refs) {
|
|
|
51
54
|
result += stringifyCompact(v, maxSortingDepth, depth + 1, refs);
|
|
52
55
|
}
|
|
53
56
|
result += "]";
|
|
54
|
-
} else if (
|
|
57
|
+
} else if (isObject2(input)) {
|
|
55
58
|
let entries = Object.entries(input);
|
|
56
59
|
if (entries.length === 0) {
|
|
57
60
|
result = "{}";
|
package/lib/getValueStableKey.js
CHANGED
package/lib/interpolate.cjs
CHANGED
|
@@ -26,9 +26,9 @@ __export(interpolate_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(interpolate_exports);
|
|
27
27
|
|
|
28
28
|
// src/assertions.ts
|
|
29
|
-
function invariant(condition,
|
|
29
|
+
function invariant(condition, error = "Invariant violation") {
|
|
30
30
|
if (!condition) {
|
|
31
|
-
throw new Error(`Invariant violation: ${
|
|
31
|
+
throw typeof error === "function" ? error() : new Error(`Invariant violation: ${error}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
package/lib/interpolate.js
CHANGED
|
@@ -25,15 +25,18 @@ __export(parallelAsyncCalls_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(parallelAsyncCalls_exports);
|
|
26
26
|
var import_t_result = require("t-result");
|
|
27
27
|
|
|
28
|
+
// src/typeGuards.ts
|
|
29
|
+
function isObject(value) {
|
|
30
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
// src/assertions.ts
|
|
29
|
-
function invariant(condition,
|
|
34
|
+
function invariant(condition, error = "Invariant violation") {
|
|
30
35
|
if (!condition) {
|
|
31
|
-
throw new Error(`Invariant violation: ${
|
|
36
|
+
throw typeof error === "function" ? error() : new Error(`Invariant violation: ${error}`);
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
|
-
}
|
|
39
|
+
var isObject2 = isObject;
|
|
37
40
|
|
|
38
41
|
// src/sleep.ts
|
|
39
42
|
function sleep(ms) {
|
|
@@ -48,7 +51,7 @@ var ParallelAsyncResultCalls = class {
|
|
|
48
51
|
}
|
|
49
52
|
add(call) {
|
|
50
53
|
this.pendingCalls.push(
|
|
51
|
-
|
|
54
|
+
isObject2(call) ? call : { metadata: void 0, fn: call }
|
|
52
55
|
);
|
|
53
56
|
return this;
|
|
54
57
|
}
|
|
@@ -56,7 +59,7 @@ var ParallelAsyncResultCalls = class {
|
|
|
56
59
|
addTuple(...calls) {
|
|
57
60
|
for (const call of calls) {
|
|
58
61
|
this.pendingCalls.push(
|
|
59
|
-
|
|
62
|
+
isObject2(call) ? call : { metadata: void 0, fn: call }
|
|
60
63
|
);
|
|
61
64
|
}
|
|
62
65
|
return {
|
package/lib/serializeXML.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
filterAndMap
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-DMW5Q4T2.js";
|
|
4
|
+
import "./chunk-WS4WEVHU.js";
|
|
5
|
+
import "./chunk-SSKW673U.js";
|
|
5
6
|
|
|
6
7
|
// src/serializeXML.ts
|
|
7
8
|
var XML_TAG_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9._-]*$/;
|
package/lib/testUtils.cjs
CHANGED
|
@@ -26,11 +26,14 @@ __export(testUtils_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(testUtils_exports);
|
|
28
28
|
|
|
29
|
-
// src/
|
|
29
|
+
// src/typeGuards.ts
|
|
30
30
|
function isObject(value) {
|
|
31
31
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// src/assertions.ts
|
|
35
|
+
var isObject2 = isObject;
|
|
36
|
+
|
|
34
37
|
// src/arrayUtils.ts
|
|
35
38
|
function filterAndMap(array, mapFilter) {
|
|
36
39
|
const result = [];
|
|
@@ -175,7 +178,7 @@ function createLoggerStore({
|
|
|
175
178
|
startTime = Date.now();
|
|
176
179
|
}
|
|
177
180
|
function add(render) {
|
|
178
|
-
if (!
|
|
181
|
+
if (!isObject2(render)) {
|
|
179
182
|
for (const [i, r] of render.entries()) {
|
|
180
183
|
logs.push({
|
|
181
184
|
i: i + 1,
|
package/lib/testUtils.js
CHANGED
|
@@ -14,10 +14,11 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
arrayWithPrevAndIndex,
|
|
16
16
|
filterAndMap
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-DMW5Q4T2.js";
|
|
18
18
|
import {
|
|
19
19
|
isObject
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WS4WEVHU.js";
|
|
21
|
+
import "./chunk-SSKW673U.js";
|
|
21
22
|
|
|
22
23
|
// src/testUtils.ts
|
|
23
24
|
function createLoggerStore({
|
package/lib/tsResult.cjs
CHANGED
|
@@ -28,7 +28,7 @@ __export(tsResult_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(tsResult_exports);
|
|
30
30
|
|
|
31
|
-
// src/
|
|
31
|
+
// src/typeGuards.ts
|
|
32
32
|
function isObject(value) {
|
|
33
33
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
34
|
}
|
|
@@ -39,6 +39,11 @@ function isPromise(value) {
|
|
|
39
39
|
return isObject(value) && "then" in value && isFunction(value.then);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// src/assertions.ts
|
|
43
|
+
var isFunction2 = isFunction;
|
|
44
|
+
var isObject2 = isObject;
|
|
45
|
+
var isPromise2 = isPromise;
|
|
46
|
+
|
|
42
47
|
// src/safeJson.ts
|
|
43
48
|
function safeJsonStringify(value) {
|
|
44
49
|
try {
|
|
@@ -163,7 +168,7 @@ var Result = {
|
|
|
163
168
|
getOkErr
|
|
164
169
|
};
|
|
165
170
|
function resultify(fn, errorNormalizer) {
|
|
166
|
-
if (!
|
|
171
|
+
if (!isFunction2(fn)) {
|
|
167
172
|
return fn.then((value) => ok(value)).catch(
|
|
168
173
|
(error) => err(
|
|
169
174
|
errorNormalizer ? errorNormalizer(error) : unknownToError(error)
|
|
@@ -172,7 +177,7 @@ function resultify(fn, errorNormalizer) {
|
|
|
172
177
|
}
|
|
173
178
|
try {
|
|
174
179
|
const result = fn();
|
|
175
|
-
if (
|
|
180
|
+
if (isPromise2(result)) {
|
|
176
181
|
return result.then((value) => ok(value)).catch(
|
|
177
182
|
(error) => err(
|
|
178
183
|
errorNormalizer ? errorNormalizer(error) : unknownToError(error)
|
|
@@ -191,7 +196,7 @@ function unknownToError(error) {
|
|
|
191
196
|
if (typeof error === "string") {
|
|
192
197
|
return new Error(error);
|
|
193
198
|
}
|
|
194
|
-
if (
|
|
199
|
+
if (isObject2(error)) {
|
|
195
200
|
return new Error(
|
|
196
201
|
"message" in error && error.message && typeof error.message === "string" ? error.message : safeJsonStringify(error) ?? "unknown",
|
|
197
202
|
{ cause: error }
|
package/lib/tsResult.js
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/typeGuards.ts
|
|
21
|
+
var typeGuards_exports = {};
|
|
22
|
+
__export(typeGuards_exports, {
|
|
23
|
+
arrayHasAtLeastXItems: () => arrayHasAtLeastXItems,
|
|
24
|
+
isFunction: () => isFunction,
|
|
25
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
26
|
+
isObject: () => isObject,
|
|
27
|
+
isPlainObject: () => isPlainObject,
|
|
28
|
+
isPromise: () => isPromise
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(typeGuards_exports);
|
|
31
|
+
function isObject(value) {
|
|
32
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
function isFunction(value) {
|
|
35
|
+
return typeof value === "function";
|
|
36
|
+
}
|
|
37
|
+
function isPromise(value) {
|
|
38
|
+
return isObject(value) && "then" in value && isFunction(value.then);
|
|
39
|
+
}
|
|
40
|
+
function isPlainObject(value) {
|
|
41
|
+
if (!value || typeof value !== "object") return false;
|
|
42
|
+
const proto = Object.getPrototypeOf(value);
|
|
43
|
+
if (proto === null) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
47
|
+
if (Ctor === Object) return true;
|
|
48
|
+
const objectCtorString = Object.prototype.constructor.toString();
|
|
49
|
+
return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
|
|
50
|
+
}
|
|
51
|
+
function isNonEmptyArray(value) {
|
|
52
|
+
return value.length > 0;
|
|
53
|
+
}
|
|
54
|
+
function arrayHasAtLeastXItems(array, minLength) {
|
|
55
|
+
return array.length >= minLength;
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
arrayHasAtLeastXItems,
|
|
60
|
+
isFunction,
|
|
61
|
+
isNonEmptyArray,
|
|
62
|
+
isObject,
|
|
63
|
+
isPlainObject,
|
|
64
|
+
isPromise
|
|
65
|
+
});
|