Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dcf1ea0

Browse filesBrowse files
Trotttargos
authored andcommitted
benchmark,test: use Object.hasOwn() where applicable
Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn PR-URL: #41229 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent e457ec0 commit dcf1ea0
Copy full SHA for dcf1ea0

File tree

Expand file treeCollapse file tree

6 files changed

+9
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+9
-11
lines changed
Open diff view settings
Collapse file

‎benchmark/common.js‎

Copy file name to clipboardExpand all lines: benchmark/common.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Benchmark {
9191
process.exit(1);
9292
}
9393
const [, key, value] = match;
94-
if (Object.prototype.hasOwnProperty.call(configs, key)) {
94+
if (Object.hasOwn(configs, key)) {
9595
if (!cliOptions[key])
9696
cliOptions[key] = [];
9797
cliOptions[key].push(
Collapse file

‎benchmark/es/map-bench.js‎

Copy file name to clipboardExpand all lines: benchmark/es/map-bench.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function fakeMap() {
7272
get(key) { return m[`$${key}`]; },
7373
set(key, val) { m[`$${key}`] = val; },
7474
get size() { return Object.keys(m).length; },
75-
has(key) { return Object.prototype.hasOwnProperty.call(m, `$${key}`); }
75+
has(key) { return Object.hasOwn(m, `$${key}`); }
7676
};
7777
}
7878

Collapse file

‎test/parallel/test-http2-capture-rejection.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-capture-rejection.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ events.captureRejections = true;
9090

9191
req.on('response', common.mustCall((headers) => {
9292
assert.strictEqual(headers[':status'], 500);
93-
assert.strictEqual(Object.hasOwnProperty.call(headers, 'content-type'),
94-
false);
93+
assert.strictEqual(Object.hasOwn(headers, 'content-type'), false);
9594
}));
9695

9796
req.on('close', common.mustCall(() => {
Collapse file

‎test/parallel/test-http2-compat-serverrequest-host.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-compat-serverrequest-host.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ server.listen(0, common.mustCall(function() {
3636
assert.strictEqual(rawHeaders[position + 1], value);
3737
}
3838

39-
assert(!Object.hasOwnProperty.call(headers, ':authority'));
40-
assert(!Object.hasOwnProperty.call(rawHeaders, ':authority'));
39+
assert(!Object.hasOwn(headers, ':authority'));
40+
assert(!Object.hasOwn(rawHeaders, ':authority'));
4141

4242
response.on('finish', common.mustCall(function() {
4343
server.close();
Collapse file

‎test/parallel/test-process-env.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-process-env.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ if (process.argv[2] === 'you-are-the-child') {
2929
assert.strictEqual('NODE_PROCESS_ENV_DELETED' in process.env, false);
3030
assert.strictEqual(process.env.NODE_PROCESS_ENV, '42');
3131
assert.strictEqual(process.env.hasOwnProperty, 'asdf');
32-
const hasOwnProperty = Object.prototype.hasOwnProperty;
33-
const has = hasOwnProperty.call(process.env, 'hasOwnProperty');
32+
const has = Object.hasOwn(process.env, 'hasOwnProperty');
3433
assert.strictEqual(has, true);
3534
process.exit(0);
3635
}
Collapse file

‎test/parallel/test-whatwg-url-properties.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-url-properties.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function testMethod(target, name, methodName = stringifyName(name)) {
6868
assert.strictEqual(typeof value, 'function');
6969
assert.strictEqual(value.name, methodName);
7070
assert.strictEqual(
71-
Object.prototype.hasOwnProperty.call(value, 'prototype'),
71+
Object.hasOwn(value, 'prototype'),
7272
false,
7373
);
7474
}
@@ -83,7 +83,7 @@ function testAccessor(target, name, readonly = false) {
8383
assert.strictEqual(typeof get, 'function');
8484
assert.strictEqual(get.name, `get ${methodName}`);
8585
assert.strictEqual(
86-
Object.prototype.hasOwnProperty.call(get, 'prototype'),
86+
Object.hasOwn(get, 'prototype'),
8787
false,
8888
);
8989

@@ -93,7 +93,7 @@ function testAccessor(target, name, readonly = false) {
9393
assert.strictEqual(typeof set, 'function');
9494
assert.strictEqual(set.name, `set ${methodName}`);
9595
assert.strictEqual(
96-
Object.prototype.hasOwnProperty.call(set, 'prototype'),
96+
Object.hasOwn(set, 'prototype'),
9797
false,
9898
);
9999
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.