Created
September 15, 2016 23:39
-
-
Save aheckmann/20a7f55022d659038cb4f830ad5f9c71 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
// run using this fork of NodeJS | |
// https://github.com/targos/node/commits/v8-5.4 (https://github.com/nodejs/node/pull/8317) | |
// | |
// node --harmony_async_await await_thenables.js | |
function counter(count) { | |
return { | |
then: function(res, rej) { | |
const p = Promise.resolve(count++); | |
return p.then(res, rej); | |
} | |
} | |
} | |
;(async function start() { | |
let incr = counter(1335); | |
console.log(await incr); // 1335 | |
console.log(await incr); // 1336 | |
console.log(await incr); // 1337 | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment