event-emitter
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -26,7 +26,14 @@ 'use strict'; | ||
var offt = off.bind(this), nlistener; | ||
if (!this[pname + ' once']) { | ||
defineProperty(this, pname + ' once', d('c', {})); | ||
} | ||
if (!this[pname + ' once'][type]) { | ||
this[pname + ' once'][type] = [[], []]; | ||
} | ||
nlistener = function nlistener() { | ||
offt(type, nlistener); | ||
offt(type, listener); | ||
listener.apply(this, arguments); | ||
}; | ||
nlistener[pname + ' listener'] = listener; | ||
this[pname + ' once'][type][0].push(nlistener[pname + ' listener'] = listener); | ||
this[pname + ' once'][type][1].push(nlistener); | ||
return on.call(this, type, nlistener); | ||
@@ -40,2 +47,8 @@ }; | ||
} | ||
ls = this[pname + ' once'] && this[pname + ' once'][type]; | ||
if (ls && ((index = ls[0].indexOf(listener)) !== -1)) { | ||
ls[0].splice(index, 1); | ||
off.call(this, type, ls[1][index]); | ||
ls[1].splice(index, 1); | ||
} | ||
return this; | ||
@@ -46,2 +59,3 @@ }; | ||
delete this[pname]; | ||
delete this[pname + ' once']; | ||
}); | ||
@@ -48,0 +62,0 @@ |
{ | ||
"name": "event-emitter", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Basic event emitter for Node.js and browser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -57,2 +57,5 @@ 'use strict'; | ||
o.once('test', a.never); | ||
o.off('test', a.never); | ||
o.emit('test'); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6787
175