Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eventemitter-ex

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventemitter-ex - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

10

EventEmitterEx.js

@@ -278,2 +278,12 @@ 'use strict';

EventEmitterEx.fromPromiseFunc = function fromPromiseFunc (f) {
var eex = new EventEmitterEx();
setImmediate(function () {
f(eex).then(eex.emit.bind(eex, 'end'), eex.emit.bind(eex, 'error'));
});
return eex;
};
function assertIsFunction (f) {

@@ -280,0 +290,0 @@ if (typeof f !== 'function')

4

package.json
{
"name": "eventemitter-ex",
"version": "1.2.0",
"version": "1.3.0",
"description": "EventEmitter extensions",

@@ -31,3 +31,3 @@ "main": "EventEmitterEx.js",

"author": "Mikhail Mazurskiy <mikhail.mazursky@gmail.com> (ash2k.com)",
"license": "Apache 2",
"license": "Apache-2.0",
"devDependencies": {

@@ -34,0 +34,0 @@ "chai": "2.x.x",

@@ -98,2 +98,48 @@ 'use strict';

describe('#fromPromiseFunc()', function () {
it('should emit end when promise is resolved', function (done) {
var eex = EEX.fromPromiseFunc(function () {
return Promise.resolve(42);
});
eex
.on('end', function (res) {
res.should.equal(42);
done();
})
.on('error', done);
});
it('should emit error when promise is rejected', function (done) {
var ERROR = new Error('Boom!');
var eex = EEX.fromPromiseFunc(function () {
return Promise.reject(ERROR);
});
eex
.on('error', function (err) {
err.should.equal(ERROR);
done();
})
.on('end', function () {
done(new Error('WTF?'));
});
});
it('should pass emitter as argument', function (done) {
var A = 34;
var eex = EEX.fromPromiseFunc(function (em) {
em.emit('data', A);
return Promise.resolve(42);
});
eex
.on('data', function (a) {
a.should.be.equal(A);
done();
})
.on('error', done);
});
});
});

@@ -100,0 +146,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc