class_LazyMan{queue: any[]=[];constructor(name: string){this.sayName(name);setTimeout(()=>{this.next();})}next(){const fn =this.queue.shift();
fn &&fn();}_holdOn(time){return()=>{setTimeout(()=>{
console.log(`Wake up after ${time} second`)this.next()}, time *1000)}}sayName(name){constfn=()=>{
console.log(`Hi! This is ${name}!`);this.next();}this.queue.push(fn);}sleep(time: number){this.queue.push(this._holdOn(time));returnthis;}eat(some: string){constfn=()=>{
console.log(`Eat ${some}~`);this.next();}this.queue.push(fn);returnthis;}sleepFirst(time: number){this.queue.unshift(this._holdOn(time));returnthis;}}constLazyMan=(name: string)=>new_LazyMan(name);LazyMan('Hank').sleepFirst(2).eat('dinner').sleep(3).eat('supper');