Projekt

Obecné

Profil

Stáhnout (833 Bajtů) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
var common = require('./common');
4
var EventEmitter = require('../');
5
var assert = require('assert');
6

    
7
var myEE = new EventEmitter();
8
var m = 0;
9
// This one comes last.
10
myEE.on('foo', common.mustCall(function () {
11
  assert.strictEqual(m, 2);
12
}));
13

    
14
// This one comes second.
15
myEE.prependListener('foo', common.mustCall(function () {
16
  assert.strictEqual(m++, 1);
17
}));
18

    
19
// This one comes first.
20
myEE.prependOnceListener('foo',
21
                         common.mustCall(function () {
22
                           assert.strictEqual(m++, 0);
23
                         }));
24

    
25
myEE.emit('foo');
26

    
27
// Verify that the listener must be a function
28
assert.throws(function () {
29
  var ee = new EventEmitter();
30
  ee.prependOnceListener('foo', null);
31
}, 'TypeError: The "listener" argument must be of type Function. Received type object');
(15-15/21)