From dcc82b37b631d636e0fefc8272c357ec4a7d6df2 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 30 Nov 2018 17:55:48 +0100 Subject: lib: remove `inherits()` usage This switches all `util.inherits()` calls to use `Object.setPrototypeOf()` instead. In fact, `util.inherits()` is mainly a small wrapper around exactly this function while adding the `_super` property on the object as well. Refs: #24395 PR-URL: https://github.com/nodejs/node/pull/24755 Refs: https://github.com/nodejs/node/issues/24395 Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina --- lib/internal/crypto/cipher.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/internal/crypto/cipher.js') diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js index cdb92465ec..7f88320d6c 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,7 @@ function Cipher(cipher, password, options) { createCipher.call(this, cipher, password, options, true); } -inherits(Cipher, LazyTransform); +Object.setPrototypeOf(Cipher.prototype, LazyTransform.prototype); Cipher.prototype._transform = function _transform(chunk, encoding, callback) { this.push(this[kHandle].update(chunk, encoding)); @@ -254,7 +253,7 @@ function addCipherPrototypeFunctions(constructor) { constructor.prototype.setAAD = Cipher.prototype.setAAD; } -inherits(Cipheriv, LazyTransform); +Object.setPrototypeOf(Cipheriv.prototype, LazyTransform.prototype); addCipherPrototypeFunctions(Cipheriv); legacyNativeHandle(Cipheriv); @@ -265,7 +264,7 @@ function Decipher(cipher, password, options) { createCipher.call(this, cipher, password, options, false); } -inherits(Decipher, LazyTransform); +Object.setPrototypeOf(Decipher.prototype, LazyTransform.prototype); addCipherPrototypeFunctions(Decipher); legacyNativeHandle(Decipher); @@ -277,7 +276,7 @@ function Decipheriv(cipher, key, iv, options) { createCipherWithIV.call(this, cipher, key, options, false, iv); } -inherits(Decipheriv, LazyTransform); +Object.setPrototypeOf(Decipheriv.prototype, LazyTransform.prototype); addCipherPrototypeFunctions(Decipheriv); legacyNativeHandle(Decipheriv); -- cgit v1.2.1