Open shaunc opened 7 years ago
isn't "@@" for "well-known symbols" in es6?
Yep. Have a look at the Symbols chapter of You Don't Know JS: ES 6 & Beyond. Here's a note from the Built-in Symbols section:
The specification uses the @@ prefix notation to refer to the built-in symbols, the most common ones being:
@@iterator
,@@toStringTag
,@@toPrimitive
.
That leads to the question, are a String and a Symbol equivalent? You can use the following block to spot check if they're the same. It looks to me like you'll need a PR to support Symbols before your code with Symbols.
Array.prototype['@@custom'] = 'from String';
console.log([]['@@custom']);
// > 'value'
const sym = Symbol.for('custom');
console.log([][sym]);
// > undefined
Array.prototype[sym] = 'from Symbol'
console.log([][sym]);
// > 'from Symbol'
Does the use of "@@" in the protocol mean that in es6 code I should actually do something like the following to define a transformer?
I'm confused what the "@@" are supposed to represent as it doesn't look like you have es6 support -- I don't suppose the above is actually interoperable with the library. But isn't "@@" for "well-known symbols" in es6?