if (_.min([options.port, options.sport]) >= 1024) { node.environment.LANDO_RESET_DIR = '/certs'; node.environment.LANDO_DROP_USER = 'node';
helpers_1.timeoutPromise(_.min([_this._errorCount * 5000, 30000])) .then(_this._getChatWorker) .then(_this._connectSub) .then(function () { _this.status = 'connected'; _this._updateUserCountLoop(); if (_this._conf.jwt) return _this._connectPub(); return _this; }).catch(function (err) { console.error('Couldn\'t connect, retrying', err); })
getMessages (author, id, limit, bypassPermissions) { return this.checkRead(author, bypassPermissions).then(() => { if (!bypassPermissions) { limit = _.min([limit, this.server.historyMaxGetMessages]) } return this.roomState.messagesGet(id, limit) }) }
function calculateDateRangeForStories(stories) { var timestamps = storiesToCompletedTimestamps(stories); var fromDate = _.min(timestamps); var toDate = _.max(timestamps); return createDateRange(fromDate, toDate); }
async _doActionResizeTerminal(parameters, session) { session.terminalCols = parameters.cols; session.terminalRows = parameters.rows; const terminal = this._terminals[parameters.applicationName]; if (!terminal) return; terminal.pty.resize( _.min(this._sessions.map(s => s.terminalCols)), _.min(this._sessions.map(s => s.terminalRows)) ); }
function calculateCycleTimeChartData(stories, dateRange) { var data = 'Data.CycleTimeChart = [\n'; var cycleTimes = []; _.each(dateRange, function (day) { _.each(stories, function (story) { if (story.completed_at.split('T')[0] === day) { var cycleTime = (new Date(story.completed_at).getTime() - new Date(story.started_at).getTime()) / MILLISECONDS_IN_A_DAY; cycleTimes.push(cycleTime); } }); if (day.split('-')[2] === '01') { data += ' [new Date("' + day + '"), ' + _.max(cycleTimes) + ', ' + _.mean(cycleTimes) + ', ' + _.min(cycleTimes) + '],\n'; cycleTimes = []; } }); data += '];\n'; return data; }
messagesGet (id, maxMessages = this.historyMaxGetMessages) { if (maxMessages <= 0) { return Promise.resolve([]) } id = _.max([0, id]) const lastid = this.lastMessageId id = _.min([id, lastid]) const end = lastid - id const len = _.min([maxMessages, end]) const start = _.max([0, end - len]) const msgs = this.messagesHistory.slice(start, end) const tss = this.messagesTimestamps.slice(start, end) const ids = this.messagesIds.slice(start, end) const data = [] for (let idx = 0; idx < msgs.length; idx++) { const msg = msgs[idx] const obj = _.cloneDeep(msg) msg.timestamp = tss[idx] msg.id = ids[idx] data[idx] = obj } return Promise.resolve(msgs) }
calcProbableValue(values) { let itemIndex while (values.length > 2) { const avg = _.mean(values) const min = _.min(values) const max = _.max(values) if ((min + max) / 2 === avg) { return avg } let maxDeviation = 0 _.forEach(values, (value, i) => { const deviation = Math.abs(value - avg) if (deviation > maxDeviation) { maxDeviation = deviation itemIndex = i } }) values.splice(itemIndex, 1) } return parseInt(_.mean(values)) }
_this.status = 'dispatcherError'; _this._errorCount++; return resolve(helpers_1.timeoutPromise(_.min([_this._errorCount * 5000, 30000])).then(_this._getChatWorker));