@tstdl/base 0.90.76 → 0.90.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.90.76",
3
+ "version": "0.90.77",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -131,7 +131,7 @@
131
131
  "typedoc": "0.25",
132
132
  "typedoc-plugin-missing-exports": "2.2",
133
133
  "typescript": "5.4",
134
- "typescript-eslint": "7.8"
134
+ "typescript-eslint": "7.9"
135
135
  },
136
136
  "peerDependencies": {
137
137
  "@elastic/elasticsearch": "^8.13",
@@ -149,9 +149,9 @@
149
149
  "mongodb": "^6.6",
150
150
  "nodemailer": "^6.9",
151
151
  "playwright": "^1.44",
152
- "preact": "^10.21",
152
+ "preact": "^10.22",
153
153
  "preact-render-to-string": "^6.4",
154
- "undici": "^6.15",
154
+ "undici": "^6.16",
155
155
  "urlpattern-polyfill": "^10.0"
156
156
  },
157
157
  "peerDependenciesMeta": {
package/utils/equals.d.ts CHANGED
@@ -19,6 +19,7 @@ export type EqualsOptions = {
19
19
  arrayDeep?: boolean;
20
20
  sortArray?: boolean;
21
21
  coerceStrings?: boolean;
22
+ checkPrototype?: boolean;
22
23
  };
23
24
  export declare function equals(a: any, b: any, options?: EqualsOptions): boolean;
24
25
  export declare function equals(a: any, b: any, options?: EqualsOptions, __internal?: any): boolean;
package/utils/equals.js CHANGED
@@ -3,6 +3,7 @@ import { toArray } from './array/array.js';
3
3
  import { toUint8Array } from './binary.js';
4
4
  import { compareByValue } from './comparison.js';
5
5
  import { sort } from './iterable-helpers/sort.js';
6
+ import { objectKeys } from './object/object.js';
6
7
  import { isDefined, isNotNull, isNull } from './type-guards.js';
7
8
  const equalsSymbol = Symbol('equals');
8
9
  // eslint-disable-next-line @typescript-eslint/no-redeclare, @typescript-eslint/naming-convention
@@ -56,9 +57,10 @@ export function equals(a, b, options = {}, visitedNodes = new Set()) {
56
57
  }
57
58
  visitedNodes.add(a);
58
59
  const aPrototype = Object.getPrototypeOf(a);
59
- const bPrototype = Object.getPrototypeOf(b);
60
- if (aPrototype !== bPrototype) {
61
- return false;
60
+ if (options.checkPrototype != false) {
61
+ if (aPrototype !== Object.getPrototypeOf(b)) {
62
+ return false;
63
+ }
62
64
  }
63
65
  if (Array.isArray(a)) {
64
66
  return (options.arrayDeep != false && (options.deep == true || options.arrayDeep == true))
@@ -71,7 +73,7 @@ export function equals(a, b, options = {}, visitedNodes = new Set()) {
71
73
  if (Equals.symbol in b) {
72
74
  return b[Equals.symbol](a);
73
75
  }
74
- if ((aPrototype != Object.prototype) && isNotNull(aPrototype)) { // Checking a is enough, because b must have equal prototype (checked above)
76
+ if ((options.checkPrototype != false) && (aPrototype != Object.prototype) && isNotNull(aPrototype)) { // Checking a is enough, because b must have equal prototype (checked above)
75
77
  throw new Error('Equals only supports literal objects, arrays, primitives and Equals interface implementations.');
76
78
  }
77
79
  if (options.deep == false) {
@@ -85,8 +87,8 @@ export function equals(a, b, options = {}, visitedNodes = new Set()) {
85
87
  }
86
88
  // eslint-disable-next-line max-statements, max-lines-per-function
87
89
  function objectEquals(a, b, options, visitedNodes) {
88
- const aProperties = Object.getOwnPropertyNames(a);
89
- const bProperties = Object.getOwnPropertyNames(b);
90
+ const aProperties = objectKeys(a);
91
+ const bProperties = objectKeys(b);
90
92
  if (!arrayEquals(aProperties, bProperties, { sort: compareByValue })) {
91
93
  return false;
92
94
  }