interactive-examples icon indicating copy to clipboard operation
interactive-examples copied to clipboard

ES6 Mode?

Open maboa opened this issue 8 years ago • 3 comments

At the moment I'm writing examples in ES5, which means I convert things like:

var p1 = Promise.resolve(3);
var p2 = 42;
var p3 = new Promise((resolve, reject) => {
  setTimeout(resolve, 100, 'foo');
}); 

Promise.all([p1, p2, p3]).then(values => { 
  console.log(values);
});

to

var p1 = Promise.resolve(3);
var p2 = 42;
var p3 = new Promise(function(resolve, reject) {
  setTimeout(resolve, 100, 'foo');
});

Promise.all([p1, p2, p3]).then(function(values) {
  console.log(values);
});

Even though ES6 browser support came before promises (I think!) So it feels a little odd to use them with the older syntax.

At some point in the future it might be nice to have an ES6 tab on the editor so that we can provide examples in newer formats. Automatic conversion from one format to the other would be great! I guess Babel or Lebab (https://lebab.io/) could help :)

maboa avatar Sep 04 '17 13:09 maboa

A quick play with Lebab shows that this might work!

screen shot 2017-09-04 at 15 20 07

maboa avatar Sep 04 '17 13:09 maboa

This is an interesting one from way back in the day. Any thoughts on this @chrisdavidmills?

schalkneethling avatar Jan 15 '21 13:01 schalkneethling

@schalkneethling Yup, I'd absolutely love to see this implemented. This has come up a few times.

chrisdavidmills avatar Jan 15 '21 14:01 chrisdavidmills