Skip to content

Remove util.inherits usage internally? #24395

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?

Activity

  1. added
    utilIssues and PRs related to the built-in util module.
    on Nov 16, 2018
  2. refack commented on Nov 16, 2018

    @refack
    Contributor

    I'm +1 on writing a PR and running CitGM on it, then have it in nightlies go get some feedback. Otherwise we won't know.
    (Ohh, and run a query on Gzemnid)

  3. added a commit that references this issue on Dec 5, 2018
  4. added a commit that references this issue on Jan 14, 2019
  5. joyeecheung commented on Mar 9, 2019

    @joyeecheung
    MemberAuthor

    This is still open, can probably be used as code-and-learn tasks

  6. added
    good first issueIssues that are suitable for first-time contributors.
    on Mar 9, 2019
  7. cjihrig commented on Mar 12, 2019

    @cjihrig
    Contributor

    @peanutenthusiast check out #26546 for an updated version of this issue.

  8. BridgeAR commented on Mar 31, 2019

    @BridgeAR
    Member

    Closing as resolved. There is no usage internal usage left in core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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