Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Rename parameter 'data' to 'value' in isJsonCompatibleDictionary for consistency #1630

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}