Last active
December 22, 2015 18:49
-
-
Save chapel/6515933 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var fn = function* (args) { | |
yield asyncFn(args); | |
}; | |
Object.defineProperty(this, 'fn', { | |
get: function () { | |
return function () { | |
return fn.next(); | |
} | |
} | |
}); | |
var value = fn(1); | |
This file contains hidden or 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
function autoGen(fn) { | |
return function () { | |
return fn.next(); | |
} | |
} | |
var fn = autoGen(function* (args) { | |
yield asyncFn(args); | |
}; | |
var value = fn(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment