How to use events.on:
172 173 174 175 176 177 178 179 180 181
const emitter = new NodeEventTarget(); const interval = setInterval(() => { emitter.dispatchEvent(new Event('foo')); }, 0); let count = 0; for await (const [ item ] of on(emitter, 'foo')) { count++; strictEqual(item.type, 'foo'); if (count > 5) { break;
How to use events.default:
GitHub: ArilyChan/arilychan
3 4 5 6 7 8 9 10 11 12
}; Object.defineProperty(exports, "__esModule", { value: true }); exports.removeSong = exports.pushSong = exports.broadcast = exports.emitter = void 0; const events_1 = __importDefault(require("events")); const database_1 = require("../database"); exports.emitter = new events_1.default(); let lastBroadcasted; const broadcast = (ns, ...args) => exports.emitter.emit(ns, ...args); exports.broadcast = broadcast; const pushSong = (song) => {
How to use events.once:
42 43 44 45 46 47 48 49 50 51
process.nextTick(() => { ee.emit('error', expected); }); try { await once(ee, 'myevent'); } catch (_e) { err = _e; } strictEqual(err, expected);
How to use events.call:
431 432 433 434 435 436 437 438 439 440 441 442 443
exports.Decoder = Decoder; util.inherits(Encoder, EventEmitter); function Encoder() { EventEmitter.call(this); } /** * Encode streams to placeholder objects.
How to use events.listenerCount:
259 260 261 262 263 264 265 266 267 268
return [stream]; }; } var iceCandidateFunction = function (event) { var candidate = event.candidate; if (EventEmitter.listenerCount(self, 'icecandidate') || EventEmitter.listenerCount(self, 'candidategatheringdone')) { if (candidate) { var cand; if (multistream && usePlanB) { cand = interop.candidateToUnifiedPlan(candidate);
How to use events.EventEmitter:
GitHub: gmuteam/jsbint
252 253 254 255 256 257 258 259 260
urls, useESNextSyntax, warnings, extraModules = [], emitter = new events.EventEmitter(); function checkOption(name, t) { name = name.trim();
12
11
2
See more examples
How to use events.defaultMaxListeners:
3505 3506 3507 3508 3509 3510 3511 3512 3513 3514
// Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { if (!isUndefined(this._maxListeners)) { m = this._maxListeners; } else { m = EventEmitter.defaultMaxListeners; } if (m && m > 0 && this._events[type].length > m) { this._events[type].warned = true;
How to use events.prototype:
534 535 536 537 538 539 540 541 542 543 544
var EventEmitter = require('events').EventEmitter; var bind = require('component-bind'); var IOStream = require('./iostream'); var parser = require('./parser'); var debug = require('debug')('socket.io-stream:socket'); var emit = EventEmitter.prototype.emit; var on = EventEmitter.prototype.on; var slice = Array.prototype.slice;