modelfusion 0.92.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.
Files changed (30) hide show
  1. package/core/api/ApiCallError.cjs +9 -1
  2. package/core/api/ApiCallError.d.ts +4 -1
  3. package/core/api/ApiCallError.js +9 -1
  4. package/model-provider/ollama/OllamaError.cjs +25 -24
  5. package/model-provider/ollama/OllamaError.d.ts +1 -11
  6. package/model-provider/ollama/OllamaError.js +24 -22
  7. package/model-provider/ollama/OllamaTextGenerationModel.cjs +38 -1
  8. package/model-provider/ollama/OllamaTextGenerationModel.d.ts +5 -1
  9. package/model-provider/ollama/OllamaTextGenerationModel.js +39 -2
  10. package/model-provider/ollama/OllamaTextGenerationModel.test.cjs +63 -0
  11. package/model-provider/ollama/OllamaTextGenerationModel.test.d.ts +1 -0
  12. package/model-provider/ollama/OllamaTextGenerationModel.test.js +61 -0
  13. package/model-provider/ollama/index.cjs +1 -3
  14. package/model-provider/ollama/index.d.ts +1 -1
  15. package/model-provider/ollama/index.js +0 -1
  16. package/model-provider/openai/OpenAIError.cjs +13 -29
  17. package/model-provider/openai/OpenAIError.d.ts +2 -11
  18. package/model-provider/openai/OpenAIError.js +11 -26
  19. package/model-provider/openai/index.cjs +1 -3
  20. package/model-provider/openai/index.d.ts +1 -1
  21. package/model-provider/openai/index.js +0 -1
  22. package/model-provider/whispercpp/WhisperCppTranscriptionModel.cjs +5 -8
  23. package/model-provider/whispercpp/WhisperCppTranscriptionModel.js +5 -8
  24. package/package.json +5 -4
  25. package/util/AsyncQueue.test.cjs +20 -21
  26. package/util/AsyncQueue.test.js +9 -10
  27. package/util/isDeepEqualData.test.cjs +14 -15
  28. package/util/isDeepEqualData.test.js +14 -15
  29. package/util/runSafe.test.cjs +12 -13
  30. package/util/runSafe.test.js +6 -7
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { ApiCallError } from "../../core/api/ApiCallError.js";
3
3
  import { ZodSchema } from "../../core/schema/ZodSchema.js";
4
4
  import { parseJSON } from "../../core/schema/parseJSON.js";
5
- export const openAIErrorDataSchema = new ZodSchema(z.object({
5
+ const openAIErrorDataSchema = new ZodSchema(z.object({
6
6
  error: z.object({
7
7
  message: z.string(),
8
8
  type: z.string(),
@@ -10,27 +10,6 @@ export const openAIErrorDataSchema = new ZodSchema(z.object({
10
10
  code: z.string().nullable(),
11
11
  }),
12
12
  }));
13
- export class OpenAIError extends ApiCallError {
14
- constructor({ data, statusCode, url, requestBodyValues, message, }) {
15
- super({
16
- message,
17
- statusCode,
18
- requestBodyValues,
19
- url,
20
- isRetryable: (statusCode === 429 &&
21
- // insufficient_quota is also reported as a 429, but it's not retryable:
22
- data?.error.type !== "insufficient_quota") ||
23
- statusCode >= 500,
24
- });
25
- Object.defineProperty(this, "data", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: void 0
30
- });
31
- this.data = data;
32
- }
33
- }
34
13
  export const failedOpenAICallResponseHandler = async ({ response, url, requestBodyValues }) => {
35
14
  const responseBody = await response.text();
36
15
  // resilient parsing in case the response is not JSON or does not match the schema:
@@ -39,20 +18,26 @@ export const failedOpenAICallResponseHandler = async ({ response, url, requestBo
39
18
  text: responseBody,
40
19
  schema: openAIErrorDataSchema,
41
20
  });
42
- return new OpenAIError({
21
+ return new ApiCallError({
22
+ message: parsedError.error.message,
43
23
  url,
44
24
  requestBodyValues,
45
25
  statusCode: response.status,
46
- message: parsedError.error.message,
26
+ responseBody,
47
27
  data: parsedError,
28
+ isRetryable: (response.status === 429 &&
29
+ // insufficient_quota is also reported as a 429, but it's not retryable:
30
+ parsedError?.error.type !== "insufficient_quota") ||
31
+ response.status >= 500,
48
32
  });
49
33
  }
50
34
  catch (parseError) {
51
- return new OpenAIError({
35
+ return new ApiCallError({
36
+ message: responseBody.trim() !== "" ? responseBody : response.statusText,
52
37
  url,
53
38
  requestBodyValues,
54
39
  statusCode: response.status,
55
- message: responseBody.trim() !== "" ? responseBody : response.statusText,
40
+ responseBody,
56
41
  });
57
42
  }
58
43
  };
@@ -26,13 +26,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.OpenAIChatPromptFormat = exports.openai = exports.OpenAIError = void 0;
29
+ exports.OpenAIChatPromptFormat = exports.openai = void 0;
30
30
  __exportStar(require("./AzureOpenAIApiConfiguration.cjs"), exports);
31
31
  __exportStar(require("./OpenAIApiConfiguration.cjs"), exports);
32
32
  __exportStar(require("./OpenAICompletionModel.cjs"), exports);
33
33
  __exportStar(require("./OpenAICostCalculator.cjs"), exports);
34
- var OpenAIError_js_1 = require("./OpenAIError.cjs");
35
- Object.defineProperty(exports, "OpenAIError", { enumerable: true, get: function () { return OpenAIError_js_1.OpenAIError; } });
36
34
  exports.openai = __importStar(require("./OpenAIFacade.cjs"));
37
35
  __exportStar(require("./OpenAIImageGenerationModel.cjs"), exports);
38
36
  __exportStar(require("./OpenAISpeechModel.cjs"), exports);
@@ -2,7 +2,7 @@ export * from "./AzureOpenAIApiConfiguration.js";
2
2
  export * from "./OpenAIApiConfiguration.js";
3
3
  export * from "./OpenAICompletionModel.js";
4
4
  export * from "./OpenAICostCalculator.js";
5
- export { OpenAIError, OpenAIErrorData } from "./OpenAIError.js";
5
+ export { OpenAIErrorData } from "./OpenAIError.js";
6
6
  export * as openai from "./OpenAIFacade.js";
7
7
  export * from "./OpenAIImageGenerationModel.js";
8
8
  export * from "./OpenAISpeechModel.js";
@@ -2,7 +2,6 @@ export * from "./AzureOpenAIApiConfiguration.js";
2
2
  export * from "./OpenAIApiConfiguration.js";
3
3
  export * from "./OpenAICompletionModel.js";
4
4
  export * from "./OpenAICostCalculator.js";
5
- export { OpenAIError } from "./OpenAIError.js";
6
5
  export * as openai from "./OpenAIFacade.js";
7
6
  export * from "./OpenAIImageGenerationModel.js";
8
7
  export * from "./OpenAISpeechModel.js";
@@ -72,15 +72,12 @@ class WhisperCppTranscriptionModel extends AbstractModel_js_1.AbstractModel {
72
72
  }
73
73
  }
74
74
  exports.WhisperCppTranscriptionModel = WhisperCppTranscriptionModel;
75
- const whisperCppTranscriptionJsonSchema = zod_1.z.union([
76
- zod_1.z.object({ text: zod_1.z.string() }),
77
- zod_1.z.object({ error: zod_1.z.string() }),
78
- ]);
75
+ const whisperCppTranscriptionJsonSchema = new ZodSchema_js_1.ZodSchema(zod_1.z.union([zod_1.z.object({ text: zod_1.z.string() }), zod_1.z.object({ error: zod_1.z.string() })]));
79
76
  const successfulResponseHandler = async ({ response, url, requestBodyValues }) => {
80
77
  const responseBody = await response.text();
81
78
  const parsedResult = (0, parseJSON_js_1.safeParseJSON)({
82
79
  text: responseBody,
83
- schema: new ZodSchema_js_1.ZodSchema(whisperCppTranscriptionJsonSchema),
80
+ schema: whisperCppTranscriptionJsonSchema,
84
81
  });
85
82
  if (!parsedResult.success) {
86
83
  throw new ApiCallError_js_1.ApiCallError({
@@ -106,12 +103,12 @@ const successfulResponseHandler = async ({ response, url, requestBodyValues }) =
106
103
  };
107
104
  };
108
105
  const failedResponseHandler = async ({ response, url, requestBodyValues, }) => {
109
- const message = await response.text();
106
+ const responseBody = await response.text();
110
107
  return new ApiCallError_js_1.ApiCallError({
111
- message,
108
+ message: responseBody,
112
109
  url,
113
110
  requestBodyValues,
114
111
  statusCode: response.status,
115
- responseBody: message,
112
+ responseBody,
116
113
  });
117
114
  };
@@ -68,15 +68,12 @@ export class WhisperCppTranscriptionModel extends AbstractModel {
68
68
  return new WhisperCppTranscriptionModel(Object.assign({}, this.settings, additionalSettings));
69
69
  }
70
70
  }
71
- const whisperCppTranscriptionJsonSchema = z.union([
72
- z.object({ text: z.string() }),
73
- z.object({ error: z.string() }),
74
- ]);
71
+ const whisperCppTranscriptionJsonSchema = new ZodSchema(z.union([z.object({ text: z.string() }), z.object({ error: z.string() })]));
75
72
  const successfulResponseHandler = async ({ response, url, requestBodyValues }) => {
76
73
  const responseBody = await response.text();
77
74
  const parsedResult = safeParseJSON({
78
75
  text: responseBody,
79
- schema: new ZodSchema(whisperCppTranscriptionJsonSchema),
76
+ schema: whisperCppTranscriptionJsonSchema,
80
77
  });
81
78
  if (!parsedResult.success) {
82
79
  throw new ApiCallError({
@@ -102,12 +99,12 @@ const successfulResponseHandler = async ({ response, url, requestBodyValues }) =
102
99
  };
103
100
  };
104
101
  const failedResponseHandler = async ({ response, url, requestBodyValues, }) => {
105
- const message = await response.text();
102
+ const responseBody = await response.text();
106
103
  return new ApiCallError({
107
- message,
104
+ message: responseBody,
108
105
  url,
109
106
  requestBodyValues,
110
107
  statusCode: response.status,
111
- responseBody: message,
108
+ responseBody,
112
109
  });
113
110
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "The TypeScript library for building multi-modal AI applications.",
4
- "version": "0.92.0",
4
+ "version": "0.92.1",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -62,8 +62,8 @@
62
62
  "build": "npm run build:esm && npm run build:cjs",
63
63
  "build:esm": "tsc --outDir dist/",
64
64
  "build:cjs": "tsc --outDir build/cjs/ -p tsconfig.cjs.json && node bin/prepare-cjs.js",
65
- "test": "vitest run src",
66
- "test-interactive": "vitest watch",
65
+ "test": "vitest --config vitest.config.js --run src",
66
+ "test:watch": "vitest watch--config vitest.config.js",
67
67
  "dist": "npm run clean && npm run lint && npm run test && npm run build && npm run dist:copy-files",
68
68
  "dist:copy-files": "copyfiles package.json README.md LICENSE dist"
69
69
  },
@@ -87,9 +87,10 @@
87
87
  "fastify": "^4.0.0",
88
88
  "husky": "^8.0.3",
89
89
  "lint-staged": "15.1.0",
90
+ "msw": "2.0.10",
90
91
  "prettier": "3.1.0",
91
92
  "rimraf": "5.0.5",
92
93
  "typescript": "5.2.2",
93
- "vitest": "^0.34.5"
94
+ "vitest": "1.0.4"
94
95
  }
95
96
  }
@@ -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
- (0, vitest_1.test)("receive values in order for single iterator created before pushing", async () => {
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
- (0, vitest_1.expect)(receivedValues).toEqual([1, 2, 3]);
18
+ expect(receivedValues).toEqual([1, 2, 3]);
20
19
  });
21
- (0, vitest_1.test)("receive values in order for single iterator created after closing", async () => {
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
- (0, vitest_1.expect)(receivedValues).toEqual([1, 2, 3]);
33
+ expect(receivedValues).toEqual([1, 2, 3]);
35
34
  });
36
- (0, vitest_1.test)("handle delayed pushing", async () => {
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
- (0, vitest_1.expect)(receivedValues).toEqual([1, 2]);
46
+ expect(receivedValues).toEqual([1, 2]);
48
47
  });
49
- (0, vitest_1.test)("error handling in consumer", async () => {
48
+ it("should error handling in consumer", async () => {
50
49
  const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
51
50
  asyncQueue.push(1);
52
- await (0, vitest_1.expect)((async () => {
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
- (0, vitest_1.expect)(receivedValues).toEqual([1, 2]);
64
+ expect(receivedValues).toEqual([1, 2]);
66
65
  });
67
- (0, vitest_1.test)("behavior on empty queue closing", async () => {
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
- (0, vitest_1.expect)(receivedValues).toEqual([]);
73
+ expect(receivedValues).toEqual([]);
75
74
  });
76
- (0, vitest_1.test)("multiple closings", async () => {
75
+ it("should multiple closings", async () => {
77
76
  const asyncQueue = new AsyncQueue_js_1.AsyncQueue();
78
77
  asyncQueue.close();
79
- (0, vitest_1.expect)(() => asyncQueue.close()).not.toThrow();
78
+ expect(() => asyncQueue.close()).not.toThrow();
80
79
  });
81
- (0, vitest_1.test)("receive all values in multiple independent consumers", async () => {
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
- (0, vitest_1.expect)(receivedValues).toEqual([1, 2, 3]);
99
+ expect(receivedValues).toEqual([1, 2, 3]);
101
100
  });
102
101
  });
103
- (0, vitest_1.test)("each consumer receives all pushed values under varying conditions", async () => {
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
- (0, vitest_1.expect)(receivedValues1).toEqual([1, 2, 3]);
132
- (0, vitest_1.expect)(receivedValues2).toEqual([1, 2, 3]); // This will likely fail because consumer2 started late.
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
- (0, vitest_1.test)("throw error when pushing to a closed queue", async () => {
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
- (0, vitest_1.expect)(() => asyncQueue.push(1)).toThrowError("Cannot push value to closed queue.");
136
+ expect(() => asyncQueue.push(1)).toThrowError("Cannot push value to closed queue.");
138
137
  });
@@ -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
- test("receive values in order for single iterator created before pushing", async () => {
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
- test("receive values in order for single iterator created after closing", async () => {
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
- test("handle delayed pushing", async () => {
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
- test("error handling in consumer", async () => {
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
- test("behavior on empty queue closing", async () => {
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
- test("multiple closings", async () => {
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
- test("receive all values in multiple independent consumers", async () => {
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
- test("each consumer receives all pushed values under varying conditions", async () => {
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
- test("throw error when pushing to a closed queue", async () => {
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
- (0, vitest_1.test)("checks if two primitives are equal", async () => {
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
- (0, vitest_1.test)("returns false for different types", async () => {
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
- (0, vitest_1.test)("returns false for null values compared with objects", async () => {
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
- (0, vitest_1.test)("identifies two equal objects", async () => {
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
- (0, vitest_1.test)("identifies two objects with different values", async () => {
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
- (0, vitest_1.test)("identifies two objects with different number of keys", async () => {
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
- (0, vitest_1.test)("handles nested objects", async () => {
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
- (0, vitest_1.test)("detects inequality in nested objects", async () => {
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
- (0, vitest_1.test)("compares arrays correctly", async () => {
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
- (0, vitest_1.test)("returns false for null comparison with object", () => {
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
- (0, vitest_1.test)("distinguishes between array and object with same enumerable properties", () => {
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
- (0, vitest_1.test)("returns false when comparing objects with different prototypes", () => {
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
- (0, vitest_1.test)("handles date object comparisons correctly", () => {
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
- (0, vitest_1.test)("handles function comparisons", () => {
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
- test("checks if two primitives are equal", async () => {
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
- test("returns false for different types", async () => {
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
- test("returns false for null values compared with objects", async () => {
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
- test("identifies two equal objects", async () => {
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
- test("identifies two objects with different values", async () => {
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
- test("identifies two objects with different number of keys", async () => {
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
- test("handles nested objects", async () => {
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
- test("detects inequality in nested objects", async () => {
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
- test("compares arrays correctly", async () => {
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
- test("returns false for null comparison with object", () => {
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
- test("distinguishes between array and object with same enumerable properties", () => {
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
- test("returns false when comparing objects with different prototypes", () => {
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
- test("handles date object comparisons correctly", () => {
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
- test("handles function comparisons", () => {
90
+ it("should handle function comparisons", () => {
92
91
  const func1 = () => {
93
92
  console.log("hello");
94
93
  };