Last active
July 25, 2017 10:50
-
-
Save gskachkov/611206af09adbcd4adae821d02bc7f8e 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
const getValue = () => { console.log('get-value'); return 'value'; }; | |
async function* foo(value = getValue()) { | |
console.log('before yield', value); | |
yield value + '-yiled'; | |
console.log('after yield'); | |
return value + '-result'; | |
} | |
async function boo() { | |
const iter = foo(); | |
console.log('before iteration'); | |
let result = await iter.next(); | |
console.log('step1:', result.value, result.done); | |
result = await iter.next(); | |
console.log('step2:', result.value, result.done); | |
} | |
boo(); | |
// get-value | |
// before iteration | |
// before yield value | |
// step1: value-yiled false | |
// after yield | |
// step2: value-result true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment