-
Notifications
You must be signed in to change notification settings - Fork 30
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
Extended standard types and Symbol.toStringTag #49
Comments
imo |
I totally agree, but apparently, according to the ES7 spec, this is what happens when we call Array.isArray in this line: I'm not sure what an " Maybe we could use What do you think about this? PS.: Am I overthinking the problem? 😆 |
Hm. Here's the official spec for "Array exotic objects". I poked around at a couple options, one of which was this, kept me at about 24,000,000 ops/sec (using Node v6.0.0 for this, by the way):
This works too, but drops down to about 2,800,000 ops/sec for array literals on my machine:
I also tried dropping the The first option above did allow me to drop through to the bottom
Trying to think if that would be sufficient, or if I'm missing a scenario... Another side note -- is it intended that the custom |
@dvlsg Whoa! That's great, thanks for your work, it is awesome to have all those pieces of information 😄 Since numbers don't lie I'd definitely go with the first option. However, I wouldn't return the I cannot be 100% sure, but I'm 99% sure we do want returns to be lowercase since we have this explicit call right here, unless someone forgot to remove it somewhere along the line I think that is the intended behavior. Since @keithamus has been maintaining this for more time he may be able to either confirm or deny my suspicion. What do you think @meeber @keithamus ? |
Cool, I'll hold off on making a PR until we get more feedback from the rest of the team. For the lowercase toStringTag, I think that's okay if it's intentional, but I noticed the readme.md ends with the following example:
That should probably have |
My gut reaction is that we shouldn't lowercase someone's custom |
Hey @dvlsg this was intended to be the original design (I mean, Array with toStringTag should return the result of that) so I personally would consider this a bug. The lowercasing is slightly problematic... but it's baked into the design and I feel like we should remain consistent, even if its wrong (because being inconsistent and wrong is worse). We could look at removing the lowercase thing as a breaking change, later down the line - but with 4.x we have many breaking changes and I think I'd sooner ease our users into breaking changes rather than have a whole lump of them. |
Assuming you aren't already planning on this, how do you feel about also exporting a pre-set chunk of "constants" (for lack of a better word) in a later version (4.x)? For example, something similar to this:
This would allow end users to do something like this:
That would make case sensitivity... less important? I suppose it would still be at least somewhat relevant (especially in the case of I could be barking up the entirely wrong tree, though -- figured I'd at least bring up the thought. |
I think we could instead look at releasing codemods (scripts which modify users code, like what js-codemod or jscodeshift does) with our breaking changes - so users just have to run a command to have their tests updated to fix breakages. (If you're interested in this concept, read more here: https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb#.dez2cqdbh) |
Fair enough. And it would have definitely required changes in userland to utilize the constants in existing tests, as well. My thought was that it would protect against further breaking changes in the future, since matching But then again, exporting and importing Whatever the case, I think I'm dragging this issue off topic. I'll look into making a PR for the original question (checking for |
Might be a question more than a bug, but how would you expect this to react?
My initial expectation was that I would receive back
ExtendedArray
through the use ofSymbol.toStringTag
, but the code returnsarray
, from here. Is this intended?The text was updated successfully, but these errors were encountered: