Skip to content

Commit

Permalink
Make results an EventEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 22, 2011
1 parent 8a83240 commit 92c5cad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 10 additions & 6 deletions package.json
@@ -1,7 +1,11 @@
{ "name" : "tap-results"
, "version" : "0.0.1"
, "description" : "A util for keeping track of tap result objects"
, "main" : "./results.js"
, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
, "repository" : "https://github.com/isaacs/tap-results"
{
"name": "tap-results",
"version": "0.0.1",
"description": "A util for keeping track of tap result objects",
"main": "./results.js",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"repository": "https://github.com/isaacs/tap-results",
"dependencies": {
"inherits": "~1.0.0"
}
}
7 changes: 7 additions & 0 deletions results.js
Expand Up @@ -2,6 +2,11 @@

module.exports = Results

var inherits = require("inherits")
, EventEmitter = require("events").EventEmitter

inherits(Results, EventEmitter)

function Results (r) {
//console.error("result constructor", r)
this.ok = true
Expand Down Expand Up @@ -30,6 +35,7 @@ Results.prototype.addSet = function (r) {
this.ok = this.ok && r.ok && true
this.bailedOut = this.bailedOut || r.bailedOut || false
this.list = (this.list || []).concat(r.list || [])
this.emit("set", this.list)
//console.error("after addSet", this)
}

Expand Down Expand Up @@ -58,4 +64,5 @@ Results.prototype.add = function (r, addToList) {
if (addToList === false) return
this.list = this.list || []
this.list.push(r)
this.emit("result", r)
}

0 comments on commit 92c5cad

Please sign in to comment.