sendDefferedMethodCall() { if (this.pendingRequests.length > 0) { this.isRequestPending = true; const nextRequest = this.pendingRequests.shift(); this.sendMethodCall(nextRequest.methodName, nextRequest.parameters) .then(nextRequest.resolve) .catch(nextRequest.reject); } }
_.each(values, (value, seriesName) => { if (!this.series[seriesName]) { return; } if (this._isHighwater(seriesName)) { this.series[seriesName].y = _.times(this.limit, _.constant(value)); } else { this.series[seriesName].y.shift(); this.series[seriesName].y.push(value); } });
test('fatal method should call async when sync-flushing fails', ({ equal, fail, doesNotThrow, plan }) => { plan(2) const messages = [ 'this is fatal 1' ] const stream = sink((result) => equal(result.msg, messages.shift())) stream.flushSync = () => { throw new Error('Error') } stream.flush = () => fail('flush should be called') const instance = pino(stream) doesNotThrow(() => instance.fatal(messages[0])) })
bench1.run() .then(() => { if (dataFiles.length > 0) return runTest(dataFiles.shift()); })
co(function * (o) { o = o || {}; const args = []; args.push.apply(args, arguments) && args.shift(); // grab alias to chosen source type const arr = this._[opts.files ? 'files' : 'globs']; // wrapper pass all arguments to plugin func const run = s => co(func).apply(this, [s, o].concat(args)); // loop thru EACH if `every`, else send full source array yield (opts.every ? Promise.all(arr.map(run)) : run(arr)); // send back instance allow chain return this; })
const formatSize = size => { let sizes = [[2, 'M'], [1, 'k']]; while (sizes.length) { let checkSize = sizes.shift(); let limit = Math.pow(1024, checkSize[0]); if (size > limit) { return `${(size / limit).toFixed(2)} ${checkSize[1]}B` } } return `${size} B`; }
runner.on( 'suite end', function ( suite ) { if ( suite.root ) { return; } stack.shift(); } );
Object.keys(update).forEach((fieldName) => { if (fieldName.indexOf('.') > -1) { const components = fieldName.split('.'); const first = components.shift(); dotNotationOptions[first] = true; } else { dotNotationOptions[fieldName] = false; } });
function runTest(dataName) { return Promise.resolve() .then(() => Promise.mapSeries([ "Fake", "NATS", "Redis", "MQTT", "TCP" ], transporter => measureTP(transporter, dataName))) .then(() => { if (dataFiles.length > 0) runTest(dataFiles.shift()); }); }
event.dispatcher.on(event.step.started, (step) => { output.stepShift = 3; const printMetaStep = (metaStep) => { if (!metaStep) return currentMetaStep.shift(); if (currentMetaStep.indexOf(metaStep.toString()) >= 0) return; // step is the same if (metaStep.metaStep) { printMetaStep(metaStep.metaStep); } currentMetaStep.unshift(metaStep.toString()); output.step(metaStep); }; printMetaStep(step.metaStep); output.step(step); });
test('resets levels from labels to numbers', async ({ is }) => { const expected = [{ level: 30, msg: 'hello world' }] pino({ useLevelLabels: true }) const instance = pino({ useLevelLabels: false }, sink((result, enc, cb) => { const current = expected.shift() check(is, result, current.level, current.msg) cb() })) instance.info('hello world') })
_.each(data, (values) => { _.each(values, (value, seriesName) => { if (!this.series[seriesName]) { return; } if (!this._isHighwater(seriesName)) { this.series[seriesName].y.shift(); this.series[seriesName].y.push(value); } }); });
run() { if (this.queue.length === 0) return Promise.resolve(); return this.execute(this.queue.shift()); }
Object.keys(update).forEach(fieldName => { if (fieldName.indexOf('.') > -1) { const components = fieldName.split('.'); const first = components.shift(); dotNotationOptions[first] = true; } else { dotNotationOptions[fieldName] = false; } });
co(function * (o) { o = o || {}; const args = []; args.push.apply(args, arguments) && args.shift(); // grab alias to chosen source type const arr = this._[opts.files ? 'files' : 'globs']; // wrapper pass all arguments to plugin func const run = s => co(func).apply(this, [s, o].concat(args)); // loop thru EACH if `every`, else send full source array yield (opts.every ? Promise.all(arr.map(run)) : run(arr)); // send back instance allow chain return this; })