Skip to content

Commit

Permalink
Update compatibility.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
crStiv authored Feb 25, 2025
1 parent 25d967a commit 79b21ee
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/json-rpc/src/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ export function isJsonCompatibleArray(value: unknown): value is JsonCompatibleAr
return true;
}

export function isJsonCompatibleDictionary(data: unknown): data is JsonCompatibleDictionary {
if (typeof data !== "object" || data === null) {
// data must be a non-null object
export function isJsonCompatibleDictionary(value: unknown): value is JsonCompatibleDictionary {
if (typeof value !== "object" || value === null) {
// value must be a non-null object
return false;
}

// Exclude special kind of objects like Array, Date or Uint8Array
// Object.prototype.toString() returns a specified value:
// http://www.ecma-international.org/ecma-262/7.0/index.html#sec-object.prototype.tostring
if (Object.prototype.toString.call(data) !== "[object Object]") {
if (Object.prototype.toString.call(value) !== "[object Object]") {
return false;
}

return Object.values(data).every(isJsonCompatibleValue);
return Object.values(value).every(isJsonCompatibleValue);
}

0 comments on commit 79b21ee

Please sign in to comment.