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

ev

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ev - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

5

History.md

@@ -0,1 +1,6 @@

0.0.3 / 2012-02-11
==================
* `once()` now passes arguments
0.0.2 / 2012-02-10

@@ -2,0 +7,0 @@ ==================

32

lib/ev.js

@@ -206,7 +206,31 @@ var maxLength = 3

EventEmitter.prototype.once = function (ev, handler) {
var self = this
var self = this, _handler
function _handler () {
self.off(ev, _handler)
handler()
switch ( this._ev_length[ev] ) {
case 0:
_handler = function () {
self.off(ev, _handler)
handler()
}
break
case 1:
_handler = function () {
self.off(ev, _handler)
handler(arguments[0])
}
break
case 2:
_handler = function () {
self.off(ev, _handler)
handler(arguments[0], arguments[1])
}
break
case 3:
_handler = function () {
self.off(ev, _handler)
handler(arguments[0], arguments[1], arguments[2])
}
break
default:
throw new Error('Invalid number of arguments:' + this._ev_length[ev] + ' for event: ' + ev)
}

@@ -213,0 +237,0 @@ _handler.handler = handler

2

package.json

@@ -6,3 +6,3 @@ {

, "keywords": ["event","emitter","listener"]
, "version": "0.0.2"
, "version": "0.0.3"
, "homepage": "http://github.com/pierrec/node-ev"

@@ -9,0 +9,0 @@ , "repository": {

@@ -41,2 +41,19 @@ /*

})
describe('arguments', function () {
var ev = new EV(options)
var args = []
it('should emit trigger the handler with all its arguments', function (done) {
function handler () {
args.push(arguments.length)
}
ev.once('match', handler)
ev.emit_match(null, null)
assert.deepEqual(args, [2])
done()
})
})
// TODO test once([ev1,ev2], listener)
})
# TODO
* Use linked objects for handlers:
this.fn
this.prev
this.protottype.exec = this.fn(args...); this.prev.exec(args...)
* `once([event1, event2...], listener)`: mutually exclusive listeners: any event will remove the listener to the other ones
* Use linked objects for handlers:
this.fn
this.prev
this.protottype.exec = this.fn(args...); this.prev.exec(args...)
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