/** * Increments max listeners by one, if they are not zero. * @private */ incrementMaxListeners() { const maxListeners = this.getMaxListeners(); if (maxListeners !== 0) { this.setMaxListeners(maxListeners + 1); } }
constructor(...eventEmitterConfig) { super(...eventEmitterConfig); this.dispatcherID = null; this.on('uncaughtException', error => { throw new Error(error); }); this.requests = {}; this.setMaxListeners(20); }
cleanup(st) { st.buffer = []; st.removeListener('end', () => this.onEnd(st)); st.removeListener('error', err => this.onError(err, st)); st.setMaxListeners(st.getMaxListeners() - 1); }
constructor(options = {}) { super(); this.name = options.name; this.type = options.type; this.options = options; theme(this); timer(this); this.state = new State(this); this.initial = [options.initial, options.default].find(v => v != null); this.stdout = options.stdout || process.stdout; this.stdin = options.stdin || process.stdin; this.scale = options.scale || 1; this.term = this.options.term || process.env.TERM_PROGRAM; this.margin = margin(this.options.margin); this.setMaxListeners(0); setOptions(this); }
test('stubs write, flush and ee methods on instance', ({ end, ok, is }) => { const instance = pino() ok(isFunc(instance.setMaxListeners)) ok(isFunc(instance.getMaxListeners)) ok(isFunc(instance.emit)) ok(isFunc(instance.addListener)) ok(isFunc(instance.on)) ok(isFunc(instance.prependListener)) ok(isFunc(instance.once)) ok(isFunc(instance.prependOnceListener)) ok(isFunc(instance.removeListener)) ok(isFunc(instance.removeAllListeners)) ok(isFunc(instance.listeners)) ok(isFunc(instance.listenerCount)) ok(isFunc(instance.eventNames)) ok(isFunc(instance.write)) ok(isFunc(instance.flush)) is(instance.on(), undefined) end() })
function I18N() { if ( ! ( this instanceof I18N ) ) { return new I18N(); } this.defaultLocaleSlug = 'en'; // Tannin always needs a plural form definition, or it fails when dealing with plurals. this.defaultPluralForms = ( n ) => ( n === 1 ? 0 : 1 ); this.state = { numberFormatSettings: {}, tannin: undefined, locale: undefined, localeSlug: undefined, textDirection: undefined, translations: LRU( { max: 100 } ), }; this.componentUpdateHooks = []; this.translateHooks = []; this.stateObserver = new EventEmitter(); // Because the higher-order component can wrap a ton of React components, // we need to bump the number of listeners to infinity and beyond // FIXME: still valid? this.stateObserver.setMaxListeners( 0 ); // default configuration this.configure(); }
_transform(chunk, encoding, done) { if (chunk instanceof Buffer) { this.queue.push(chunk); } else if (typeof this.fn !== 'function') { if (chunk.name) { this.emit( 'error', new Error('Please provide transform function') ); } } else { const st = this.fn(chunk); // Consume streams in parallel if (st instanceof stream) { st.buffer = []; const onData = data => { data = data instanceof Buffer ? data : Buffer.from(data); st.buffer.push(data); }; st.setMaxListeners(st.getMaxListeners() + 1); st.on('data', onData); st.on('error', err => this.onError(err, st)); } // Process streams in series this.queue.push(st); } this.next(); done(); }
setProperty(safeProcess, "getMaxListeners", GenericFunction.bind(realProcess.getMaxListeners, realProcess)) setProperty(safeProcess, "once", GenericFunction.bind(realProcess.once, realProcess)) setProperty(safeProcess, "setMaxListeners", GenericFunction.bind(realProcess.setMaxListeners, realProcess)) setProperty(safeProcess, "versions", safe(safeProcess.versions))
this.loadPort = channels[1].port2; this.inferencePort = channels[2].port2; this.inferencePort.setMaxListeners(1000000); this.once('online', () => { this.initPort.once('close', () => {
this.session = session; this.logger.info("AMQP10 is connected"); this.connection._connection.setMaxListeners(0); this.session._session.setMaxListeners(0); this.session.setMaxListeners(0); this.connected = true; return this.onConnected();
function onExit() { setMaxListeners(Math.max(getMaxListeners() - 1, 0))
function setup(t, env) { const _env = process.env; delete process.env.NTL_NO_RERUN_CACHE; // avoid listeners warning process.stdin.setMaxListeners(13); process.env = { ...process.env, ...env }; t.teardown(() => { process.env = _env; }); }
it('init', () => { process.setMaxListeners(0); });
this.setMaxListeners(0);
/** * Decrements max listeners by one, if they are not zero. * @private */ decrementMaxListeners() { const maxListeners = this.getMaxListeners(); if (maxListeners !== 0) { this.setMaxListeners(maxListeners - 1); } }