Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a inherits method to complement util.inherits #3

Open
oliverzy opened this issue Dec 2, 2013 · 1 comment
Open

Add a inherits method to complement util.inherits #3

oliverzy opened this issue Dec 2, 2013 · 1 comment

Comments

@oliverzy
Copy link

oliverzy commented Dec 2, 2013

Hi,

I'm looking for a traits implementation in JS and found this one is pretty interesting.
As you know, Node.js has a util.inherits method to simplify inheritance.

In terms of traits, it seems we need a similar util function that can combine util.inherits and traits together, that's what I have written.
I use lodash extend method for simplicity.

function inherits(constructor, parentConstructor, trait, properties) {
  util.inherits(constructor, parentConstructor);
  if (properties !== undefined)
    _.extend(constructor.prototype, properties);
  if (trait !== undefined)
    constructor.prototype = trait.create(constructor.prototype);
}
@Gozala
Copy link
Owner

Gozala commented Dec 3, 2013

Hey @oliverzy to be honest I'm no longer interested in this module, if you are I'm happy to give you ownership and you can do whatever you like with it :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants