domain-browser
Advanced tools
Comparing version 1.1.2 to 1.1.3
11
index.js
@@ -10,2 +10,13 @@ /*global define:false require:false */ | ||
var d = new events.EventEmitter(); | ||
function emitError(e) { | ||
d.emit('error', e) | ||
} | ||
d.add = function(emitter){ | ||
emitter.on('error', emitError); | ||
} | ||
d.remove = function(emitter){ | ||
emitter.removeListener('error', emitError); | ||
} | ||
d.run = function(fn){ | ||
@@ -12,0 +23,0 @@ try { |
{ | ||
"title": "Node's [domain module](http://nodejs.org/api/domain.html) for the web browser", | ||
"name": "domain-browser", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Note, this is merely an evented try...catch with the same API as node. Nothing more.", | ||
@@ -41,3 +41,4 @@ "homepage": "https://github.com/bevry/domain-browser", | ||
"contributors": [ | ||
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)" | ||
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)", | ||
"substack (https://github.com/substack)" | ||
], | ||
@@ -44,0 +45,0 @@ "bugs": { |
@@ -42,3 +42,3 @@ | ||
- Install: `npm install --save domain-browser` | ||
- CDN URL: `//wzrd.in/bundle/domain-browser@1.1.2` | ||
- CDN URL: `//wzrd.in/bundle/domain-browser@1.1.3` | ||
@@ -85,2 +85,3 @@ ### [Ender](http://ender.jit.su/) | ||
- [Benjamin Lupton](https://github.com/balupton) <b@lupton.cc> — [view contributions](https://github.com/bevry/domain-browser/commits?author=balupton) | ||
- [substack](https://github.com/substack) — [view contributions](https://github.com/bevry/domain-browser/commits?author=substack) | ||
@@ -87,0 +88,0 @@ [Become a contributor!](https://github.com/bevry/domain-browser/blob/master/CONTRIBUTING.md#files) |
38
test.js
// Import | ||
var events = require('events'); | ||
var expect = require('chai').expect; | ||
@@ -20,2 +21,39 @@ var joe = require('joe'); | ||
}); | ||
it('should be able to add emitters', function(done){ | ||
var d = domain.create(); | ||
var emitter = new events.EventEmitter(); | ||
d.add(emitter); | ||
d.on('error', function (err) { | ||
expect(err && err.message).to.eql('an emitted error'); | ||
done(); | ||
}); | ||
emitter.emit('error', new Error('an emitted error')); | ||
}); | ||
it('should be able to remove emitters', function (done){ | ||
var emitter = new events.EventEmitter(); | ||
var d = domain.create(); | ||
d.add(emitter); | ||
var domainGotError = false; | ||
d.on('error', function (err) { | ||
domainGotError = true | ||
}); | ||
emitter.on('error', function (err) { | ||
expect(err && err.message).to.eql('This error should not go to the domain') | ||
// Make sure nothing race condition-y is happening | ||
setTimeout(function () { | ||
expect(domainGotError).to.eql(false) | ||
done() | ||
}, 0) | ||
}) | ||
d.remove(emitter); | ||
emitter.emit('error', new Error('This error should not go to the domain')); | ||
}) | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9703
80
102
1