-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: accept a variable arity of constructors by inherits() #937
Conversation
I don't like this, it's not obvious what Additionally I think it's very rare to need to do what you are doing (I have never needed it personally) so making it slightly easier is not worth it. |
Are there plans with io.js to adopt es6 class syntax at some stage? if there are; it may not be worth adding to just deprecate in favor of syntax. |
-1 from me also for the reasons outlined by @petkaantonov |
Yeah, I agree with Petka here too. People will think it means that |
@meandmycode io.js will get es6 class syntax as soon as it gets implemented and released in v8. Whether that syntax ends up getting used in any core code is a different story (probably not). |
@gkatsev all exports.inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}; This is a subset of what ES6 classes do, which is roughly (copying what babel does): var _inherits = function(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
}; Overall - very close. Even if it won't be used it core it won't matter much :) |
@gkatsev adopt probably not the right word, I should say promote- in that this method would become deprecated from public use anyway. |
Wow this is super-confusing, -1. |
Thanks for your contribution! As you mention, this module is locked, so only security fixes, bug fixes, and performance improvements will be considered. Since this patch does not fulfill those requirements, it will not be accepted. Additionally, increased usefulness is a very subjective metric – in this case we have ES2015 classes to look forward to, and it doesn't seem like the new functionality is obvious to most of the reviewers here. Closing this. |
thanks for the feedback! this suggestion seems rather unpopular. should anyone feel differently it's on npm: https://www.npmjs.com/package/utildot |
although the API has long been frozen, and despite stability level 3 and up being off-limits, this should be considered because merit of its usefulness outweighs the need to enforce frozen stability.
instead of doing this:
we ought to do: