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

ee-first

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-first - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

44

index.js

@@ -8,9 +8,14 @@

stuff.forEach(function (arr) {
for (var i = 0; i < stuff.length; i++) {
var arr = stuff[i]
if (!Array.isArray(arr) || arr.length < 2)
throw new TypeError('each array member must be [ee, events...]')
var ee = arr.shift()
var ee = arr[0]
arr.forEach(function (event) {
for (var j = 1; j < arr.length; j++) {
var event = arr[j]
var fn = listener(event, cleanup)
// listen to the event

@@ -24,11 +29,5 @@ ee.on(event, fn)

})
}
}
function fn(err) {
cleanup()
if (event === 'error') return done(err, ee, 'error')
done(null, ee, event)
}
})
})
return function (fn) {

@@ -39,7 +38,26 @@ done = fn

function cleanup() {
while (cleanups.length) {
var x = cleanups.shift()
var x
for (var i = 0; i < cleanups.length; i++) {
x = cleanups[i]
x.ee.removeListener(x.event, x.fn)
}
done.apply(null, arguments)
}
}
function listener(event, done) {
return function onevent(arg1) {
var args = new Array(arguments.length)
var ee = this
var err = event === 'error'
? arg1
: null
// copy args to prevent arguments escaping scope
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i]
}
done(err, ee, event, args)
}
}
{
"name": "ee-first",
"description": "return the first event in a set of ee/event pairs",
"version": "1.0.2",
"version": "1.0.3",
"author": {

@@ -6,0 +6,0 @@ "name": "Jonathan Ong",

@@ -17,6 +17,7 @@

[ee3, 'a', 'b', 'c'],
], function (err, ee, event) {
], function (err, ee, event, args) {
assert.ifError(err)
assert.equal(ee, ee2)
assert.equal(event, 'b')
assert.deepEqual(args, [1, 2, 3])
done()

@@ -33,3 +34,3 @@ })

[ee3, 'error', 'b', 'c'],
], function (err, ee, event) {
], function (err, ee, event, args) {
assert.equal(err.message, 'boom')

@@ -49,3 +50,3 @@ assert.equal(ee, ee3)

[ee3, 'a', 'b', 'c'],
], function (err, ee, event) {
], function (err, ee, event, args) {
assert.ifError(err)

@@ -52,0 +53,0 @@ ;[ee1, ee2, ee3].forEach(function (ee) {

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