jmar777 / suspend

Callback-free control flow for Node using ES6 generators.
548 stars 22 forks source link

Just a fake, may have another better way #25

Open skyblue opened 9 years ago

skyblue commented 9 years ago

eg:

    this.sleep = function(ms, cb){
        setTimeout(cb, ms)
    }
    suspend.run(function*(resume) {
        yield this.sleep(1000, resume())
    }, function(err, ret) {
        return next(err, ret)
    }, this)