Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
util: use missing validators
The `inherits()` method in the `util` lib module is not using validators which others do use.
  • Loading branch information
VoltrexKeyva authored Jun 1, 2021
commit dda5e5f8a5d680328ca1bb287b82b5410e45e575
14 changes: 4 additions & 10 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const { debuglog } = require('internal/util/debuglog');
const {
validateFunction,
validateNumber,
validateObject,
} = require('internal/validators');
const { TextDecoder, TextEncoder } = require('internal/encoding');
const { isBuffer } = require('buffer').Buffer;
Expand Down Expand Up @@ -229,17 +230,10 @@ function log(...args) {
* the super constructor lacks a prototype.
*/
function inherits(ctor, superCtor) {
validateFunction(ctor, 'ctor');
validateFunction(superCtor, 'superCtor');
validateObject(superCtor.prototype, 'superCtor.prototype');

if (ctor === undefined || ctor === null)
throw new ERR_INVALID_ARG_TYPE('ctor', 'Function', ctor);

if (superCtor === undefined || superCtor === null)
throw new ERR_INVALID_ARG_TYPE('superCtor', 'Function', superCtor);

if (superCtor.prototype === undefined) {
throw new ERR_INVALID_ARG_TYPE('superCtor.prototype',
'Object', superCtor.prototype);
}
ObjectDefineProperty(ctor, 'super_', {
value: superCtor,
writable: true,
Expand Down