1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
'use strict';
const common = require('../common');
var events = require('events');
var e = new events.EventEmitter();
e.once('hello', common.mustCall(function(a, b) {}));
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
var remove = function() {
common.fail('once->foo should not be emitted');
};
e.once('foo', remove);
e.removeListener('foo', remove);
e.emit('foo');
e.once('e', common.mustCall(function() {
e.emit('e');
}));
e.once('e', common.mustCall(function() {}));
e.emit('e');
|