2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-07-14 11:26:35 -04:00
|
|
|
const common = require('../common');
|
2010-10-12 23:52:26 +03:00
|
|
|
var events = require('events');
|
|
|
|
|
|
|
|
var e = new events.EventEmitter();
|
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
e.once('hello', common.mustCall(function(a, b) {}));
|
2010-10-12 23:52:26 +03:00
|
|
|
|
2010-12-05 22:15:30 +03:00
|
|
|
e.emit('hello', 'a', 'b');
|
|
|
|
e.emit('hello', 'a', 'b');
|
|
|
|
e.emit('hello', 'a', 'b');
|
|
|
|
e.emit('hello', 'a', 'b');
|
2010-10-12 23:52:26 +03:00
|
|
|
|
2011-03-18 21:02:14 +01:00
|
|
|
var remove = function() {
|
2016-07-14 11:26:35 -04:00
|
|
|
common.fail('once->foo should not be emitted');
|
2011-03-18 21:02:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
e.once('foo', remove);
|
|
|
|
e.removeListener('foo', remove);
|
|
|
|
e.emit('foo');
|
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
e.once('e', common.mustCall(function() {
|
2015-05-19 13:00:06 +02:00
|
|
|
e.emit('e');
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2013-11-12 12:19:13 -08:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
e.once('e', common.mustCall(function() {}));
|
2013-11-12 12:19:13 -08:00
|
|
|
|
|
|
|
e.emit('e');
|