0.1.8 • Published 11 years ago

continuable-generators v0.1.8

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

continuable-generators

NPM version

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 --harmony on node v0.11.2
var Redis = require("redis")
var console = require("console")
var list = require("continuable-list")
var of = require("continuable/of")

var client = Redis.createClient()
var run = require("../index")

run(function*() {
    yield client.hmset.bind(client, "blog::post", {
        date: "20130605",
        title: "g3n3rat0rs r0ck",
        tags: "js,node"
    })

    var post = yield client.hgetall.bind(client, "blog::post")
    var tags = post.tags.split(",")
    var taggedPosts = yield list(tags.map(function (tag) {
        return client.hgetall.bind(client, "post::tag::" + tag)
    }))

    return of({ 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

0.1.8

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago