function validate (opts) { if (!opts || !opts.appId) { throw Error('appId missing'); } if (opts.sort && !R.contains(opts.sort, R.values(c.sort))) { throw new Error('Invalid sort ' + opts.sort); } }
queueArray(queueObj, orderFilterLessThan) { return R.pipe( R.values, R.filter(orderFilterLessThan ? q => q.order < orderFilterLessThan : R.identity), R.sortBy(q => q.order), R.map(q => q.key) )(queueObj); }
function validate (opts) { if (opts.category && !R.contains(opts.category, R.values(c.category))) { throw Error('Invalid category ' + opts.category); } opts.collection = opts.collection || c.collection.TOP_FREE; if (!R.contains(opts.collection, R.values(c.collection))) { throw Error(`Invalid collection ${opts.collection}`); } if (opts.age && !R.contains(opts.age, R.values(c.age))) { throw Error(`Invalid age range ${opts.age}`); } }
fullKeyQueryAggregateMeasures() { const measureToHierarchy = this.collectRootMeasureToHieararchy(); const measuresToRender = (multiplied, cumulative) => R.pipe( R.values, R.flatten, R.filter( m => m.multiplied === multiplied && this.newMeasure(m.measure).isCumulative() === cumulative ), R.map(m => m.measure), R.uniq, R.map(m => this.newMeasure(m)) ); const multipliedMeasures = measuresToRender(true, false)(measureToHierarchy); const regularMeasures = measuresToRender(false, false)(measureToHierarchy); const cumulativeMeasures = R.pipe( R.map(multiplied => R.xprod([multiplied], measuresToRender(multiplied, true)(measureToHierarchy))), R.unnest )([false, true]); return { multipliedMeasures, regularMeasures, cumulativeMeasures }; }
['sum', 'avg', 'count', 'number'].indexOf(m.type) !== -1 ), R.values ); const joinRequired =
function mapStateToProps(state){ const meals = values(state.entities.meals); return {meals}; }
net.on('netInfoBlockchainLength', (length, address) => { if (length >= blockchain.getLength()) { this.netInfoBlockchainLengths[address] = length storage.session.netInfoBlockchainLength = helper.calcProbableValue(R.values(this.netInfoBlockchainLengths)) // this.log('Received blockchain length. ACCEPT. Probable length', storage.session.netInfoBlockchainLength) } else { // this.log('Received blockchain length. REJECT') } })
const getSquashedScore = async (metrics) => ({ lighthouse: R.pipe( R.map((metric) => R.sum(R.values(metric))), R.sum, R.divide(R.__, R.length(metrics) * R.length(R.keys(R.head(metrics)))), R.curry(Math.round), )(metrics), })
async function getModelCount(ctx) { // * v1 // const count = {} // forEachObjIndexed(async (model, modelName) => { // count[modelName] = await model.count() // }, ctx.app.model.models) // * v2 // const models = ctx.app.model.models // const names = keys(models) // const toCountPromises = map(m => m.count(), values(models)) // const _values = await Promise.all(toCountPromises) // ctx.body = zipObj(names, _values) // * v3 const models = ctx.app.model.models const getValuePromises = R.pipe(R.values, R.map(R.invoker(0, 'count'))) const names = keys(models) const values = await Promise.all(getValuePromises(models)) ctx.body = R.zipObj(names, values) }
function newMeal(state){ const meals = pluck("name", values(state)), id = meals.length, name = `New Meal #${filterStartsWith("New Meal",meals).length}`; return { id, name, protein: 22, fat: 22, carbs: 22, fiber: 22, calories: 200, ingredients:[]}; }
const commonRules = input => ({ healthy: [[isBoolean, "Healthy should be a boolean"]], info: [[R.either(R.isNil, isObject), "Info should be an object"]], dependentOn: R.contains(input.type, DEPENDENT_ON_REQUIRED_TYPES) ? [ [isString, "DependentOn should be a string"], [ notEmpty, `DependentOn is required when type is one of ${DEPENDENT_ON_REQUIRED_TYPES.join( ", " )}` ] ] : [ [ R.isNil, `DependentOn should be omitted when type is one of ${R.values( R.omit(DEPENDENT_ON_REQUIRED_TYPES, types) ).join(", ")}` ] ] })
const Basket = ({ basket, removeItem, updateItem, clearAllItems }) => { const items = values(basket); return ( <Container> {items && items.map(item => ( <BasketItem key={item.id} item={item} handlers={{ removeItem, updateItem }} /> ))} <BasketTotal items={items} clearAllItems={clearAllItems} /> </Container> ); }
/* Miner */ this.server.addMethod('getMiningTask', (params, callback) => { const requestId = this.lastRequestId++ this.log('#' + requestId + ' Rcvd getMiningTask, nonce=' + params.nonce + ', hps=' + params.hps) storage.trigger('minerReqTask') if ((params.nonce !== undefined) && (params.hps !== undefined)) { storage.session.stat.hpsList[params.nonce] = params.hps storage.session.stat.hps = helper.countToStr(R.reduce((a, b) => a + b, 0, R.values(storage.session.stat.hpsList))) } if (storage.miningTask && storage.miningTask.active && !storage.session.forkProcessor) { this.log('#' + requestId + ' Sent {green-fg}active=1{/green-fg}') callback(null, storage.miningTask) } else { this.log('#' + requestId + ' Sent {red-fg}active=0{/red-fg}') callback(null, { active: 0 }) } })
start += field.size return acc + field.size }, 0, R.values(this.fields))
R.values(packageConductors).map(packageDevelopConductor => packageDevelopConductor.stop(), ),