modelfusion 0.91.0 → 0.92.1
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/README.md +4 -2
- package/core/FunctionOptions.d.ts +3 -11
- package/core/LogFormat.cjs +10 -0
- package/core/LogFormat.d.ts +9 -0
- package/core/LogFormat.js +9 -0
- package/core/ModelFusionConfiguration.cjs +21 -0
- package/core/ModelFusionConfiguration.d.ts +6 -0
- package/core/ModelFusionConfiguration.js +14 -0
- package/core/api/ApiCallError.cjs +9 -1
- package/core/api/ApiCallError.d.ts +4 -1
- package/core/api/ApiCallError.js +9 -1
- package/core/executeFunctionCall.cjs +4 -4
- package/core/executeFunctionCall.js +4 -4
- package/core/getFunctionCallLogger.cjs +21 -5
- package/core/getFunctionCallLogger.js +21 -5
- package/core/index.cjs +15 -2
- package/core/index.d.ts +2 -2
- package/core/index.js +2 -2
- package/model-function/executeStandardCall.cjs +4 -4
- package/model-function/executeStandardCall.js +4 -4
- package/model-function/executeStreamCall.cjs +4 -4
- package/model-function/executeStreamCall.js +4 -4
- package/model-provider/ollama/OllamaError.cjs +25 -24
- package/model-provider/ollama/OllamaError.d.ts +1 -11
- package/model-provider/ollama/OllamaError.js +24 -22
- package/model-provider/ollama/OllamaTextGenerationModel.cjs +38 -1
- package/model-provider/ollama/OllamaTextGenerationModel.d.ts +5 -1
- package/model-provider/ollama/OllamaTextGenerationModel.js +39 -2
- package/model-provider/ollama/OllamaTextGenerationModel.test.cjs +63 -0
- package/model-provider/ollama/OllamaTextGenerationModel.test.d.ts +1 -0
- package/model-provider/ollama/OllamaTextGenerationModel.test.js +61 -0
- package/model-provider/ollama/index.cjs +1 -3
- package/model-provider/ollama/index.d.ts +1 -1
- package/model-provider/ollama/index.js +0 -1
- package/model-provider/openai/OpenAIError.cjs +13 -29
- package/model-provider/openai/OpenAIError.d.ts +2 -11
- package/model-provider/openai/OpenAIError.js +11 -26
- package/model-provider/openai/index.cjs +1 -3
- package/model-provider/openai/index.d.ts +1 -1
- package/model-provider/openai/index.js +0 -1
- package/model-provider/whispercpp/WhisperCppTranscriptionModel.cjs +5 -8
- package/model-provider/whispercpp/WhisperCppTranscriptionModel.js +5 -8
- package/package.json +5 -4
- package/tool/execute-tool/executeTool.cjs +3 -4
- package/tool/execute-tool/executeTool.js +3 -4
- package/util/AsyncQueue.test.cjs +20 -21
- package/util/AsyncQueue.test.js +9 -10
- package/util/isDeepEqualData.test.cjs +14 -15
- package/util/isDeepEqualData.test.js +14 -15
- package/util/runSafe.test.cjs +12 -13
- package/util/runSafe.test.js +6 -7
- package/core/GlobalFunctionLogging.cjs +0 -12
- package/core/GlobalFunctionLogging.d.ts +0 -3
- package/core/GlobalFunctionLogging.js +0 -7
- package/core/GlobalFunctionObservers.cjs +0 -12
- package/core/GlobalFunctionObservers.d.ts +0 -3
- package/core/GlobalFunctionObservers.js +0 -7
package/util/AsyncQueue.test.cjs
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const vitest_1 = require("vitest");
|
4
3
|
const delay_js_1 = require("./delay.cjs");
|
5
4
|
const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
6
|
-
(
|
5
|
+
it("should receive values in order for single iterator created before pushing", async () => {
|
7
6
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
8
7
|
const receivedValues = [];
|
9
8
|
const receiveValuesPromise = (async () => {
|
@@ -16,9 +15,9 @@ const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
|
16
15
|
asyncQueue.push(3);
|
17
16
|
asyncQueue.close();
|
18
17
|
await receiveValuesPromise;
|
19
|
-
|
18
|
+
expect(receivedValues).toEqual([1, 2, 3]);
|
20
19
|
});
|
21
|
-
(
|
20
|
+
it("should receive values in order for single iterator created after closing", async () => {
|
22
21
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
23
22
|
asyncQueue.push(1);
|
24
23
|
asyncQueue.push(2);
|
@@ -31,9 +30,9 @@ const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
|
31
30
|
}
|
32
31
|
})();
|
33
32
|
await receiveValuesPromise;
|
34
|
-
|
33
|
+
expect(receivedValues).toEqual([1, 2, 3]);
|
35
34
|
});
|
36
|
-
(
|
35
|
+
it("should handle delayed pushing", async () => {
|
37
36
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
38
37
|
setTimeout(() => {
|
39
38
|
asyncQueue.push(1);
|
@@ -44,12 +43,12 @@ const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
|
44
43
|
for await (const value of asyncQueue) {
|
45
44
|
receivedValues.push(value);
|
46
45
|
}
|
47
|
-
|
46
|
+
expect(receivedValues).toEqual([1, 2]);
|
48
47
|
});
|
49
|
-
(
|
48
|
+
it("should error handling in consumer", async () => {
|
50
49
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
51
50
|
asyncQueue.push(1);
|
52
|
-
await
|
51
|
+
await expect((async () => {
|
53
52
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
54
53
|
for await (const _value of asyncQueue) {
|
55
54
|
throw new Error("Consumer error");
|
@@ -62,23 +61,23 @@ const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
|
62
61
|
for await (const value of asyncQueue) {
|
63
62
|
receivedValues.push(value);
|
64
63
|
}
|
65
|
-
|
64
|
+
expect(receivedValues).toEqual([1, 2]);
|
66
65
|
});
|
67
|
-
(
|
66
|
+
it("should behavior on empty queue closing", async () => {
|
68
67
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
69
68
|
asyncQueue.close();
|
70
69
|
const receivedValues = [];
|
71
70
|
for await (const value of asyncQueue) {
|
72
71
|
receivedValues.push(value);
|
73
72
|
}
|
74
|
-
|
73
|
+
expect(receivedValues).toEqual([]);
|
75
74
|
});
|
76
|
-
(
|
75
|
+
it("should multiple closings", async () => {
|
77
76
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
78
77
|
asyncQueue.close();
|
79
|
-
|
78
|
+
expect(() => asyncQueue.close()).not.toThrow();
|
80
79
|
});
|
81
|
-
(
|
80
|
+
it("should receive all values in multiple independent consumers", async () => {
|
82
81
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
83
82
|
const consumerPromises = [1, 2].map(async () => {
|
84
83
|
const receivedValues = [];
|
@@ -97,10 +96,10 @@ const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
|
97
96
|
asyncQueue.close();
|
98
97
|
const allReceivedValues = await Promise.all(consumerPromises);
|
99
98
|
allReceivedValues.forEach((receivedValues) => {
|
100
|
-
|
99
|
+
expect(receivedValues).toEqual([1, 2, 3]);
|
101
100
|
});
|
102
101
|
});
|
103
|
-
(
|
102
|
+
it("should each consumer receives all pushed values under varying conditions", async () => {
|
104
103
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
105
104
|
// Start the first consumer, which will await values.
|
106
105
|
const receivedValues1 = [];
|
@@ -128,11 +127,11 @@ const AsyncQueue_js_1 = require("./AsyncQueue.cjs");
|
|
128
127
|
asyncQueue.close();
|
129
128
|
await Promise.all([consumer1, consumer2]);
|
130
129
|
// Both consumers should have received all values, even if they started at different times.
|
131
|
-
|
132
|
-
|
130
|
+
expect(receivedValues1).toEqual([1, 2, 3]);
|
131
|
+
expect(receivedValues2).toEqual([1, 2, 3]); // This will likely fail because consumer2 started late.
|
133
132
|
});
|
134
|
-
(
|
133
|
+
it("should throw error when pushing to a closed queue", async () => {
|
135
134
|
const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
|
136
135
|
asyncQueue.close();
|
137
|
-
|
136
|
+
expect(() => asyncQueue.push(1)).toThrowError("Cannot push value to closed queue.");
|
138
137
|
});
|
package/util/AsyncQueue.test.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { expect, test } from "vitest";
|
2
1
|
import { delay } from "./delay.js";
|
3
2
|
import { AsyncQueue } from "./AsyncQueue.js";
|
4
|
-
|
3
|
+
it("should receive values in order for single iterator created before pushing", async () => {
|
5
4
|
const asyncQueue = new AsyncQueue();
|
6
5
|
const receivedValues = [];
|
7
6
|
const receiveValuesPromise = (async () => {
|
@@ -16,7 +15,7 @@ test("receive values in order for single iterator created before pushing", async
|
|
16
15
|
await receiveValuesPromise;
|
17
16
|
expect(receivedValues).toEqual([1, 2, 3]);
|
18
17
|
});
|
19
|
-
|
18
|
+
it("should receive values in order for single iterator created after closing", async () => {
|
20
19
|
const asyncQueue = new AsyncQueue();
|
21
20
|
asyncQueue.push(1);
|
22
21
|
asyncQueue.push(2);
|
@@ -31,7 +30,7 @@ test("receive values in order for single iterator created after closing", async
|
|
31
30
|
await receiveValuesPromise;
|
32
31
|
expect(receivedValues).toEqual([1, 2, 3]);
|
33
32
|
});
|
34
|
-
|
33
|
+
it("should handle delayed pushing", async () => {
|
35
34
|
const asyncQueue = new AsyncQueue();
|
36
35
|
setTimeout(() => {
|
37
36
|
asyncQueue.push(1);
|
@@ -44,7 +43,7 @@ test("handle delayed pushing", async () => {
|
|
44
43
|
}
|
45
44
|
expect(receivedValues).toEqual([1, 2]);
|
46
45
|
});
|
47
|
-
|
46
|
+
it("should error handling in consumer", async () => {
|
48
47
|
const asyncQueue = new AsyncQueue();
|
49
48
|
asyncQueue.push(1);
|
50
49
|
await expect((async () => {
|
@@ -62,7 +61,7 @@ test("error handling in consumer", async () => {
|
|
62
61
|
}
|
63
62
|
expect(receivedValues).toEqual([1, 2]);
|
64
63
|
});
|
65
|
-
|
64
|
+
it("should behavior on empty queue closing", async () => {
|
66
65
|
const asyncQueue = new AsyncQueue();
|
67
66
|
asyncQueue.close();
|
68
67
|
const receivedValues = [];
|
@@ -71,12 +70,12 @@ test("behavior on empty queue closing", async () => {
|
|
71
70
|
}
|
72
71
|
expect(receivedValues).toEqual([]);
|
73
72
|
});
|
74
|
-
|
73
|
+
it("should multiple closings", async () => {
|
75
74
|
const asyncQueue = new AsyncQueue();
|
76
75
|
asyncQueue.close();
|
77
76
|
expect(() => asyncQueue.close()).not.toThrow();
|
78
77
|
});
|
79
|
-
|
78
|
+
it("should receive all values in multiple independent consumers", async () => {
|
80
79
|
const asyncQueue = new AsyncQueue();
|
81
80
|
const consumerPromises = [1, 2].map(async () => {
|
82
81
|
const receivedValues = [];
|
@@ -98,7 +97,7 @@ test("receive all values in multiple independent consumers", async () => {
|
|
98
97
|
expect(receivedValues).toEqual([1, 2, 3]);
|
99
98
|
});
|
100
99
|
});
|
101
|
-
|
100
|
+
it("should each consumer receives all pushed values under varying conditions", async () => {
|
102
101
|
const asyncQueue = new AsyncQueue();
|
103
102
|
// Start the first consumer, which will await values.
|
104
103
|
const receivedValues1 = [];
|
@@ -129,7 +128,7 @@ test("each consumer receives all pushed values under varying conditions", async
|
|
129
128
|
expect(receivedValues1).toEqual([1, 2, 3]);
|
130
129
|
expect(receivedValues2).toEqual([1, 2, 3]); // This will likely fail because consumer2 started late.
|
131
130
|
});
|
132
|
-
|
131
|
+
it("should throw error when pushing to a closed queue", async () => {
|
133
132
|
const asyncQueue = new AsyncQueue();
|
134
133
|
asyncQueue.close();
|
135
134
|
expect(() => asyncQueue.push(1)).toThrowError("Cannot push value to closed queue.");
|
@@ -4,9 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
7
|
-
const vitest_1 = require("vitest");
|
8
7
|
const isDeepEqualData_js_1 = require("./isDeepEqualData.cjs");
|
9
|
-
(
|
8
|
+
it("should check if two primitives are equal", async () => {
|
10
9
|
let x = 1;
|
11
10
|
let y = 1;
|
12
11
|
let result = (0, isDeepEqualData_js_1.isDeepEqualData)(x, y);
|
@@ -16,48 +15,48 @@ const isDeepEqualData_js_1 = require("./isDeepEqualData.cjs");
|
|
16
15
|
result = (0, isDeepEqualData_js_1.isDeepEqualData)(x, y);
|
17
16
|
node_assert_1.default.equal(result, false);
|
18
17
|
});
|
19
|
-
(
|
18
|
+
it("should return false for different types", async () => {
|
20
19
|
const obj = { a: 1 };
|
21
20
|
const num = 1;
|
22
21
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj, num);
|
23
22
|
node_assert_1.default.equal(result, false);
|
24
23
|
});
|
25
|
-
(
|
24
|
+
it("should return false for null values compared with objects", async () => {
|
26
25
|
const obj = { a: 1 };
|
27
26
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj, null);
|
28
27
|
node_assert_1.default.equal(result, false);
|
29
28
|
});
|
30
|
-
(
|
29
|
+
it("should identify two equal objects", async () => {
|
31
30
|
const obj1 = { a: 1, b: 2 };
|
32
31
|
const obj2 = { a: 1, b: 2 };
|
33
32
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj1, obj2);
|
34
33
|
node_assert_1.default.equal(result, true);
|
35
34
|
});
|
36
|
-
(
|
35
|
+
it("should identify two objects with different values", async () => {
|
37
36
|
const obj1 = { a: 1, b: 2 };
|
38
37
|
const obj2 = { a: 1, b: 3 };
|
39
38
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj1, obj2);
|
40
39
|
node_assert_1.default.equal(result, false);
|
41
40
|
});
|
42
|
-
(
|
41
|
+
it("should identify two objects with different number of keys", async () => {
|
43
42
|
const obj1 = { a: 1, b: 2 };
|
44
43
|
const obj2 = { a: 1, b: 2, c: 3 };
|
45
44
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj1, obj2);
|
46
45
|
node_assert_1.default.equal(result, false);
|
47
46
|
});
|
48
|
-
(
|
47
|
+
it("should handle nested objects", async () => {
|
49
48
|
const obj1 = { a: { c: 1 }, b: 2 };
|
50
49
|
const obj2 = { a: { c: 1 }, b: 2 };
|
51
50
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj1, obj2);
|
52
51
|
node_assert_1.default.equal(result, true);
|
53
52
|
});
|
54
|
-
(
|
53
|
+
it("should detect inequality in nested objects", async () => {
|
55
54
|
const obj1 = { a: { c: 1 }, b: 2 };
|
56
55
|
const obj2 = { a: { c: 2 }, b: 2 };
|
57
56
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj1, obj2);
|
58
57
|
node_assert_1.default.equal(result, false);
|
59
58
|
});
|
60
|
-
(
|
59
|
+
it("should compare arrays correctly", async () => {
|
61
60
|
const arr1 = [1, 2, 3];
|
62
61
|
const arr2 = [1, 2, 3];
|
63
62
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(arr1, arr2);
|
@@ -67,18 +66,18 @@ const isDeepEqualData_js_1 = require("./isDeepEqualData.cjs");
|
|
67
66
|
const result2 = (0, isDeepEqualData_js_1.isDeepEqualData)(arr3, arr4);
|
68
67
|
node_assert_1.default.equal(result2, false);
|
69
68
|
});
|
70
|
-
(
|
69
|
+
it("should return false for null comparison with object", () => {
|
71
70
|
const obj = { a: 1 };
|
72
71
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj, null);
|
73
72
|
node_assert_1.default.equal(result, false);
|
74
73
|
});
|
75
|
-
(
|
74
|
+
it("should distinguish between array and object with same enumerable properties", () => {
|
76
75
|
const obj = { 0: "one", 1: "two", length: 2 };
|
77
76
|
const arr = ["one", "two"];
|
78
77
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj, arr);
|
79
78
|
node_assert_1.default.equal(result, false);
|
80
79
|
});
|
81
|
-
(
|
80
|
+
it("should return false when comparing objects with different prototypes", () => {
|
82
81
|
const obj1 = Object.create({ a: 1 });
|
83
82
|
const obj2 = Object.create(null);
|
84
83
|
obj1.b = 2;
|
@@ -86,14 +85,14 @@ const isDeepEqualData_js_1 = require("./isDeepEqualData.cjs");
|
|
86
85
|
const result = (0, isDeepEqualData_js_1.isDeepEqualData)(obj1, obj2);
|
87
86
|
node_assert_1.default.equal(result, false);
|
88
87
|
});
|
89
|
-
(
|
88
|
+
it("should handle date object comparisons correctly", () => {
|
90
89
|
const date1 = new Date(2000, 0, 1);
|
91
90
|
const date2 = new Date(2000, 0, 1);
|
92
91
|
const date3 = new Date(2000, 0, 2);
|
93
92
|
node_assert_1.default.equal((0, isDeepEqualData_js_1.isDeepEqualData)(date1, date2), true);
|
94
93
|
node_assert_1.default.equal((0, isDeepEqualData_js_1.isDeepEqualData)(date1, date3), false);
|
95
94
|
});
|
96
|
-
(
|
95
|
+
it("should handle function comparisons", () => {
|
97
96
|
const func1 = () => {
|
98
97
|
console.log("hello");
|
99
98
|
};
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import assert from "node:assert";
|
2
|
-
import { test } from "vitest";
|
3
2
|
import { isDeepEqualData } from "./isDeepEqualData.js";
|
4
|
-
|
3
|
+
it("should check if two primitives are equal", async () => {
|
5
4
|
let x = 1;
|
6
5
|
let y = 1;
|
7
6
|
let result = isDeepEqualData(x, y);
|
@@ -11,48 +10,48 @@ test("checks if two primitives are equal", async () => {
|
|
11
10
|
result = isDeepEqualData(x, y);
|
12
11
|
assert.equal(result, false);
|
13
12
|
});
|
14
|
-
|
13
|
+
it("should return false for different types", async () => {
|
15
14
|
const obj = { a: 1 };
|
16
15
|
const num = 1;
|
17
16
|
const result = isDeepEqualData(obj, num);
|
18
17
|
assert.equal(result, false);
|
19
18
|
});
|
20
|
-
|
19
|
+
it("should return false for null values compared with objects", async () => {
|
21
20
|
const obj = { a: 1 };
|
22
21
|
const result = isDeepEqualData(obj, null);
|
23
22
|
assert.equal(result, false);
|
24
23
|
});
|
25
|
-
|
24
|
+
it("should identify two equal objects", async () => {
|
26
25
|
const obj1 = { a: 1, b: 2 };
|
27
26
|
const obj2 = { a: 1, b: 2 };
|
28
27
|
const result = isDeepEqualData(obj1, obj2);
|
29
28
|
assert.equal(result, true);
|
30
29
|
});
|
31
|
-
|
30
|
+
it("should identify two objects with different values", async () => {
|
32
31
|
const obj1 = { a: 1, b: 2 };
|
33
32
|
const obj2 = { a: 1, b: 3 };
|
34
33
|
const result = isDeepEqualData(obj1, obj2);
|
35
34
|
assert.equal(result, false);
|
36
35
|
});
|
37
|
-
|
36
|
+
it("should identify two objects with different number of keys", async () => {
|
38
37
|
const obj1 = { a: 1, b: 2 };
|
39
38
|
const obj2 = { a: 1, b: 2, c: 3 };
|
40
39
|
const result = isDeepEqualData(obj1, obj2);
|
41
40
|
assert.equal(result, false);
|
42
41
|
});
|
43
|
-
|
42
|
+
it("should handle nested objects", async () => {
|
44
43
|
const obj1 = { a: { c: 1 }, b: 2 };
|
45
44
|
const obj2 = { a: { c: 1 }, b: 2 };
|
46
45
|
const result = isDeepEqualData(obj1, obj2);
|
47
46
|
assert.equal(result, true);
|
48
47
|
});
|
49
|
-
|
48
|
+
it("should detect inequality in nested objects", async () => {
|
50
49
|
const obj1 = { a: { c: 1 }, b: 2 };
|
51
50
|
const obj2 = { a: { c: 2 }, b: 2 };
|
52
51
|
const result = isDeepEqualData(obj1, obj2);
|
53
52
|
assert.equal(result, false);
|
54
53
|
});
|
55
|
-
|
54
|
+
it("should compare arrays correctly", async () => {
|
56
55
|
const arr1 = [1, 2, 3];
|
57
56
|
const arr2 = [1, 2, 3];
|
58
57
|
const result = isDeepEqualData(arr1, arr2);
|
@@ -62,18 +61,18 @@ test("compares arrays correctly", async () => {
|
|
62
61
|
const result2 = isDeepEqualData(arr3, arr4);
|
63
62
|
assert.equal(result2, false);
|
64
63
|
});
|
65
|
-
|
64
|
+
it("should return false for null comparison with object", () => {
|
66
65
|
const obj = { a: 1 };
|
67
66
|
const result = isDeepEqualData(obj, null);
|
68
67
|
assert.equal(result, false);
|
69
68
|
});
|
70
|
-
|
69
|
+
it("should distinguish between array and object with same enumerable properties", () => {
|
71
70
|
const obj = { 0: "one", 1: "two", length: 2 };
|
72
71
|
const arr = ["one", "two"];
|
73
72
|
const result = isDeepEqualData(obj, arr);
|
74
73
|
assert.equal(result, false);
|
75
74
|
});
|
76
|
-
|
75
|
+
it("should return false when comparing objects with different prototypes", () => {
|
77
76
|
const obj1 = Object.create({ a: 1 });
|
78
77
|
const obj2 = Object.create(null);
|
79
78
|
obj1.b = 2;
|
@@ -81,14 +80,14 @@ test("returns false when comparing objects with different prototypes", () => {
|
|
81
80
|
const result = isDeepEqualData(obj1, obj2);
|
82
81
|
assert.equal(result, false);
|
83
82
|
});
|
84
|
-
|
83
|
+
it("should handle date object comparisons correctly", () => {
|
85
84
|
const date1 = new Date(2000, 0, 1);
|
86
85
|
const date2 = new Date(2000, 0, 1);
|
87
86
|
const date3 = new Date(2000, 0, 2);
|
88
87
|
assert.equal(isDeepEqualData(date1, date2), true);
|
89
88
|
assert.equal(isDeepEqualData(date1, date3), false);
|
90
89
|
});
|
91
|
-
|
90
|
+
it("should handle function comparisons", () => {
|
92
91
|
const func1 = () => {
|
93
92
|
console.log("hello");
|
94
93
|
};
|
package/util/runSafe.test.cjs
CHANGED
@@ -1,58 +1,57 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const vitest_1 = require("vitest");
|
4
3
|
const runSafe_js_1 = require("./runSafe.cjs");
|
5
|
-
(
|
4
|
+
it("should catch thrown error in sync function", async () => {
|
6
5
|
const error = new Error("test error");
|
7
6
|
const result = await (0, runSafe_js_1.runSafe)(() => {
|
8
7
|
throw error;
|
9
8
|
});
|
10
|
-
|
9
|
+
expect(result).toEqual({
|
11
10
|
ok: false,
|
12
11
|
error,
|
13
12
|
});
|
14
13
|
});
|
15
|
-
(
|
14
|
+
it("should catch thrown string in sync function", async () => {
|
16
15
|
const result = await (0, runSafe_js_1.runSafe)(() => {
|
17
16
|
throw "test error";
|
18
17
|
});
|
19
|
-
|
18
|
+
expect(result).toEqual({
|
20
19
|
ok: false,
|
21
20
|
error: "test error",
|
22
21
|
});
|
23
22
|
});
|
24
|
-
(
|
23
|
+
it("should catch thrown error in async function", async () => {
|
25
24
|
const error = new Error("test error");
|
26
25
|
const result = await (0, runSafe_js_1.runSafe)(async () => {
|
27
26
|
throw error;
|
28
27
|
});
|
29
|
-
|
28
|
+
expect(result).toEqual({
|
30
29
|
ok: false,
|
31
30
|
error,
|
32
31
|
});
|
33
32
|
});
|
34
|
-
(
|
33
|
+
it("should catch thrown string in async function", async () => {
|
35
34
|
const result = await (0, runSafe_js_1.runSafe)(async () => {
|
36
35
|
throw "test error";
|
37
36
|
});
|
38
|
-
|
37
|
+
expect(result).toEqual({
|
39
38
|
ok: false,
|
40
39
|
error: "test error",
|
41
40
|
});
|
42
41
|
});
|
43
|
-
(
|
42
|
+
it("should catch rejected Promise", async () => {
|
44
43
|
const error = new Error("test error");
|
45
44
|
const result = await (0, runSafe_js_1.runSafe)(async () => {
|
46
45
|
return Promise.reject(error);
|
47
46
|
});
|
48
|
-
|
47
|
+
expect(result).toEqual({
|
49
48
|
ok: false,
|
50
49
|
error,
|
51
50
|
});
|
52
51
|
});
|
53
|
-
(
|
52
|
+
it("should not throw error", async () => {
|
54
53
|
const result = await (0, runSafe_js_1.runSafe)(async () => "result");
|
55
|
-
|
54
|
+
expect(result).toEqual({
|
56
55
|
ok: true,
|
57
56
|
value: "result",
|
58
57
|
});
|
package/util/runSafe.test.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import { expect, test } from "vitest";
|
2
1
|
import { runSafe } from "./runSafe.js";
|
3
|
-
|
2
|
+
it("should catch thrown error in sync function", async () => {
|
4
3
|
const error = new Error("test error");
|
5
4
|
const result = await runSafe(() => {
|
6
5
|
throw error;
|
@@ -10,7 +9,7 @@ test("catch thrown error in sync function", async () => {
|
|
10
9
|
error,
|
11
10
|
});
|
12
11
|
});
|
13
|
-
|
12
|
+
it("should catch thrown string in sync function", async () => {
|
14
13
|
const result = await runSafe(() => {
|
15
14
|
throw "test error";
|
16
15
|
});
|
@@ -19,7 +18,7 @@ test("catch thrown string in sync function", async () => {
|
|
19
18
|
error: "test error",
|
20
19
|
});
|
21
20
|
});
|
22
|
-
|
21
|
+
it("should catch thrown error in async function", async () => {
|
23
22
|
const error = new Error("test error");
|
24
23
|
const result = await runSafe(async () => {
|
25
24
|
throw error;
|
@@ -29,7 +28,7 @@ test("catch thrown error in async function", async () => {
|
|
29
28
|
error,
|
30
29
|
});
|
31
30
|
});
|
32
|
-
|
31
|
+
it("should catch thrown string in async function", async () => {
|
33
32
|
const result = await runSafe(async () => {
|
34
33
|
throw "test error";
|
35
34
|
});
|
@@ -38,7 +37,7 @@ test("catch thrown string in async function", async () => {
|
|
38
37
|
error: "test error",
|
39
38
|
});
|
40
39
|
});
|
41
|
-
|
40
|
+
it("should catch rejected Promise", async () => {
|
42
41
|
const error = new Error("test error");
|
43
42
|
const result = await runSafe(async () => {
|
44
43
|
return Promise.reject(error);
|
@@ -48,7 +47,7 @@ test("catch rejected Promise", async () => {
|
|
48
47
|
error,
|
49
48
|
});
|
50
49
|
});
|
51
|
-
|
50
|
+
it("should not throw error", async () => {
|
52
51
|
const result = await runSafe(async () => "result");
|
53
52
|
expect(result).toEqual({
|
54
53
|
ok: true,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getGlobalFunctionLogging = exports.setGlobalFunctionLogging = void 0;
|
4
|
-
let globalFunctionLogging = undefined;
|
5
|
-
function setGlobalFunctionLogging(logLevel) {
|
6
|
-
globalFunctionLogging = logLevel;
|
7
|
-
}
|
8
|
-
exports.setGlobalFunctionLogging = setGlobalFunctionLogging;
|
9
|
-
function getGlobalFunctionLogging() {
|
10
|
-
return globalFunctionLogging;
|
11
|
-
}
|
12
|
-
exports.getGlobalFunctionLogging = getGlobalFunctionLogging;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getGlobalFunctionObservers = exports.setGlobalFunctionObservers = void 0;
|
4
|
-
let globalFunctionObservers = [];
|
5
|
-
function setGlobalFunctionObservers(functionObservers) {
|
6
|
-
globalFunctionObservers = functionObservers;
|
7
|
-
}
|
8
|
-
exports.setGlobalFunctionObservers = setGlobalFunctionObservers;
|
9
|
-
function getGlobalFunctionObservers() {
|
10
|
-
return globalFunctionObservers;
|
11
|
-
}
|
12
|
-
exports.getGlobalFunctionObservers = getGlobalFunctionObservers;
|