-
Notifications
You must be signed in to change notification settings - Fork 31
keys and values are still in specs #5
Comments
those used to be Does this answer your question? |
Well that's true, but there are things like https://github.com/termi/es6-transpiler, that can manage for-of quite nicely. I haven't tried yet that and if there is some other blocker then nevermind this. |
I believe that transpiler needs special syntax in order to support iterators but that's actually a valid point. I'll try to fix this somehow soon, stay tuned. |
I had also found this one ... https://www.npmjs.org/package/es6-for-of And if you need support for Symbol, this looks quite good ... https://www.npmjs.org/package/es6-symbol |
Symbol done the right way are here |
Ok, guess it doesn't matter that much. Till it's written according to specs, it should be good enough to use before it becomes stable in browsers. |
OK, I've had a better look at what specs say and methods implemented here and there … it's more work than expected. If you are in a rush I might suggest an alternative, if not already linked in this project home. Apologies but I have not much time these days for extra maintenance :-( |
Sure, let me know about alternative, it's not like everything would be dependent on this part :) |
lurking around quickly, it seems that nobody got all three of them in (understandable, since WeakMap is not reliable) but the most complete polyfill seems to be the one included in es6-shim - it gives you fully specd I'll keep this updated in case I'll ever find some time to add these |
Ping! Any chance of getting iterators? I literally can't use this lib because I want to use the built-in |
I am pretty sure if the engine supports for/of you have native Set in there too, right ? HHave a look: https://github.com/paulmillr/es6-shim/#safe-shims |
So I'm actually using var iterator = mySet.values();
var itVal;
while(!(itVal = iterator.next()).done) {
itVal.value;
} Which is basically how you have to do it if you want to use |
if that's how you have to do it anyway, what are you gaining in terms of performance? why not just the following? mySet.forEach(function (value) {
// do what you have to do
}); I think es6-shim is the right way to go for a better compatibility. Transpilers might even support es6-shim fix/implementation in order to work properly, this old module was meant to introduce basic collections, not the whole new Iterator logic. Not sure I should fix it, it seems right now overlapping or duplicated with what es6-shi fixed already. What do you think? Why you need this module to be fixed? |
Actually, just ran a jsperf and it looks like using http://jsperf.com/es6-collection-iteration/8 I wasn't aware that you were deprecating this module in favor of es6-shim, the reason I don't use es6-shim is because I can't include only the set polyfill or only the map polyfill. I basically have to include everything or nothing, which is lame. I am using |
I am not necessarily deprecating this but I am not sure I want to fix the Iterator part. Iterator is a whole "thing" that if partially implemented coild break other code around. I rather stick with faster Iterator is good, but not so useful with Sets or Maps, IMHO + I really don't have time to brng in a full Iterator logic that won't mess up with other possible polyfills that somehow fix Iterators in the whole env. Hope this makes sense to you |
@WebReflection Makes perfect sense, thanks for taking the time to explain it out. I still won't be using es6-shim for the foreseeable future, and I can't use for/of because I don't want to use a transpiler. I want to use a set because the insert/unique check is much faster than an array, but the iteration is just so much slower (and that happens much more often in my case) so I may just switch to a pure array implementation. |
if iteration is more frequent than inserting, how about this: Array.prototype.pushUnique = function () {
for (var tmp, i = 0; i < arguments.length; i++) {
tmp = arguments[i];
if (this.indexOf(tmp) < 0) this.push(tmp);
}
return this.length;
}; you are penalized in insertion, but you won't compromise looping, which is the frequent operation. |
@WebReflection Which is exactly what I am going to do, I was using a set because the insertion would be more performant but I didn't realize until now just how slow the iteration was :( |
I have just checked draft from 18th of July and these two are still in there, so why you have removed them ?
The text was updated successfully, but these errors were encountered: