Closed marclaval closed 8 years ago
The shim doesn't expose features which can't be 100% implemented in es5 browsers, thus it doesn't define Symbol
at all. It might be a reasonable feature to add to es6-sham
, though.
Under no circumstances will es6-shim
expose Symbol
or anything underneath it, since Symbols are simply impossible to faithfully shim.
You can derive es6-shim
's internal Symbol.iterator
value by looking in Object.getOwnPropertyNames(Map.prototype)
, and finding the key (besides "entries" itself, and "size" which throws on access) whose value is === Map.prototype.entries
. Namely, Object.getOwnPropertyNames(Map.prototype).find(function (key) { return key !== 'entries' && key !== 'size' && Map.prototype[key] === Map.prototype.entries; });
I wouldn't accept this in es6-sham
by itself, however, since the existence of Symbol
in the global space could break a lot of code that doesn't properly check Symbol support.
@ljharb fair enough. Thanks for the tip to retrieve the internal value.
This detection is now unnecessary; https://npmjs.com/es-get-iterator will let you get an iterator from any value.
Hello,
it can be very nice to use
Symbol.iterator
. For example: https://github.com/angular/angular/blob/master/modules/angular2/src/core/compiler/query_list.ts#L104 But the shim doesn't expose'_es6-shim iterator_'
asSymbol.iterator
.Cheers