var applyThenClause = function(scenario,then) { return R.over(R.lensProp('steps'),R.over(R.lensProp('Given'), R.map(function (condition){ if(intersects(then.text,condition.text).isGood){ return R.set(R.lensProp('reachable'),true,condition); } return condition; })),scenario); }
const selector = ( standardId, risks, usersByIds, riskTypesByIds, departmentsByIds, standardsByIds, ) => compose( map(compose( over(lenses.type, id => riskTypesByIds[id]), over(lenses.originator, id => getUserWithFullName(usersByIds[id])), over(lenses.owner, id => getUserWithFullName(usersByIds[id])), over(lenses.departments, map(compose( renameKeys({ name: 'title' }), id => departmentsByIds[id], ))), over(lenses.standards, map(id => standardsByIds[id])), over(lenses.analysis, compose( over(lenses.executor, id => getUserWithFullName(usersByIds[id])), over(lenses.completedBy, id => getUserWithFullName(usersByIds[id])), )), renameKeys({ ownerId: 'owner', originatorId: 'originator', typeId: 'type', departmentsIds: 'departments', standardsIds: 'standards', }), )), filter(where({ standardsIds: contains(standardId) })), )(risks);
module.exports = function processLayout(blockDefs, layoutString) { const parsedLayout = parseLayout(layoutString) return R.pipe( R.over( R.lensProp('blocks'), R.map(({ id, type, opts, gridRow='auto', gridColumn='auto' }) => { const { Component=() => h('div', { style: { backgroundColor: 'red' }, }, `No such block type: ${type}`), makeInputStream=through.obj, makeOutputStream=through.obj, processOpts=R.defaultTo({}, R.identity), defaultOpts={} } = (blockDefs[type] || {}) return { id, type, gridRow, gridColumn, block: { Component, makeInputStream, makeOutputStream, processOpts, }, defaultOpts: Object.assign({}, defaultOpts, opts), } }) ), R.over( R.lensProp('gridGap'), R.defaultTo('') ), R.over( R.lensProp('gridTemplateColumns'), R.defaultTo('') ), R.over( R.lensProp('gridTemplateRows'), R.defaultTo('') ), )(parsedLayout) }
const historyStateWithNewOrder = curry((state, newOrder) => pipe( hideConfigs, over( StateLenses.fieldsState, sort((f1, f2) => newOrder.indexOf(f1.id) - newOrder.indexOf(f2.id)) ) )(state));
onClick: () => { onValueChange(R.over( R.lensProp(field), cs => (cs || []).splice(i + 1, 0, emptyCreator), value )) }
const sign = curry((BitcoinLib, signingFunction, password, wallet, selection) => { const getPrivAcc = keypath => pathToKey(BitcoinLib, wallet, password, keypath); const getPrivAddr = address => getKeyForAddress(BitcoinLib, wallet, password, address); const getKeys = isFromAccount(selection) ? getPrivAcc : getPrivAddr; const selectionWithKeys = over(compose(lensProp('inputs'), mapped, lensProp('priv')), getKeys, selection); return signingFunction(selectionWithKeys); });
export const multivarka = (...reqBuildChain) => compose( tap(startRequest), over(lensProp('query'), RWhen( pathSatisfies(equals(0), ['$and', 'length']), omit(['$and']) )), ...reqBuildChain )(RequestType);
export const where = prop => apply( useWith( over(lensPath(['query', '$and'])), [ pipe(flip(call)([]), map(objOf(prop)), concat), identity ]) );
const reducer = (state: Object={}, action: Object) => { const {status, config:{identifier}, meta} = R.path(['meta', 'middleman'], action) if (status === 'complete') { const identifierLens = R.lensProp(identifier) return R.over(identifierLens, R.assoc('cursor', meta.cursor), state) } return state }
const appendOutput = ({visibles}, newOutput) => { const outputLens = lensProp('outputs'); const lastLens = lensIndex(-1); const appendNewOutput = compose(flatten, append(newOutput)); const updateLast = v => over(outputLens, appendNewOutput, v); return over(lastLens, updateLast, visibles); };
onClick: () => { onValueChange(R.over( R.lensProp(field), cs => (cs || []).length < 2 ? [emptyCreator] : cs.splice(i, 1), value )) }
function cycleTimeVTreeWithLists(lists) { return R.compose( cycleTimeVTree, R.over( R.lensIndex(0), R.map(getListNameFromId(lists)) ) ); }
const simulations = ( state: State = [], action: Action ): State => { if (action.error) return state switch (action.type) { case 'simulationStart': return [ ...state, { id: action.payload.id, netlist: action.payload.netlist, status: 'pending', progress: 0 } ] case 'simulationStop': return R.over( // focus on sim with specified id R.lensIndex(R.findIndex( R.propEq('id', action.payload.id) )(state)), R.set( R.lensProp('status'), 'cancelled' ), state ) case 'simulationStatus': return R.over( // focus on sim with specified id R.lensIndex(R.findIndex( R.propEq('id', action.payload.id) )(state)), R.set( R.lensProp('progress'), action.payload.progress ), state ) default: return state } }
}).add('ramda', function() { var rmd = R.compose( R.reverse, R.sortBy(R.prop("since")), R.map(R.over(R.lensProp("name"), R.toUpper)), R.filter(R.where({ name: R.test(/^tw/) })) )(companies); })
const frontend = (state = { repositories: [], commits: [] }, action) => { switch (action.type) { case CHANGE_PAGE: return _.set(lenses.page, action.page)(state) case ADD_REPOSITORY: return _.over(lenses.repositories, _.concat([action.repository]))(state) case TOGGLE_REPOSITORY: console.log(action) const doAction = _.compose(trace('lenses.repositories'), arrayToggle(action.name)) return _.over(lenses.repositories, doAction)(state) case ADD_COMMIT: return _.over(lenses.commits, _.concat(action.commit))(state) default: return state } }
const lens = curry((props, fn) => { if (typeof props === 'string') { props = props.split('.') } const _lens = (props.length > 1) ? lensPath(props) : lensProp(props[0]) return map(over(_lens, fn)) })
fetch(){ this.dotProgress() const concatState = compose(concat, this.currentState) Model. get(this.state.next). fork(log, compose( this.updateState, debug('state'), over(lensP, concatState('results'))) ) }
module.exports = R.curry((verb_index, insult_data) => R.compose( R.omit(['verbs']), R.assoc('plural', insult_data.verbs[verb_index].plural), R.over( verb_lens, R.compose( R.ifElse( () => insult_data.first_person, R.prop('first_person'), R.prop('third_person')), R.nth(verb_index)))) (insult_data))
const parseToGraph = R.curry((displayedLists, data) => R.compose( R.map(R.over(R.lensProp('key'), getListNameFromId(displayedLists))), R.filter((list) => R.contains( R.prop('key', list), R.pluck('id', displayedLists) )), R.map((list) => ({ key: list, values: R.map(parsedValueAtDate(list, data), R.pluck('date', data)), })), allLists, R.defaultTo([]) )(data)
function addAuthoritySymbols(dataset) { return R.over( R.lensProp('authorities'), R.map(authority => R.over( R.lensProp('periods'), R.map(R.assoc($$Authority, authority)), authority ) ), dataset ) }
.map(({ type, patch, id }) => { if (type._name !== 'AddAuthority') return patch; if (!(id in selectedPeriods)) return patch; return R.over( R.lensPath(['value', 'periods']), R.pipe( Object.entries, R.filter(([periodID]) => selectedPeriods[id][periodID]), R.fromPairs ), patch ) })
it('should uppercase the name and return the whole user', () => { let result = R.over(name, R.toUpper, user) let output = { name: "PHTEVEN", pet: { name: "Nipper", type: "dog" }, address: { billing: { name: "Home", number: 12, line1: "Rowan Place", country: "Colchester", city: "Essex", postcode: "CO1 1AJ" } } } expect(result).to.eql(output) })
it('should uppercase the billing address name and return the whole user', () => { let billingAddressName = R.compose(billingAddress, name) let result = R.over(billingAddressName, R.toUpper, user) let output = { name: "Phteven", pet: { name: "Nipper", type: "dog" }, address: { billing: { name: "HOME", number: 12, line1: "Rowan Place", country: "Colchester", city: "Essex", postcode: "CO1 1AJ" } } } expect(result).to.eql(output) })
it('should reverse the pet name and return the whole user', () => { let petName = R.compose(pet, name) let result = R.over(petName, R.reverse, user) let output = { name: "Phteven", pet: { name: "reppiN", type: "dog" }, address: { billing: { name: "Home", number: 12, line1: "Rowan Place", country: "Colchester", city: "Essex", postcode: "CO1 1AJ" } } } expect(result).to.eql(output) })
const updateLast = v => over(outputLens, appendNewOutput, v);
set: val$ => val$.map(val => ({mod: R.over(stateLens, R.always(val)), ID}))
mod: mod$ => mod$.map(mod => ({mod: R.over(stateLens, mod), ID})),
const getInitialValues = compose( spreadProp('analysis'), pick([ 'title', 'description', 'statusComment', 'magnitude', 'owner', 'originator', 'type', 'standards', 'departments', 'analysis', ]), over(lenses.owner, getUserOptions), over(lenses.originator, getUserOptions), over(lenses.type, getId), over(lenses.standards, mapEntitiesToOptions), over(lenses.departments, mapEntitiesToOptions), over(lenses.analysis, compose( pick([ 'targetDate', 'executor', 'completedBy', 'completionComments', 'completedAt', ]), over(lenses.executor, compose(getUserOptions, defaultTo({}))), over(lenses.completedBy, compose(getUserOptions, defaultTo({}))), )),
import R from 'ramda' const filterFields = R.pick(['name', 'options', 'strategy']); const filterOptions = R.over(R.lensProp('options'), R.pick(["customScripts"])); const prepareConnectionForDiff = R.compose(filterOptions, filterFields); export default prepareConnectionForDiff;
const effectsLens = lensProp('effects') const effectInstancesLens = lensProp('effectInstances') const instrumentInstancesLens = lensProp('instrumentInstances') const instrumentsLens = lensProp('instruments') const channels = view(channelsLens) const constructor = view(lensProp('constructor')) const destination = view(lensProp('destination')) const effects = view(effectsLens) const effectInstances = view(effectInstancesLens) const instance = view(lensProp('instance')) const instruments = view(instrumentsLens) const instrumentInstances = view(instrumentInstancesLens) const name = view(lensProp('name')) const overChannels = over(channelsLens) const overEffectInstances = over(effectInstancesLens) const overEffectPlugins = over(lensProp('effectPlugins')) const overEffects = over(effectsLens) const overInstrumentInstances = over(instrumentInstancesLens) const overInstrumentPlugins = over(lensProp('instrumentPlugins')) const overInstruments = over(instrumentsLens) const nameEquals = x => compose(equals(x), name) const findNameEquals = curry((x, y) => compose(find, nameEquals)(x)(y)) const findConstructor = compose(constructor, findNameEquals) const sortByName = sortBy(name) const overChannelEffects = curry((f, channelId, state) => overChannels( adjust(overEffects(f), findIndex(nameEquals(channelId), channels(state))), state