One of the most important feature introduced in Javascript ES6 is the
Generator function,
which provides the ability to suspend the execution of a function. However, not
all browsers and platforms support generator right now. Earlier versions of
Firefox either had ES6 generators turned off, or supported only old style
generators. On Chrome 28, you have to turn on an experimental flag named
Enable Experimental JavaScript. Node.js haven’t got generator support until
version 0.11.2 and you have to run it with --harmony
flag.
You have another option that is to compile the javascript files using Regenerator, an ES6 to ES5 Javascript compiler (Google also has their own compiler called Traceur). Regenerator is available on npm
The command to transform js file is simple. You need to include the runtime file in your result html file.
If you want Regenerator to include the runtime automatically for you in all
files that it generates, use --include-runtime
flag
If you want to use Regenerator with Gulp (read more at Automate Javascript development with Gulp), you need to install gulp-regenerator.
To use it, simply pipe it to a gulp task
You can also include the runtime with options.includeRuntime
Another example for a gulp task that pipes multiple actions