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

Array.prototype is modified #36

Closed
thanpolas opened this issue Oct 2, 2013 · 3 comments
Closed

Array.prototype is modified #36

thanpolas opened this issue Oct 2, 2013 · 3 comments
Assignees

Comments

@thanpolas
Copy link

I had an issue (verbling/assetflow#10) in one of my libraries, were a developer has conflict problems because Collections alters the Array.prototype. I am quoting @Amptron:

Collections JS adds some methods to the Array.prototype. Since this added functionality doesn't seem to be an explicit intention of assetflow, it seems weird to have it as a dependency.

Specifically, we're using Sugar JS and Collection's Array.find method collides with Sugar's Array.find which is an unintended consequence of using assetflow.

  assert = require('assert');

  assert.equal(Array.prototype.find, void 0, "Prototype modified before assetflow");

  require('assetflow');

  assert.equal(Array.prototype.find, void 0, "Prototype modified after assetflow");

Output: Prototype modified after assetflow

What do you suggest the best course of action should be?

@Stuk
Copy link
Contributor

Stuk commented Oct 2, 2013

@thanpolas Just FYI it's defined here, and is needed by a number of collections, so it's not a simple matter of just replacing it. In the short term your user could overwrite it themselves to accept a function or a value to maintain the needed compat. Obviously far from ideal.

@kriskowal collections' Array#find does not align with the ES6 spec's. Sugar JS's is closer. From a collections point of view it should be changed, although this is going to cause problems with FRB.

@kriskowal
Copy link
Member

@Stuk looks like I guessed wrong on the direction they were going to take. I’m okay with renaming our find and findLast to findValue and findLastValue and propagating the changes outward.

@kriskowal
Copy link
Member

We have corrected our find and findIndex shims in the v2 branch. Alas that this is as soon as we can fix the problem, and that v2 is not ready for prime time. However, no further work needed on this ticket.

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

4 participants