| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cb362a3 commit 639130e
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,7 @@ function _validateContent(report, fields = []) { | |||
| 69 | 69 | ||
| 70 | 70 | checkForUnknownFields(report, sections); | |
| 71 | 71 | sections.forEach((section) => { | |
| 72 | - assert(report.hasOwnProperty(section)); | ||
| 72 | + assert(Object.hasOwn(report, section)); | ||
| 73 | 73 | assert(typeof report[section] === 'object' && report[section] !== null); | |
| 74 | 74 | }); | |
| 75 | 75 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,7 @@ for (const version of versions) { | |||
| 51 | 51 | assert.strictEqual(parts[parts.length - 1], 'x', | |
| 52 | 52 | `'num' from ${tested} doesn't end in '.x'.`); | |
| 53 | 53 | const isEvenRelease = Number.parseInt(parts[expectedLength - 2]) % 2 === 0; | |
| 54 | - const hasLtsProperty = version.hasOwnProperty('lts'); | ||
| 54 | + const hasLtsProperty = Object.hasOwn(version, 'lts'); | ||
| 55 | 55 | if (hasLtsProperty) { | |
| 56 | 56 | // Odd-numbered versions of Node.js are never LTS. | |
| 57 | 57 | assert.ok(isEvenRelease, `${tested} should not be an 'lts' release.`); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,7 +78,7 @@ child.spawn({ | |||
| 78 | 78 | stdio: 'pipe' | |
| 79 | 79 | }); | |
| 80 | 80 | ||
| 81 | - assert.strictEqual(child.hasOwnProperty('pid'), true); | ||
| 81 | + assert.strictEqual(Object.hasOwn(child, 'pid'), true); | ||
| 82 | 82 | assert(Number.isInteger(child.pid)); | |
| 83 | 83 | ||
| 84 | 84 | // Try killing with invalid signal | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,9 +18,9 @@ assert.throws(() => getValidStdio(600), expectedError); | |||
| 18 | 18 | const stdio1 = []; | |
| 19 | 19 | const result = getValidStdio(stdio1, false); | |
| 20 | 20 | assert.strictEqual(stdio1.length, 3); | |
| 21 | - assert.strictEqual(result.hasOwnProperty('stdio'), true); | ||
| 22 | - assert.strictEqual(result.hasOwnProperty('ipc'), true); | ||
| 23 | - assert.strictEqual(result.hasOwnProperty('ipcFd'), true); | ||
| 21 | + assert.strictEqual(Object.hasOwn(result, 'stdio'), true); | ||
| 22 | + assert.strictEqual(Object.hasOwn(result, 'ipc'), true); | ||
| 23 | + assert.strictEqual(Object.hasOwn(result, 'ipcFd'), true); | ||
| 24 | 24 | } | |
| 25 | 25 | ||
| 26 | 26 | // Should throw if stdio has ipc and sync is true | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,7 +131,7 @@ if (cluster.isWorker) { | |||
| 131 | 131 | assert.strictEqual(Object.keys(arguments[0]).length, 4); | |
| 132 | 132 | assert.strictEqual(arguments[0].address, '127.0.0.1'); | |
| 133 | 133 | assert.strictEqual(arguments[0].addressType, 4); | |
| 134 | - assert(arguments[0].hasOwnProperty('fd')); | ||
| 134 | + assert(Object.hasOwn(arguments[0], 'fd')); | ||
| 135 | 135 | assert.strictEqual(arguments[0].fd, undefined); | |
| 136 | 136 | const port = arguments[0].port; | |
| 137 | 137 | assert(Number.isInteger(port)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,7 +72,7 @@ function primary() { | |||
| 72 | 72 | // Set up event handlers for every worker. Each worker sends a message when | |
| 73 | 73 | // it has received the expected number of packets. After that it disconnects. | |
| 74 | 74 | for (const key in cluster.workers) { | |
| 75 | - if (cluster.workers.hasOwnProperty(key)) | ||
| 75 | + if (Object.hasOwn(cluster.workers, key)) | ||
| 76 | 76 | setupWorker(cluster.workers[key]); | |
| 77 | 77 | } | |
| 78 | 78 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,7 +63,7 @@ function primary() { | |||
| 63 | 63 | // Set up event handlers for every worker. Each worker sends a message when | |
| 64 | 64 | // it has received the expected number of packets. After that it disconnects. | |
| 65 | 65 | for (const key in cluster.workers) { | |
| 66 | - if (cluster.workers.hasOwnProperty(key)) | ||
| 66 | + if (Object.hasOwn(cluster.workers, key)) | ||
| 67 | 67 | setupWorker(cluster.workers[key]); | |
| 68 | 68 | } | |
| 69 | 69 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,14 +9,14 @@ const { Worker, isMainThread } = require('worker_threads'); | |||
| 9 | 9 | ||
| 10 | 10 | // eslint-disable-next-line no-proto | |
| 11 | 11 | assert.strictEqual(Object.prototype.__proto__, undefined); | |
| 12 | - assert(!Object.prototype.hasOwnProperty('__proto__')); | ||
| 12 | + assert(!Object.hasOwn(Object.prototype, '__proto__')); | ||
| 13 | 13 | ||
| 14 | 14 | const ctx = vm.createContext(); | |
| 15 | 15 | const ctxGlobal = vm.runInContext('this', ctx); | |
| 16 | 16 | ||
| 17 | 17 | // eslint-disable-next-line no-proto | |
| 18 | 18 | assert.strictEqual(ctxGlobal.Object.prototype.__proto__, undefined); | |
| 19 | - assert(!ctxGlobal.Object.prototype.hasOwnProperty('__proto__')); | ||
| 19 | + assert(!Object.hasOwn(ctxGlobal.Object.prototype, '__proto__')); | ||
| 20 | 20 | ||
| 21 | 21 | if (isMainThread) { | |
| 22 | 22 | new Worker(__filename); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ const assert = require('assert'); | |||
| 7 | 7 | const vm = require('vm'); | |
| 8 | 8 | const { Worker, isMainThread } = require('worker_threads'); | |
| 9 | 9 | ||
| 10 | - assert(Object.prototype.hasOwnProperty('__proto__')); | ||
| 10 | + assert(Object.hasOwn(Object.prototype, '__proto__')); | ||
| 11 | 11 | ||
| 12 | 12 | assert.throws(() => { | |
| 13 | 13 | // eslint-disable-next-line no-proto,no-unused-expressions | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,40 +32,40 @@ const events = require('events'); | |||
| 32 | 32 | for (let i = 0; i < 10; i++) { | |
| 33 | 33 | e.on('default', common.mustNotCall()); | |
| 34 | 34 | } | |
| 35 | - assert.ok(!e._events.default.hasOwnProperty('warned')); | ||
| 35 | + assert.ok(!Object.hasOwn(e._events.default, 'warned')); | ||
| 36 | 36 | e.on('default', common.mustNotCall()); | |
| 37 | 37 | assert.ok(e._events.default.warned); | |
| 38 | 38 | ||
| 39 | 39 | // symbol | |
| 40 | 40 | const symbol = Symbol('symbol'); | |
| 41 | 41 | e.setMaxListeners(1); | |
| 42 | 42 | e.on(symbol, common.mustNotCall()); | |
| 43 | - assert.ok(!e._events[symbol].hasOwnProperty('warned')); | ||
| 43 | + assert.ok(!Object.hasOwn(e._events[symbol], 'warned')); | ||
| 44 | 44 | e.on(symbol, common.mustNotCall()); | |
| 45 | - assert.ok(e._events[symbol].hasOwnProperty('warned')); | ||
| 45 | + assert.ok(Object.hasOwn(e._events[symbol], 'warned')); | ||
| 46 | 46 | ||
| 47 | 47 | // specific | |
| 48 | 48 | e.setMaxListeners(5); | |
| 49 | 49 | for (let i = 0; i < 5; i++) { | |
| 50 | 50 | e.on('specific', common.mustNotCall()); | |
| 51 | 51 | } | |
| 52 | - assert.ok(!e._events.specific.hasOwnProperty('warned')); | ||
| 52 | + assert.ok(!Object.hasOwn(e._events.specific, 'warned')); | ||
| 53 | 53 | e.on('specific', common.mustNotCall()); | |
| 54 | 54 | assert.ok(e._events.specific.warned); | |
| 55 | 55 | ||
| 56 | 56 | // only one | |
| 57 | 57 | e.setMaxListeners(1); | |
| 58 | 58 | e.on('only one', common.mustNotCall()); | |
| 59 | - assert.ok(!e._events['only one'].hasOwnProperty('warned')); | ||
| 59 | + assert.ok(!Object.hasOwn(e._events['only one'], 'warned')); | ||
| 60 | 60 | e.on('only one', common.mustNotCall()); | |
| 61 | - assert.ok(e._events['only one'].hasOwnProperty('warned')); | ||
| 61 | + assert.ok(Object.hasOwn(e._events['only one'], 'warned')); | ||
| 62 | 62 | ||
| 63 | 63 | // unlimited | |
| 64 | 64 | e.setMaxListeners(0); | |
| 65 | 65 | for (let i = 0; i < 1000; i++) { | |
| 66 | 66 | e.on('unlimited', common.mustNotCall()); | |
| 67 | 67 | } | |
| 68 | - assert.ok(!e._events.unlimited.hasOwnProperty('warned')); | ||
| 68 | + assert.ok(!Object.hasOwn(e._events.unlimited, 'warned')); | ||
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | 71 | // process-wide | |
@@ -76,16 +76,16 @@ const events = require('events'); | |||
| 76 | 76 | for (let i = 0; i < 42; ++i) { | |
| 77 | 77 | e.on('fortytwo', common.mustNotCall()); | |
| 78 | 78 | } | |
| 79 | - assert.ok(!e._events.fortytwo.hasOwnProperty('warned')); | ||
| 79 | + assert.ok(!Object.hasOwn(e._events.fortytwo, 'warned')); | ||
| 80 | 80 | e.on('fortytwo', common.mustNotCall()); | |
| 81 | - assert.ok(e._events.fortytwo.hasOwnProperty('warned')); | ||
| 81 | + assert.ok(Object.hasOwn(e._events.fortytwo, 'warned')); | ||
| 82 | 82 | delete e._events.fortytwo.warned; | |
| 83 | 83 | ||
| 84 | 84 | events.EventEmitter.defaultMaxListeners = 44; | |
| 85 | 85 | e.on('fortytwo', common.mustNotCall()); | |
| 86 | - assert.ok(!e._events.fortytwo.hasOwnProperty('warned')); | ||
| 86 | + assert.ok(!Object.hasOwn(e._events.fortytwo, 'warned')); | ||
| 87 | 87 | e.on('fortytwo', common.mustNotCall()); | |
| 88 | - assert.ok(e._events.fortytwo.hasOwnProperty('warned')); | ||
| 88 | + assert.ok(Object.hasOwn(e._events.fortytwo, 'warned')); | ||
| 89 | 89 | } | |
| 90 | 90 | ||
| 91 | 91 | // But _maxListeners still has precedence over defaultMaxListeners | |
@@ -94,9 +94,9 @@ const events = require('events'); | |||
| 94 | 94 | const e = new events.EventEmitter(); | |
| 95 | 95 | e.setMaxListeners(1); | |
| 96 | 96 | e.on('uno', common.mustNotCall()); | |
| 97 | - assert.ok(!e._events.uno.hasOwnProperty('warned')); | ||
| 97 | + assert.ok(!Object.hasOwn(e._events.uno, 'warned')); | ||
| 98 | 98 | e.on('uno', common.mustNotCall()); | |
| 99 | - assert.ok(e._events.uno.hasOwnProperty('warned')); | ||
| 99 | + assert.ok(Object.hasOwn(e._events.uno, 'warned')); | ||
| 100 | 100 | ||
| 101 | 101 | // chainable | |
| 102 | 102 | assert.strictEqual(e, e.setMaxListeners(1)); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments