source: trip-planner-front/node_modules/events/tests/prepend.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 833 bytes
Line 
1'use strict';
2
3var common = require('./common');
4var EventEmitter = require('../');
5var assert = require('assert');
6
7var myEE = new EventEmitter();
8var m = 0;
9// This one comes last.
10myEE.on('foo', common.mustCall(function () {
11 assert.strictEqual(m, 2);
12}));
13
14// This one comes second.
15myEE.prependListener('foo', common.mustCall(function () {
16 assert.strictEqual(m++, 1);
17}));
18
19// This one comes first.
20myEE.prependOnceListener('foo',
21 common.mustCall(function () {
22 assert.strictEqual(m++, 0);
23 }));
24
25myEE.emit('foo');
26
27// Verify that the listener must be a function
28assert.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.