GeezerVison is showing github.com — benchmark,test: use Object.hasOwn() where applicable · nodejs/node@dcf1ea0
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benchmark/common.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -91,7 +91,7 @@ class Benchmark { | 91 | 91 | process.exit(1); | 92 | 92 | } | 93 | 93 | const [, key, value] = match; | 94 | | - if (Object.prototype.hasOwnProperty.call(configs, key)) { | | 94 | + if (Object.hasOwn(configs, key)) { | 95 | 95 | if (!cliOptions[key]) | 96 | 96 | cliOptions[key] = []; | 97 | 97 | cliOptions[key].push( | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/es/map-bench.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -72,7 +72,7 @@ function fakeMap() { | 72 | 72 | get(key) { return m[`$${key}`]; }, | 73 | 73 | set(key, val) { m[`$${key}`] = val; }, | 74 | 74 | 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}`); } | 76 | 76 | }; | 77 | 77 | } | 78 | 78 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-http2-capture-rejection.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -90,8 +90,7 @@ events.captureRejections = true; | 90 | 90 |
| 91 | 91 | req.on('response', common.mustCall((headers) => { | 92 | 92 | 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); | 95 | 94 | })); | 96 | 95 |
| 97 | 96 | req.on('close', common.mustCall(() => { | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -36,8 +36,8 @@ server.listen(0, common.mustCall(function() { | 36 | 36 | assert.strictEqual(rawHeaders[position + 1], value); | 37 | 37 | } | 38 | 38 |
| 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')); | 41 | 41 |
| 42 | 42 | response.on('finish', common.mustCall(function() { | 43 | 43 | server.close(); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-process-env.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,8 +29,7 @@ if (process.argv[2] === 'you-are-the-child') { | 29 | 29 | assert.strictEqual('NODE_PROCESS_ENV_DELETED' in process.env, false); | 30 | 30 | assert.strictEqual(process.env.NODE_PROCESS_ENV, '42'); | 31 | 31 | 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'); | 34 | 33 | assert.strictEqual(has, true); | 35 | 34 | process.exit(0); | 36 | 35 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-url-properties.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -68,7 +68,7 @@ function testMethod(target, name, methodName = stringifyName(name)) { | 68 | 68 | assert.strictEqual(typeof value, 'function'); | 69 | 69 | assert.strictEqual(value.name, methodName); | 70 | 70 | assert.strictEqual( | 71 | | - Object.prototype.hasOwnProperty.call(value, 'prototype'), | | 71 | + Object.hasOwn(value, 'prototype'), | 72 | 72 | false, | 73 | 73 | ); | 74 | 74 | } | @@ -83,7 +83,7 @@ function testAccessor(target, name, readonly = false) { | 83 | 83 | assert.strictEqual(typeof get, 'function'); | 84 | 84 | assert.strictEqual(get.name, `get ${methodName}`); | 85 | 85 | assert.strictEqual( | 86 | | - Object.prototype.hasOwnProperty.call(get, 'prototype'), | | 86 | + Object.hasOwn(get, 'prototype'), | 87 | 87 | false, | 88 | 88 | ); | 89 | 89 |
| @@ -93,7 +93,7 @@ function testAccessor(target, name, readonly = false) { | 93 | 93 | assert.strictEqual(typeof set, 'function'); | 94 | 94 | assert.strictEqual(set.name, `set ${methodName}`); | 95 | 95 | assert.strictEqual( | 96 | | - Object.prototype.hasOwnProperty.call(set, 'prototype'), | | 96 | + Object.hasOwn(set, 'prototype'), | 97 | 97 | false, | 98 | 98 | ); | 99 | 99 | } | |
|