function onunpipe(readable, unpipeInfo) { debug('onunpipe'); if (readable === src) { if (unpipeInfo && unpipeInfo.hasUnpiped === false) { unpipeInfo.hasUnpiped = true; cleanup(); } } }
function flow(stream) { const state = stream._readableState; debug('flow', state.flowing); while (state.flowing && stream.read() !== null); }
['get', 'set'].forEach( k => { redisClient[`${k}Async`] = promisify(redisClient[k]); } );
function updateItemName(item) { var attributes = getSignatureAttributes(item); var itemName = item.name || ''; if (item.variable) { itemName = '…' + itemName; } if (attributes && attributes.length) { itemName = util.format( '%s<span class="signature-attributes">%s</span>', itemName, attributes.join(', ') ); } return itemName; }
function checkMetricsPermission (cb) { /* istanbul ignore if: tracking intentionally disabled when running tests */ if (insight.optOut === undefined) { return promisify(insight.askPermission).call( insight, 'May Clinic.js report anonymous usage statistics to improve the tool over time?' ) } return Promise.resolve() }
async function uploadData (uploadURL, authToken, filename, opts) { // filename may either be .clinic-doctor.html or the data directory // .clinic-doctor const filePrefix = path.join(filename).replace(/\.html$/, '') const isPrivate = opts && opts.private console.log(`Uploading data for ${filePrefix} and ${filePrefix}.html`) const result = await tarAndUploadPromisified(path.resolve(filePrefix), uploadURL, authToken, { private: isPrivate }) result.url = `${uploadURL}${result.html}` return result }
function isRunning(pid, callback) { pid ? cp.exec(util.format(CHECK_RUNNING_CMD, pid), function (err, stdout, stderr) { callback(!err && !!stdout.toString().trim()); }) : callback(); }
function buildAttribsString(attribs) { var attribsString = ''; if (attribs && attribs.length) { attribsString = htmlsafe( util.format('(%s) ', attribs.join(', ')) ); } return attribsString; }
function resume_(stream, state) { if (!state.reading) { debug('resume read 0'); stream.read(0); } state.resumeScheduled = false; state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); }
stream.on('end', function() { debug('wrapped end'); if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) self.push(chunk); } self.push(null); });
// if the dest has an error, then stop piping into it. // however, don't suppress the throwing behavior for this. function onerror(er) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); if (EE.listenerCount(dest, 'error') === 0) dest.emit('error', er); }
function pipeOnDrain(src) { return function() { var state = src._readableState; debug('pipeOnDrain', state.awaitDrain); if (state.awaitDrain) state.awaitDrain--; if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { state.flowing = true; flow(src); } }; }
function emitReadable_(stream) { debug('emit readable'); stream.emit('readable'); flow(stream); }
function onfinish() { debug('onfinish'); dest.removeListener('close', onclose); unpipe(); }