continuable-generators

0.1.8 • Public • Published

continuable-generators

build status NPM version dependency status

Experimental usage of generators for continuables

run takes a generator and returns a continuable. It's expected that the values you yield are continuables themself.

Example

// run this with --use-strict --harmony on node v0.11.2
let Redis = require("redis")
let console = require("console")
let list = require("continuable-list")
 
let client = Redis.createClient()
let async = require("../index")
 
async(function* () {
    yield client.hmset.bind(client, "blog::post", {
        date: "20130605",
        title: "g3n3rat0rs r0ck",
        tags: "js,node"
    })
 
    let post = yield client.hgetall.bind(client, "blog::post")
    let tags = post.tags.split(",")
    let taggedPosts = yield list(tags.map(function (tag) {
        return client.hgetall.bind(client, "post::tag::" + tag)
    }))
 
    return { post: post, taggedPosts: taggedPosts }
})(function (err, result) {
    if (err) {
        throw err
    }
 
    console.log("post", result.post, "taggedPosts", result.taggedPosts)
 
    client.quit()
})
 

Installation

npm install continuable-generators

Contributors

  • Raynos

MIT Licenced

Readme

Keywords

none

Package Sidebar

Install

npm i continuable-generators

Weekly Downloads

1

Version

0.1.8

License

none

Last publish

Collaborators

  • raynos