function sleep(ms) {
return new Promise((resolve)=> {
setTimeout(()=> {
resolve();
}, ms)
})
}
class Human {
async sayHello() {
await sleep(1000);
console.log('hello')
return this;
}
async sayBye() {
await sleep(1000);
console.log('bye');
return this;
}
}
(async ()=> {
await new Human().sayHello().sayBye();
})();
// => helloしか出力されない
asyncのメソッドをメソッドチェーンで書くのは不可能な模様?
babelの仕様なのかasync/awaitの仕様なのかは謎
return await this;
のようにしてもダメでした