summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2023-05-02 19:15:45 +0900
committerGitHub <noreply@github.com>2023-05-02 12:15:45 +0200
commit49eb887cc6325e14211ec4a241ffc4ac98f0f7a9 (patch)
tree8dec27c42c45b8e0bfaa7d4b886546fbdc942b64 /ext
parentcf893741c3206f55eaac1999f50f1018122f7b85 (diff)
refactor(core): Use `ObjectHasOwn` instead of `ObjectPrototypeHasOwnProperty` (#18952)
ES2022 `Object.hasOwn` can be used in snapshot, so I migrate to use it.
Diffstat (limited to 'ext')
-rw-r--r--ext/console/01_console.js12
-rw-r--r--ext/crypto/00_crypto.js6
-rw-r--r--ext/fetch/20_headers.js4
-rw-r--r--ext/ffi/00_ffi.js4
-rw-r--r--ext/node/polyfills/01_require.js4
-rw-r--r--ext/node/polyfills/internal/child_process.ts4
-rw-r--r--ext/node/polyfills/internal/primordials.mjs2
-rw-r--r--ext/webidl/00_webidl.js6
8 files changed, 21 insertions, 21 deletions
diff --git a/ext/console/01_console.js b/ext/console/01_console.js
index 3b2f44917..31431f120 100644
--- a/ext/console/01_console.js
+++ b/ext/console/01_console.js
@@ -68,10 +68,10 @@ const {
ObjectGetOwnPropertyNames,
ObjectGetOwnPropertySymbols,
ObjectGetPrototypeOf,
+ ObjectHasOwn,
ObjectIs,
ObjectKeys,
ObjectPrototype,
- ObjectPrototypeHasOwnProperty,
ObjectPrototypeIsPrototypeOf,
ObjectPrototypePropertyIsEnumerable,
ObjectPrototypeToString,
@@ -710,7 +710,7 @@ function formatValue(
}
function getClassBase(value, constructor, tag) {
- const hasName = ObjectPrototypeHasOwnProperty(value, "name");
+ const hasName = ObjectHasOwn(value, "name");
const name = (hasName && value.name) || "(anonymous)";
let base = `class ${name}`;
if (constructor !== "Function" && constructor !== null) {
@@ -1148,7 +1148,7 @@ function addPrototypeProperties(
// Ignore the `constructor` property and keys that exist on layers above.
if (
key === "constructor" ||
- ObjectPrototypeHasOwnProperty(main, key) ||
+ ObjectHasOwn(main, key) ||
(depth !== 0 && SetPrototypeHas(keySet, key))
) {
continue;
@@ -1315,7 +1315,7 @@ function formatArray(ctx, value, recurseTimes) {
const output = [];
for (let i = 0; i < len; i++) {
// Special handle sparse arrays.
- if (!ObjectPrototypeHasOwnProperty(value, i)) {
+ if (!ObjectHasOwn(value, i)) {
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
}
ArrayPrototypePush(
@@ -2291,7 +2291,7 @@ function hasOwnProperty(obj, v) {
if (obj == null) {
return false;
}
- return ObjectPrototypeHasOwnProperty(obj, v);
+ return ObjectHasOwn(obj, v);
}
// Copyright Joyent, Inc. and other Node contributors. MIT license.
@@ -3603,7 +3603,7 @@ function wrapConsole(consoleFromDeno, consoleFromV8) {
const keys = ObjectKeys(consoleFromV8);
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
- if (ObjectPrototypeHasOwnProperty(consoleFromDeno, key)) {
+ if (ObjectHasOwn(consoleFromDeno, key)) {
consoleFromDeno[key] = FunctionPrototypeBind(
callConsole,
consoleFromDeno,
diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js
index 5be2e0c1c..1008f4cf6 100644
--- a/ext/crypto/00_crypto.js
+++ b/ext/crypto/00_crypto.js
@@ -27,7 +27,7 @@ const {
JSONStringify,
MathCeil,
ObjectAssign,
- ObjectPrototypeHasOwnProperty,
+ ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
SafeArrayIterator,
SafeWeakMap,
@@ -211,7 +211,7 @@ function normalizeAlgorithm(algorithm, op) {
// 5.
let desiredType = undefined;
for (const key in registeredAlgorithms) {
- if (!ObjectPrototypeHasOwnProperty(registeredAlgorithms, key)) {
+ if (!ObjectHasOwn(registeredAlgorithms, key)) {
continue;
}
if (
@@ -246,7 +246,7 @@ function normalizeAlgorithm(algorithm, op) {
const dict = simpleAlgorithmDictionaries[desiredType];
// 10.
for (const member in dict) {
- if (!ObjectPrototypeHasOwnProperty(dict, member)) {
+ if (!ObjectHasOwn(dict, member)) {
continue;
}
const idlType = dict[member];
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js
index 7ec6751fa..89b9e1a2b 100644
--- a/ext/fetch/20_headers.js
+++ b/ext/fetch/20_headers.js
@@ -28,8 +28,8 @@ const {
ArrayPrototypeJoin,
ArrayPrototypeSplice,
ArrayPrototypeFilter,
- ObjectPrototypeHasOwnProperty,
ObjectEntries,
+ ObjectHasOwn,
RegExpPrototypeTest,
SafeArrayIterator,
SafeRegExp,
@@ -79,7 +79,7 @@ function fillHeaders(headers, object) {
}
} else {
for (const key in object) {
- if (!ObjectPrototypeHasOwnProperty(object, key)) {
+ if (!ObjectHasOwn(object, key)) {
continue;
}
appendHeader(headers, key, object[key]);
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index f36690226..2091a55b3 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -10,7 +10,7 @@ const {
ArrayPrototypeJoin,
DataViewPrototypeGetByteLength,
ObjectDefineProperty,
- ObjectPrototypeHasOwnProperty,
+ ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
Number,
NumberIsSafeInteger,
@@ -439,7 +439,7 @@ class DynamicLibrary {
constructor(path, symbols) {
({ 0: this.#rid, 1: this.symbols } = ops.op_ffi_load({ path, symbols }));
for (const symbol in symbols) {
- if (!ObjectPrototypeHasOwnProperty(symbols, symbol)) {
+ if (!ObjectHasOwn(symbols, symbol)) {
continue;
}
diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js
index ce7312ee8..c73701ba8 100644
--- a/ext/node/polyfills/01_require.js
+++ b/ext/node/polyfills/01_require.js
@@ -16,7 +16,7 @@ const {
ArrayPrototypeSplice,
ObjectGetOwnPropertyDescriptor,
ObjectGetPrototypeOf,
- ObjectPrototypeHasOwnProperty,
+ ObjectHasOwn,
ObjectSetPrototypeOf,
ObjectKeys,
ObjectEntries,
@@ -433,7 +433,7 @@ const CircularRequirePrototypeWarningProxy = new Proxy({}, {
getOwnPropertyDescriptor(target, prop) {
if (
- ObjectPrototypeHasOwnProperty(target, prop) || prop === "__esModule"
+ ObjectHasOwn(target, prop) || prop === "__esModule"
) {
return ObjectGetOwnPropertyDescriptor(target, prop);
}
diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts
index 7c72cb0ca..edc4caa5e 100644
--- a/ext/node/polyfills/internal/child_process.ts
+++ b/ext/node/polyfills/internal/child_process.ts
@@ -34,7 +34,7 @@ import {
ArrayPrototypeSlice,
ArrayPrototypeSort,
ArrayPrototypeUnshift,
- ObjectPrototypeHasOwnProperty,
+ ObjectHasOwn,
StringPrototypeToUpperCase,
} from "ext:deno_node/internal/primordials.mjs";
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
@@ -429,7 +429,7 @@ function copyProcessEnvToEnv(
if (
Deno.env.get(name) &&
(!optionEnv ||
- !ObjectPrototypeHasOwnProperty(optionEnv, name))
+ !ObjectHasOwn(optionEnv, name))
) {
env[name] = Deno.env.get(name);
}
diff --git a/ext/node/polyfills/internal/primordials.mjs b/ext/node/polyfills/internal/primordials.mjs
index 1639efdb5..8127eebac 100644
--- a/ext/node/polyfills/internal/primordials.mjs
+++ b/ext/node/polyfills/internal/primordials.mjs
@@ -12,7 +12,7 @@ export const ArrayPrototypeSort = (that, ...args) => that.sort(...args);
export const ArrayPrototypeUnshift = (that, ...args) => that.unshift(...args);
export const ObjectAssign = Object.assign;
export const ObjectCreate = Object.create;
-export const ObjectPrototypeHasOwnProperty = Object.hasOwn;
+export const ObjectHasOwn = Object.hasOwn;
export const RegExpPrototypeTest = (that, ...args) => that.test(...args);
export const RegExpPrototypeExec = RegExp.prototype.exec;
export const StringFromCharCode = String.fromCharCode;
diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js
index 71b7982b7..247ebfe0d 100644
--- a/ext/webidl/00_webidl.js
+++ b/ext/webidl/00_webidl.js
@@ -47,7 +47,7 @@ const {
ObjectGetOwnPropertyDescriptor,
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
- ObjectPrototypeHasOwnProperty,
+ ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
ObjectIs,
PromisePrototypeThen,
@@ -920,7 +920,7 @@ function createRecordConverter(keyConverter, valueConverter) {
// Fast path for common case (not a Proxy)
if (!core.isProxy(V)) {
for (const key in V) {
- if (!ObjectPrototypeHasOwnProperty(V, key)) {
+ if (!ObjectHasOwn(V, key)) {
continue;
}
const typedKey = keyConverter(key, prefix, context, opts);
@@ -1133,7 +1133,7 @@ function mixinPairIterable(name, prototype, dataSymbol, keyKey, valueKey) {
function configurePrototype(prototype) {
const descriptors = ObjectGetOwnPropertyDescriptors(prototype.prototype);
for (const key in descriptors) {
- if (!ObjectPrototypeHasOwnProperty(descriptors, key)) {
+ if (!ObjectHasOwn(descriptors, key)) {
continue;
}
if (key === "constructor") continue;