LazyMan
class LazyMan {
tasks = []
constructor(name){
this.name = name
console.log(`I am ${name}`)
setTimeout(() => {
this.next()
})
}
next(){
const task = this.tasks.shift()
if(task) task()
}
do(sth){
const task = () => {
console.log(`do ${sth}`)
this.next()
}
this.tasks.push(task)
return this
}
sleep(delay){
const task = () => {
setTimeout(() => {
console.log(`sleep ${delay}s`)
this.next()
}, delay * 1000)
}
this.tasks.push(task)
return this
}
}
以自己现在的努力程度,还没有资格和别人拼天赋

浙公网安备 33010602011771号