Skip to content
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

Warn about Array.prototype modification and/or allow opt-out #4

Open
jkrems opened this issue Dec 19, 2013 · 2 comments
Open

Warn about Array.prototype modification and/or allow opt-out #4

jkrems opened this issue Dec 19, 2013 · 2 comments

Comments

@jkrems
Copy link

jkrems commented Dec 19, 2013

I understand that it's convenient but I think quite some people would consider it a bad practice to change the prototype of built-in types. It's modifying global state which would prevent me from using galaxy in any library: I wouldn't want to mess with global scope of the app using my library. I think the work-around is require('galaxy/lib/galaxy') but I'm not sure if anything in there relies on the Array prototype being patched. Just having require('galaxy/core') available and documented would be enough.

@jdavisclark
Copy link

+1

@bjouhier
Copy link
Owner

I had forgotten to watch the repo so I did not see this issue. Sorry for the delay in reponding.

require('galaxy/lib/galaxy') does the trick. The array module won't be loaded.

I think that this issue of modifying Array.prototype is a bit blown out of proportion. It doesn't prevent you from mixing with other libraries at all. The extra array methods are non enumerable so they won't interfere with code that introspects arrays or their prototypes. The only potential conflict that I see is if some other library tries to add functions with the same names. Pretty unlikely.

Adding a galaxy/core that only loads galaxy is not a big deal. But isn't require('galaxy/lib/galaxy') sufficient? I don't want to add bells and whistles unless there is a real issue.

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

No branches or pull requests

3 participants