Skip to content

Remove util.inherits usage internally? #24395

Closed
@joyeecheung

Description

@joyeecheung

Currently, util.inherits does this:

node/lib/util.js

Lines 300 to 318 in e1aa730

function inherits(ctor, superCtor) {
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',
'Function', superCtor.prototype);
}
Object.defineProperty(ctor, 'super_', {
value: superCtor,
writable: true,
configurable: true
});
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
}

Most of the code seems unnecessary for our internal use. Essentially we can just replace all the internal util.inherits usage with Object.setPrototypeOf(ctor.prototype, superCtor.prototype)

Unless someone is relying on that ctor._super property existing on our internal types..

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions