diff --git a/doc/api/util.md b/doc/api/util.md index 8b2e7d2e41141e..7d8f2d7852c9eb 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -325,6 +325,8 @@ Inherit the prototype methods from one [constructor][] into another. The prototype of `constructor` will be set to a new object created from `superConstructor`. +This mainly adds some input validation on top of +`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`. As an additional convenience, `superConstructor` will be accessible through the `constructor.super_` property. diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 97c5ab604ff821..ac482bcfea37d8 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -105,8 +105,8 @@ function Agent(options) { } }); } - -util.inherits(Agent, EventEmitter); +Object.setPrototypeOf(Agent.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Agent, EventEmitter); Agent.defaultMaxSockets = Infinity; diff --git a/lib/_http_client.js b/lib/_http_client.js index 5b47f9c72a71b7..a5bd035bd968a3 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -279,9 +279,8 @@ function ClientRequest(input, options, cb) { this._deferToConnect(null, null, () => this._flush()); } - -util.inherits(ClientRequest, OutgoingMessage); - +Object.setPrototypeOf(ClientRequest.prototype, OutgoingMessage.prototype); +Object.setPrototypeOf(ClientRequest, OutgoingMessage); ClientRequest.prototype._finish = function _finish() { DTRACE_HTTP_CLIENT_REQUEST(this, this.connection); diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js index 23ac4d54be1ec5..bf2fee693225c9 100644 --- a/lib/_http_incoming.js +++ b/lib/_http_incoming.js @@ -21,7 +21,6 @@ 'use strict'; -const util = require('util'); const Stream = require('stream'); function readStart(socket) { @@ -72,8 +71,8 @@ function IncomingMessage(socket) { // read by the user, so there's no point continuing to handle it. this._dumped = false; } -util.inherits(IncomingMessage, Stream.Readable); - +Object.setPrototypeOf(IncomingMessage.prototype, Stream.Readable.prototype); +Object.setPrototypeOf(IncomingMessage, Stream.Readable); IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) { if (callback) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 3bedce9d515b38..eb68d091c68407 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -106,7 +106,8 @@ function OutgoingMessage() { this._onPendingData = noopPendingOutput; } -util.inherits(OutgoingMessage, Stream); +Object.setPrototypeOf(OutgoingMessage.prototype, Stream.prototype); +Object.setPrototypeOf(OutgoingMessage, Stream); Object.defineProperty(OutgoingMessage.prototype, '_headers', { diff --git a/lib/_http_server.js b/lib/_http_server.js index c171b1d3e78a41..11b583f0192c8c 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -137,7 +137,8 @@ function ServerResponse(req) { this.shouldKeepAlive = false; } } -util.inherits(ServerResponse, OutgoingMessage); +Object.setPrototypeOf(ServerResponse.prototype, OutgoingMessage.prototype); +Object.setPrototypeOf(ServerResponse, OutgoingMessage); ServerResponse.prototype._finish = function _finish() { DTRACE_HTTP_SERVER_RESPONSE(this.connection); diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 7059757dbd44b1..82cc23a38ca030 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -28,11 +28,11 @@ module.exports = Duplex; -const util = require('util'); const Readable = require('_stream_readable'); const Writable = require('_stream_writable'); -util.inherits(Duplex, Readable); +Object.setPrototypeOf(Duplex.prototype, Readable.prototype); +Object.setPrototypeOf(Duplex, Readable); { // Allow the keys array to be GC'ed. diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js index 82adaa8d1c7d86..404617f58eab1f 100644 --- a/lib/_stream_passthrough.js +++ b/lib/_stream_passthrough.js @@ -28,8 +28,8 @@ module.exports = PassThrough; const Transform = require('_stream_transform'); -const util = require('util'); -util.inherits(PassThrough, Transform); +Object.setPrototypeOf(PassThrough.prototype, Transform.prototype); +Object.setPrototypeOf(PassThrough, Transform); function PassThrough(options) { if (!(this instanceof PassThrough)) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 47dbae31b5f2c1..d1a17fd066076d 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -44,7 +44,8 @@ const { emitExperimentalWarning } = require('internal/util'); let StringDecoder; let createReadableStreamAsyncIterator; -util.inherits(Readable, Stream); +Object.setPrototypeOf(Readable.prototype, Stream.prototype); +Object.setPrototypeOf(Readable, Stream); const { errorOrDestroy } = destroyImpl; const kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 679f79b80dfb35..0a37b6a4d4490c 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -71,8 +71,8 @@ const { ERR_TRANSFORM_WITH_LENGTH_0 } = require('internal/errors').codes; const Duplex = require('_stream_duplex'); -const util = require('util'); -util.inherits(Transform, Duplex); +Object.setPrototypeOf(Transform.prototype, Duplex.prototype); +Object.setPrototypeOf(Transform, Duplex); function afterTransform(er, data) { diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 022dcffdd78e28..c2f5a5ec4ac9d1 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -28,7 +28,6 @@ module.exports = Writable; Writable.WritableState = WritableState; -const util = require('util'); const internalUtil = require('internal/util'); const Stream = require('stream'); const { Buffer } = require('buffer'); @@ -47,7 +46,8 @@ const { const { errorOrDestroy } = destroyImpl; -util.inherits(Writable, Stream); +Object.setPrototypeOf(Writable.prototype, Stream.prototype); +Object.setPrototypeOf(Writable, Stream); function nop() {} diff --git a/lib/dgram.js b/lib/dgram.js index 55662313d640cd..4751debff1500c 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -108,7 +108,8 @@ function Socket(type, listener) { sendBufferSize }; } -util.inherits(Socket, EventEmitter); +Object.setPrototypeOf(Socket.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Socket, EventEmitter); function createSocket(type, listener) { diff --git a/lib/https.js b/lib/https.js index 0854c3d440577a..4a83853d078d9e 100644 --- a/lib/https.js +++ b/lib/https.js @@ -149,7 +149,8 @@ function Agent(options) { list: [] }; } -inherits(Agent, HttpAgent); +Object.setPrototypeOf(Agent.prototype, HttpAgent.prototype); +Object.setPrototypeOf(Agent, HttpAgent); Agent.prototype.createConnection = createConnection; Agent.prototype.getName = function getName(options) { diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 3d4a2b5478124a..cd942e65b59798 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -265,7 +265,8 @@ function ChildProcess() { maybeClose(this); }; } -util.inherits(ChildProcess, EventEmitter); +Object.setPrototypeOf(ChildProcess.prototype, EventEmitter.prototype); +Object.setPrototypeOf(ChildProcess, EventEmitter); function flushStdio(subprocess) { diff --git a/lib/internal/cluster/worker.js b/lib/internal/cluster/worker.js index 2cf5fc385809c7..8033f82f2e24d0 100644 --- a/lib/internal/cluster/worker.js +++ b/lib/internal/cluster/worker.js @@ -1,6 +1,5 @@ 'use strict'; const EventEmitter = require('events'); -const util = require('util'); module.exports = Worker; @@ -30,7 +29,8 @@ function Worker(options) { } } -util.inherits(Worker, EventEmitter); +Object.setPrototypeOf(Worker.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Worker, EventEmitter); Worker.prototype.kill = function() { this.destroy.apply(this, arguments); diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js index cdb92465ece578..1e5dc91c8d5790 100644 --- a/lib/internal/crypto/cipher.js +++ b/lib/internal/crypto/cipher.js @@ -32,7 +32,6 @@ const { const assert = require('assert'); const LazyTransform = require('internal/streams/lazy_transform'); -const { inherits } = require('util'); const { deprecate, normalizeEncoding } = require('internal/util'); // Lazy loaded for startup performance. @@ -124,7 +123,8 @@ function Cipher(cipher, password, options) { createCipher.call(this, cipher, password, options, true); } -inherits(Cipher, LazyTransform); +Object.setPrototypeOf(Cipher.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Cipher, LazyTransform); Cipher.prototype._transform = function _transform(chunk, encoding, callback) { this.push(this[kHandle].update(chunk, encoding)); @@ -254,7 +254,8 @@ function addCipherPrototypeFunctions(constructor) { constructor.prototype.setAAD = Cipher.prototype.setAAD; } -inherits(Cipheriv, LazyTransform); +Object.setPrototypeOf(Cipheriv.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Cipheriv, LazyTransform); addCipherPrototypeFunctions(Cipheriv); legacyNativeHandle(Cipheriv); @@ -265,7 +266,8 @@ function Decipher(cipher, password, options) { createCipher.call(this, cipher, password, options, false); } -inherits(Decipher, LazyTransform); +Object.setPrototypeOf(Decipher.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Decipher, LazyTransform); addCipherPrototypeFunctions(Decipher); legacyNativeHandle(Decipher); @@ -277,7 +279,8 @@ function Decipheriv(cipher, key, iv, options) { createCipherWithIV.call(this, cipher, key, options, false, iv); } -inherits(Decipheriv, LazyTransform); +Object.setPrototypeOf(Decipheriv.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Decipheriv, LazyTransform); addCipherPrototypeFunctions(Decipheriv); legacyNativeHandle(Decipheriv); diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js index 6803d8fa954e73..f289d11cf8b9c0 100644 --- a/lib/internal/crypto/hash.js +++ b/lib/internal/crypto/hash.js @@ -21,7 +21,6 @@ const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; const { validateString } = require('internal/validators'); -const { inherits } = require('util'); const { normalizeEncoding } = require('internal/util'); const { isArrayBufferView } = require('internal/util/types'); const LazyTransform = require('internal/streams/lazy_transform'); @@ -39,7 +38,8 @@ function Hash(algorithm, options) { LazyTransform.call(this, options); } -inherits(Hash, LazyTransform); +Object.setPrototypeOf(Hash.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Hash, LazyTransform); Hash.prototype._transform = function _transform(chunk, encoding, callback) { this[kHandle].update(chunk, encoding); @@ -100,7 +100,8 @@ function Hmac(hmac, key, options) { LazyTransform.call(this, options); } -inherits(Hmac, LazyTransform); +Object.setPrototypeOf(Hmac.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Hmac, LazyTransform); Hmac.prototype.update = Hash.prototype.update; diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js index 9f02c866739f24..fa2d4998b6c990 100644 --- a/lib/internal/crypto/sig.js +++ b/lib/internal/crypto/sig.js @@ -18,7 +18,6 @@ const { validateArrayBufferView, } = require('internal/crypto/util'); const { Writable } = require('stream'); -const { inherits } = require('util'); function Sign(algorithm, options) { if (!(this instanceof Sign)) @@ -30,7 +29,8 @@ function Sign(algorithm, options) { Writable.call(this, options); } -inherits(Sign, Writable); +Object.setPrototypeOf(Sign.prototype, Writable.prototype); +Object.setPrototypeOf(Sign, Writable); Sign.prototype._write = function _write(chunk, encoding, callback) { this.update(chunk, encoding); @@ -101,7 +101,8 @@ function Verify(algorithm, options) { Writable.call(this, options); } -inherits(Verify, Writable); +Object.setPrototypeOf(Verify.prototype, Writable.prototype); +Object.setPrototypeOf(Verify, Writable); Verify.prototype._write = Sign.prototype._write; Verify.prototype.update = Sign.prototype.update; diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 1eb3439f230160..059f203597500b 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -17,7 +17,6 @@ const { } = require('internal/fs/utils'); const { Readable, Writable } = require('stream'); const { toPathIfFileURL } = require('internal/url'); -const util = require('util'); const kMinPoolSpace = 128; @@ -119,7 +118,8 @@ function ReadStream(path, options) { } }); } -util.inherits(ReadStream, Readable); +Object.setPrototypeOf(ReadStream.prototype, Readable.prototype); +Object.setPrototypeOf(ReadStream, Readable); ReadStream.prototype.open = function() { fs.open(this.path, this.flags, this.mode, (er, fd) => { @@ -273,7 +273,8 @@ function WriteStream(path, options) { if (typeof this.fd !== 'number') this.open(); } -util.inherits(WriteStream, Writable); +Object.setPrototypeOf(WriteStream.prototype, Writable.prototype); +Object.setPrototypeOf(WriteStream, Writable); WriteStream.prototype._final = function(callback) { if (this.autoClose) { diff --git a/lib/internal/fs/sync_write_stream.js b/lib/internal/fs/sync_write_stream.js index b365474663d8c2..1e7c6a50a96d6d 100644 --- a/lib/internal/fs/sync_write_stream.js +++ b/lib/internal/fs/sync_write_stream.js @@ -1,7 +1,6 @@ 'use strict'; const { Writable } = require('stream'); -const { inherits } = require('util'); const { closeSync, writeSync } = require('fs'); function SyncWriteStream(fd, options) { @@ -16,7 +15,8 @@ function SyncWriteStream(fd, options) { this.on('end', () => this._destroy()); } -inherits(SyncWriteStream, Writable); +Object.setPrototypeOf(SyncWriteStream.prototype, Writable.prototype); +Object.setPrototypeOf(SyncWriteStream, Writable); SyncWriteStream.prototype._write = function(chunk, encoding, cb) { writeSync(this.fd, chunk, 0, chunk.length); diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index e026aa8192c3cf..83c9b429ef6063 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -19,7 +19,6 @@ const { const { toNamespacedPath } = require('path'); const { validateUint32 } = require('internal/validators'); const { toPathIfFileURL } = require('internal/url'); -const util = require('util'); const assert = require('assert'); const kOldStatus = Symbol('kOldStatus'); @@ -36,7 +35,8 @@ function StatWatcher(bigint) { this[kOldStatus] = -1; this[kUseBigint] = bigint; } -util.inherits(StatWatcher, EventEmitter); +Object.setPrototypeOf(StatWatcher.prototype, EventEmitter.prototype); +Object.setPrototypeOf(StatWatcher, EventEmitter); function onchange(newStatus, stats) { const self = this[owner_symbol]; @@ -132,7 +132,8 @@ function FSWatcher() { } }; } -util.inherits(FSWatcher, EventEmitter); +Object.setPrototypeOf(FSWatcher.prototype, EventEmitter.prototype); +Object.setPrototypeOf(FSWatcher, EventEmitter); // FIXME(joyeecheung): this method is not documented. diff --git a/lib/internal/streams/legacy.js b/lib/internal/streams/legacy.js index 9790696bfc7131..85c88c73f01f06 100644 --- a/lib/internal/streams/legacy.js +++ b/lib/internal/streams/legacy.js @@ -1,12 +1,12 @@ 'use strict'; const EE = require('events'); -const util = require('util'); function Stream() { EE.call(this); } -util.inherits(Stream, EE); +Object.setPrototypeOf(Stream.prototype, EE.prototype); +Object.setPrototypeOf(Stream, EE); Stream.prototype.pipe = function(dest, options) { var source = this; diff --git a/lib/net.js b/lib/net.js index ba7c3eb6daca0d..a46844adf3e9a0 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1145,7 +1145,8 @@ function Server(options, connectionListener) { this.allowHalfOpen = options.allowHalfOpen || false; this.pauseOnConnect = !!options.pauseOnConnect; } -util.inherits(Server, EventEmitter); +Object.setPrototypeOf(Server.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Server, EventEmitter); function toNumber(x) { return (x = Number(x)) >= 0 ? x : false; } diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 1086c4b5199f16..9b40c8f97735c8 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -33,7 +33,6 @@ const { const { AsyncResource } = require('async_hooks'); const L = require('internal/linkedlist'); const kInspect = require('internal/util').customInspectSymbol; -const { inherits } = require('util'); const kCallback = Symbol('callback'); const kTypes = Symbol('types'); @@ -208,10 +207,9 @@ class PerformanceNodeTiming { }; } } -// Use this instead of Extends because we want PerformanceEntry in the -// prototype chain but we do not want to use the PerformanceEntry -// constructor for this. -inherits(PerformanceNodeTiming, PerformanceEntry); +Object.setPrototypeOf( + PerformanceNodeTiming.prototype, PerformanceEntry.prototype); +Object.setPrototypeOf(PerformanceNodeTiming, PerformanceEntry); const nodeTiming = new PerformanceNodeTiming(); diff --git a/lib/readline.js b/lib/readline.js index 049f5aaeccf439..e55507416b0b08 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -32,7 +32,7 @@ const { ERR_INVALID_CURSOR_POS, ERR_INVALID_OPT_VALUE } = require('internal/errors').codes; -const { debug, inherits } = require('util'); +const { debug } = require('util'); const { emitExperimentalWarning } = require('internal/util'); const { Buffer } = require('buffer'); const EventEmitter = require('events'); @@ -245,7 +245,8 @@ function Interface(input, output, completer, terminal) { input.resume(); } -inherits(Interface, EventEmitter); +Object.setPrototypeOf(Interface.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Interface, EventEmitter); Object.defineProperty(Interface.prototype, 'columns', { configurable: true, diff --git a/lib/repl.js b/lib/repl.js index 5dbd02fd231cd1..1ab4031f09cb9a 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -53,7 +53,6 @@ const { } = require('internal/deps/acorn/dist/acorn'); const internalUtil = require('internal/util'); const util = require('util'); -const { inherits } = util; const Stream = require('stream'); const vm = require('vm'); const path = require('path'); @@ -669,9 +668,9 @@ function REPLServer(prompt, // handle multiline history if (self[kBufferedCommandSymbol].length) - REPLServer.super_.prototype.multilineHistory.call(self, false); + Interface.prototype.multilineHistory.call(self, false); else { - REPLServer.super_.prototype.multilineHistory.call(self, true); + Interface.prototype.multilineHistory.call(self, true); } // Clear buffer if no SyntaxErrors @@ -753,7 +752,9 @@ function REPLServer(prompt, self.displayPrompt(); } -inherits(REPLServer, Interface); +Object.setPrototypeOf(REPLServer.prototype, Interface.prototype); +Object.setPrototypeOf(REPLServer, Interface); + exports.REPLServer = REPLServer; exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy'); @@ -894,18 +895,18 @@ REPLServer.prototype.displayPrompt = function(preserveCursor) { const len = this.lines.level.length ? this.lines.level.length - 1 : 0; const levelInd = '..'.repeat(len); prompt += levelInd + ' '; - REPLServer.super_.prototype.undoHistory.call(this); + Interface.prototype.undoHistory.call(this); } // Do not overwrite `_initialPrompt` here - REPLServer.super_.prototype.setPrompt.call(this, prompt); + Interface.prototype.setPrompt.call(this, prompt); this.prompt(preserveCursor); }; // When invoked as an API method, overwrite _initialPrompt REPLServer.prototype.setPrompt = function setPrompt(prompt) { this._initialPrompt = prompt; - REPLServer.super_.prototype.setPrompt.call(this, prompt); + Interface.prototype.setPrompt.call(this, prompt); }; REPLServer.prototype.turnOffEditorMode = util.deprecate( @@ -923,7 +924,8 @@ function ArrayStream() { this.emit('data', `${data[n]}\n`); }; } -util.inherits(ArrayStream, Stream); +Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype); +Object.setPrototypeOf(ArrayStream, Stream); ArrayStream.prototype.readable = true; ArrayStream.prototype.writable = true; ArrayStream.prototype.resume = function() {}; @@ -1396,7 +1398,7 @@ function addStandardGlobals(completionGroups, filter) { function _turnOnEditorMode(repl) { repl.editorMode = true; - REPLServer.super_.prototype.setPrompt.call(repl, ''); + Interface.prototype.setPrompt.call(repl, ''); } function _turnOffEditorMode(repl) { @@ -1514,5 +1516,6 @@ function regexpEscape(s) { function Recoverable(err) { this.err = err; } -inherits(Recoverable, SyntaxError); +Object.setPrototypeOf(Recoverable.prototype, SyntaxError.prototype); +Object.setPrototypeOf(Recoverable, SyntaxError); exports.Recoverable = Recoverable; diff --git a/lib/zlib.js b/lib/zlib.js index 559f6c2d5f3056..fc1eeaf2b099fc 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -31,7 +31,6 @@ const Transform = require('_stream_transform'); const { deprecate, _extend, - inherits, types: { isAnyArrayBuffer, isArrayBufferView @@ -318,7 +317,8 @@ function Zlib(opts, mode) { this._info = opts && opts.info; this.once('end', this.close); } -inherits(Zlib, Transform); +Object.setPrototypeOf(Zlib.prototype, Transform.prototype); +Object.setPrototypeOf(Zlib, Transform); Object.defineProperty(Zlib.prototype, '_closed', { configurable: true, @@ -648,28 +648,32 @@ function Deflate(opts) { return new Deflate(opts); Zlib.call(this, opts, DEFLATE); } -inherits(Deflate, Zlib); +Object.setPrototypeOf(Deflate.prototype, Zlib.prototype); +Object.setPrototypeOf(Deflate, Zlib); function Inflate(opts) { if (!(this instanceof Inflate)) return new Inflate(opts); Zlib.call(this, opts, INFLATE); } -inherits(Inflate, Zlib); +Object.setPrototypeOf(Inflate.prototype, Zlib.prototype); +Object.setPrototypeOf(Inflate, Zlib); function Gzip(opts) { if (!(this instanceof Gzip)) return new Gzip(opts); Zlib.call(this, opts, GZIP); } -inherits(Gzip, Zlib); +Object.setPrototypeOf(Gzip.prototype, Zlib.prototype); +Object.setPrototypeOf(Gzip, Zlib); function Gunzip(opts) { if (!(this instanceof Gunzip)) return new Gunzip(opts); Zlib.call(this, opts, GUNZIP); } -inherits(Gunzip, Zlib); +Object.setPrototypeOf(Gunzip.prototype, Zlib.prototype); +Object.setPrototypeOf(Gunzip, Zlib); function DeflateRaw(opts) { if (opts && opts.windowBits === 8) opts.windowBits = 9; @@ -677,21 +681,24 @@ function DeflateRaw(opts) { return new DeflateRaw(opts); Zlib.call(this, opts, DEFLATERAW); } -inherits(DeflateRaw, Zlib); +Object.setPrototypeOf(DeflateRaw.prototype, Zlib.prototype); +Object.setPrototypeOf(DeflateRaw, Zlib); function InflateRaw(opts) { if (!(this instanceof InflateRaw)) return new InflateRaw(opts); Zlib.call(this, opts, INFLATERAW); } -inherits(InflateRaw, Zlib); +Object.setPrototypeOf(InflateRaw.prototype, Zlib.prototype); +Object.setPrototypeOf(InflateRaw, Zlib); function Unzip(opts) { if (!(this instanceof Unzip)) return new Unzip(opts); Zlib.call(this, opts, UNZIP); } -inherits(Unzip, Zlib); +Object.setPrototypeOf(Unzip.prototype, Zlib.prototype); +Object.setPrototypeOf(Unzip, Zlib); function createConvenienceMethod(ctor, sync) { if (sync) {