Last active
November 25, 2016 00:36
-
-
Save gkucmierz/a566a9ab2d7f717443630ad43b388d8c to your computer and use it in GitHub Desktop.
Implementation of new generator creation from string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Generator = (function*(){}).constructor; | |
// function Generator(...a) { | |
// let [args, body] = a; | |
// if (a.length === 0) [args, body] = [[], '']; | |
// if (a.length === 1) [args, body] = [[], a[0]]; | |
// return new Function(`return function*(${args.join(',')}){${body}};`)(); | |
// } | |
// new genearator: | |
// | |
// new Generator(); | |
// new Generator('return yield;'); | |
// new Generator(['arg'], 'return yield arg;'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment