Skip to content
A Promises/A implementation based on streams
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test rejected test. Fixes #4
LICENCE stream example now uses domains. Badassery
index.js Added test for #3. Fixes #3
package.json 0.1.2


A Promises/A implementation based on streams

Promises and streams are the same thing. Except promises are far less powerful / flexible

Example using PromiseStream

var ReadStream = require("read-stream")
    , assert = require("assert")
    , Promise = require("promise-stream")

// one is a queue
var one = ReadStream()
    // Create a promise from one's stream.
    , pone = Promise(

var ptwo = pone.then(function (v) {
    assert(true, "one is fulfilled")
    console.log("one", v)

    return "two"
}, function (e) {
    assert(false, "one is not rejected")

var pthree = ptwo.then(function (v) {
    assert(true, "two is fulfilled")
    console.log("two", v)

    throw "three"
}, function (e) {
    assert(false, "two is not rejected")

var pfour = pthree.then(function (v) {
    assert(false, "three is not fulfilled")
}, function (e) {
    assert(true, "three is rejected")
    console.log("three", e)

// Flow data through one's queue

Same example using just streams and domains

var ReadWriteStream = require("read-write-stream")
    , assert = require("assert")
    , Domain = require("domain")

var domain = Domain.create() () {
    var one = ReadWriteStream()
        , two = ReadWriteStream(function write(chunk, queue) {
            console.log("one", chunk)
        , three = ReadWriteStream(function write(chunk, queue) {
            console.log("two", chunk)
        , four = ReadWriteStream()

    domain.on("error", function (err) {
        console.log("three", err)

    // Flow data through one's queu


npm install promise-stream


  • Raynos

MIT Licenced

Something went wrong with that request. Please try again.