summaryrefslogtreecommitdiff
path: root/test/simple/test-event-emitter-once.js
blob: 204b2d6c303a82a3a2374102cf875500198e17eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var common = require('../common');
var assert = require('assert');
var events = require('events');

var e = new events.EventEmitter();
var times_hello_emited = 0;

e.once('hello', function(a, b) {
  times_hello_emited++;
});

e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');

process.addListener('exit', function() {
  assert.equal(1, times_hello_emited);
});