termi / es6-transpiler

Tomorrow's JavaScript syntax today
Other
216 stars 18 forks source link

Implement Symbol's: transpiling and polyfill #31

Open termi opened 10 years ago

termi commented 10 years ago
var obj = {};
var private = Symbol();

obj[private] = 123;// shoudn't throw error
typeof private === 'symbol';
typeof private === 'string';//do not modify this line

private + "";// shoud throw error

->

var obj = {};
var private = Symbol();
$mark_obj_as_symbol_recipient$0(obj);
obj[private] = 123;// shoudn't throw error
($isSymbol$0(private) ? 'symbol' : typeof private) === 'symbol';
typeof private === 'string';//do not modify this line
$reset_symbol_recipient$0();
private + "";// shoud throw error

The resulting script should:

  1. respect brackets notation
  2. respect native Symbol's implementation
  3. throw error on converting symbol to string
  4. typeof should be also polyfilled
  5. typeof should not be replaced in obvious cases such as comparison with string literal which is neither 'object' nor 'symbol'