|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
833 bytes
|
| Line | |
|---|
| 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');
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.