-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
Adding methods to the String Prototype? #6
Comments
It's unlikely, I disagree with ever extending a built-in prototype. If you want you can just assign it yourself and write a wrapper. E.g. var changeCase = require('change-case');
for (var key in changeCase) {
String.prototype[key] = function () {
return changeCase[key](this);
};
} |
I value perspective. Would you be willing to share why you avoid extending? Is it because other modules might collide and cause issues? Thanks! |
Yeah, no problem. There are a couple of things and collisions are definitely valid. It basically comes down to if I wanted to extend someone elses code with my own - I would subclass it to ensure greater compatibility. It also means that other people that use the code aren't startled when this random bit of code is inside something they are using. Although this isn't as specific as other things, I believe the rule should be fully enforced everywhere. That way no one has any surprises and the original authors can continue building up their code without having to worry about downstream consumers. |
Afternoon. Great module. I was wondering if there was any thought of adding these methods to the String prototype to enable str.titleCase()? etc?
The text was updated successfully, but these errors were encountered: