You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
}
The text was updated successfully, but these errors were encountered:
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 :)
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.
The text was updated successfully, but these errors were encountered: