/* * Get the count of follows a user has * * @param {object} state Global state tree * @returns {Integer} Follow count */ const getReaderFollowsCount = ( state ) => Math.max( state.reader.follows.itemsCount, size( filter( state.reader.follows.items, { is_following: true } ) ) )
keyedReducer( 'seed', withoutPersistence( ( state = null, action ) => { switch ( action.type ) { case READER_RECOMMENDED_SITES_RECEIVE: return Math.max( action.payload.offset, state ); } return state; } ) )
// q is assumed to be normalized // clamp, to handle numerical problems function clamp( x ) { return Math.min( Math.max( x, -1 ), 1 ); }
// Set the volume to some value in [0, 1] setVolume (volume) { // check if its in [0.0 - 1.0] range volume = Math.max(0, Math.min(1, volume)) const state = this.state if (isCasting(state)) { Cast.setVolume(volume) } else { state.playing.setVolume = volume } }
handleFetchTransferSummaryError() { let nextInterval = config.torrentClientPollInterval || 2000; // If more than consecutive errors have occurred, then we delay the next // request. if (++this.errorCount >= 3) { nextInterval = Math.max(nextInterval + (this.errorCount * nextInterval) / 4, 1000 * 60); } this.deferFetchTransferSummary(nextInterval); this.emit(historyServiceEvents.FETCH_TRANSFER_SUMMARY_ERROR); }
generateColumnData(source) { let size = _.reduce(source, (o, arr) => { return Math.max(o, arr.length); }, 0); let range = new Array(size).fill(0); return _.map(source, (v, k) => ([k].concat(v).concat(range)).slice(0, size + 1)); }
$export($export.S, 'Math', { clamp: function clamp(x, lower, upper) { return Math.min(upper, Math.max(lower, x)); } });
const getMax = arr => { if (arr.size === 0) { return -1; } return Math.max.apply(Math, arr.toJS().map(o => o._temp__id)); }
function xor(a, b) { const length = Math.max(a.length, b.length) const buffer = Buffer.allocUnsafe(length) for (let i = 0; i < length; i++) buffer[i] = a[i] ^ b[i] return buffer }
getAlignedTexts(str, space) { const len = str.length; let left; if (len <= space) left = str + r(" ", space - len); else { left = str.slice(0, Math.max(space - 3, 0)); left += r(".", Math.min(3, space)); } return left; }
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) // clamp, to handle numerical problems function clamp( x ) { return Math.min( Math.max( x, -1 ), 1 ); }
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) // clamp, to handle numerical problems function clamp( x ) { return Math.min( Math.max( x, -1 ), 1 ); }
const clampNumber = (num: number, min: number, max: number) => { if (typeof num === 'undefined') { return min; } num = Math.min(num, max); num = Math.max(num, min); return num; }