diff --git a/test/common/arraystream.js b/test/common/arraystream.js index dadd6ff0481c60..9c497fcd9b40da 100644 --- a/test/common/arraystream.js +++ b/test/common/arraystream.js @@ -2,7 +2,6 @@ 'use strict'; const { Stream } = require('stream'); -const { inherits } = require('util'); function noop() {} // A stream to push an array into a REPL @@ -14,7 +13,8 @@ function ArrayStream() { }; } -inherits(ArrayStream, Stream); +Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype); +Object.setPrototypeOf(ArrayStream, Stream); ArrayStream.prototype.readable = true; ArrayStream.prototype.writable = true; ArrayStream.prototype.pause = noop; diff --git a/test/fixtures/repl-tab-completion-nested-repls.js b/test/fixtures/repl-tab-completion-nested-repls.js index 832734a22a5024..ceff6e79453705 100644 --- a/test/fixtures/repl-tab-completion-nested-repls.js +++ b/test/fixtures/repl-tab-completion-nested-repls.js @@ -7,7 +7,6 @@ 'use strict'; const { Stream } = require('stream'); -const { inherits } = require('util'); function noop() {} // A stream to push an array into a REPL @@ -19,7 +18,8 @@ function ArrayStream() { }; } -inherits(ArrayStream, Stream); +Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype); +Object.setPrototypeOf(ArrayStream, Stream); ArrayStream.prototype.readable = true; ArrayStream.prototype.writable = true; ArrayStream.prototype.pause = noop; @@ -47,4 +47,4 @@ putIn.run([ ]); // In Node.js 10.11.0, this next line will terminate the repl silently... -testMe.complete('inner.o', () => { throw new Error('fhqwhgads'); }); +testMe.complete('inner.o', () => { throw new Error('fhqwhgads'); }); \ No newline at end of file diff --git a/test/parallel/test-event-emitter-prepend.js b/test/parallel/test-event-emitter-prepend.js index 3259ea47f945a3..c5cf009259d722 100644 --- a/test/parallel/test-event-emitter-prepend.js +++ b/test/parallel/test-event-emitter-prepend.js @@ -31,7 +31,6 @@ common.expectsError(() => { // Test fallback if prependListener is undefined. const stream = require('stream'); -const util = require('util'); delete EventEmitter.prototype.prependListener; @@ -39,13 +38,15 @@ function Writable() { this.writable = true; stream.Stream.call(this); } -util.inherits(Writable, stream.Stream); +Object.setPrototypeOf(Writable.prototype, stream.Stream.prototype); +Object.setPrototypeOf(Writable, stream.Stream); function Readable() { this.readable = true; stream.Stream.call(this); } -util.inherits(Readable, stream.Stream); +Object.setPrototypeOf(Readable.prototype, stream.Stream.prototype); +Object.setPrototypeOf(Readable, stream.Stream); const w = new Writable(); const r = new Readable(); diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js index 094565197bd740..1157f334594981 100644 --- a/test/parallel/test-event-emitter-subclass.js +++ b/test/parallel/test-event-emitter-subclass.js @@ -23,9 +23,9 @@ const common = require('../common'); const assert = require('assert'); const EventEmitter = require('events').EventEmitter; -const util = require('util'); -util.inherits(MyEE, EventEmitter); +Object.setPrototypeOf(MyEE.prototype, EventEmitter.prototype); +Object.setPrototypeOf(MyEE, EventEmitter); function MyEE(cb) { this.once(1, cb); @@ -38,7 +38,8 @@ const myee = new MyEE(common.mustCall()); myee.hasOwnProperty('usingDomains'); -util.inherits(ErrorEE, EventEmitter); +Object.setPrototypeOf(ErrorEE.prototype, EventEmitter.prototype); +Object.setPrototypeOf(ErrorEE, EventEmitter); function ErrorEE() { this.emit('error', new Error('blerg')); } diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index 4271ad920d6c39..dc971690412baa 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -24,7 +24,6 @@ require('../common'); const assert = require('assert'); -const util = require('util'); const net = require('net'); const http = require('http'); @@ -69,7 +68,8 @@ function testServer() { }); } -util.inherits(testServer, http.Server); +Object.setPrototypeOf(testServer.prototype, http.Server.prototype); +Object.setPrototypeOf(testServer, http.Server); function writeReq(socket, data, encoding) { diff --git a/test/parallel/test-stream-duplex-destroy.js b/test/parallel/test-stream-duplex-destroy.js index 518998fd182607..1108413e72480f 100644 --- a/test/parallel/test-stream-duplex-destroy.js +++ b/test/parallel/test-stream-duplex-destroy.js @@ -3,7 +3,6 @@ const common = require('../common'); const { Duplex } = require('stream'); const assert = require('assert'); -const { inherits } = require('util'); { const duplex = new Duplex({ @@ -190,7 +189,8 @@ const { inherits } = require('util'); Duplex.call(this); } - inherits(MyDuplex, Duplex); + Object.setPrototypeOf(MyDuplex.prototype, Duplex.prototype); + Object.setPrototypeOf(MyDuplex, Duplex); new MyDuplex(); } diff --git a/test/parallel/test-stream-pipe-cleanup.js b/test/parallel/test-stream-pipe-cleanup.js index ac0a72a1da416b..cdb4d503d6422a 100644 --- a/test/parallel/test-stream-pipe-cleanup.js +++ b/test/parallel/test-stream-pipe-cleanup.js @@ -25,14 +25,14 @@ require('../common'); const stream = require('stream'); const assert = require('assert'); -const util = require('util'); function Writable() { this.writable = true; this.endCalls = 0; stream.Stream.call(this); } -util.inherits(Writable, stream.Stream); +Object.setPrototypeOf(Writable.prototype, stream.Stream.prototype); +Object.setPrototypeOf(Writable, stream.Stream); Writable.prototype.end = function() { this.endCalls++; }; @@ -45,13 +45,15 @@ function Readable() { this.readable = true; stream.Stream.call(this); } -util.inherits(Readable, stream.Stream); +Object.setPrototypeOf(Readable.prototype, stream.Stream.prototype); +Object.setPrototypeOf(Readable, stream.Stream); function Duplex() { this.readable = true; Writable.call(this); } -util.inherits(Duplex, Writable); +Object.setPrototypeOf(Duplex.prototype, Writable.prototype); +Object.setPrototypeOf(Duplex, Writable); let i = 0; const limit = 100; diff --git a/test/parallel/test-stream-pipe-event.js b/test/parallel/test-stream-pipe-event.js index 9054a5a1663ab3..d7772df6a1624b 100644 --- a/test/parallel/test-stream-pipe-event.js +++ b/test/parallel/test-stream-pipe-event.js @@ -23,19 +23,20 @@ require('../common'); const stream = require('stream'); const assert = require('assert'); -const util = require('util'); function Writable() { this.writable = true; stream.Stream.call(this); } -util.inherits(Writable, stream.Stream); +Object.setPrototypeOf(Writable.prototype, stream.Stream.prototype); +Object.setPrototypeOf(Writable, stream.Stream); function Readable() { this.readable = true; stream.Stream.call(this); } -util.inherits(Readable, stream.Stream); +Object.setPrototypeOf(Readable.prototype, stream.Stream.prototype); +Object.setPrototypeOf(Readable, stream.Stream); let passed = false; diff --git a/test/parallel/test-stream-readable-destroy.js b/test/parallel/test-stream-readable-destroy.js index 3354a8755ec957..8ad375e68b3e42 100644 --- a/test/parallel/test-stream-readable-destroy.js +++ b/test/parallel/test-stream-readable-destroy.js @@ -3,7 +3,6 @@ const common = require('../common'); const { Readable } = require('stream'); const assert = require('assert'); -const { inherits } = require('util'); { const read = new Readable({ @@ -160,7 +159,8 @@ const { inherits } = require('util'); Readable.call(this); } - inherits(MyReadable, Readable); + Object.setPrototypeOf(MyReadable.prototype, Readable.prototype); + Object.setPrototypeOf(MyReadable, Readable); new MyReadable(); } diff --git a/test/parallel/test-stream-writable-destroy.js b/test/parallel/test-stream-writable-destroy.js index 83c941f4599cab..5fbb7ae19b14dc 100644 --- a/test/parallel/test-stream-writable-destroy.js +++ b/test/parallel/test-stream-writable-destroy.js @@ -3,7 +3,6 @@ const common = require('../common'); const { Writable } = require('stream'); const assert = require('assert'); -const { inherits } = require('util'); { const write = new Writable({ @@ -173,7 +172,8 @@ const { inherits } = require('util'); Writable.call(this); } - inherits(MyWritable, Writable); + Object.setPrototypeOf(MyWritable.prototype, Writable.prototype); + Object.setPrototypeOf(MyWritable, Writable); new MyWritable(); } diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index 480aba8d56b580..fa4140ed8c5757 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -304,6 +304,7 @@ function BadCustomError(msg) { Object.defineProperty(this, 'name', { value: 'BadCustomError', enumerable: false }); } -util.inherits(BadCustomError, Error); +Object.setPrototypeOf(BadCustomError.prototype, Error.prototype); +Object.setPrototypeOf(BadCustomError, Error); assert.strictEqual(util.format(new BadCustomError('foo')), '[BadCustomError: foo]'); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 66887a10f48cd3..1816e4db06075c 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -599,7 +599,8 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324'); Object.defineProperty(this, 'name', { value: 'BadCustomError', enumerable: false }); } - util.inherits(BadCustomError, Error); + Object.setPrototypeOf(BadCustomError.prototype, Error.prototype); + Object.setPrototypeOf(BadCustomError, Error); assert.strictEqual( util.inspect(new BadCustomError('foo')), '[BadCustomError: foo]' diff --git a/test/parallel/test-zlib-deflate-raw-inherits.js b/test/parallel/test-zlib-deflate-raw-inherits.js index a24726a3fbe465..bb53caa9b50a6d 100644 --- a/test/parallel/test-zlib-deflate-raw-inherits.js +++ b/test/parallel/test-zlib-deflate-raw-inherits.js @@ -2,17 +2,17 @@ require('../common'); const { DeflateRaw } = require('zlib'); -const { inherits } = require('util'); const { Readable } = require('stream'); // validates that zlib.DeflateRaw can be inherited -// with util.inherits +// with Object.setPrototypeOf function NotInitialized(options) { DeflateRaw.call(this, options); this.prop = true; } -inherits(NotInitialized, DeflateRaw); +Object.setPrototypeOf(NotInitialized.prototype, DeflateRaw.prototype); +Object.setPrototypeOf(NotInitialized, DeflateRaw); const dest = new NotInitialized();