Exemplo n.º 1
0
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);
    
}
Exemplo n.º 2
0
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);
Exemplo n.º 3
0
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)
}
Exemplo n.º 4
0
const historyStateWithNewOrder = curry((state, newOrder) => pipe(
  hideConfigs,
  over(
    StateLenses.fieldsState,
    sort((f1, f2) => newOrder.indexOf(f1.id) - newOrder.indexOf(f2.id))
  )
)(state));
Exemplo n.º 5
0
 onClick: () => {
   onValueChange(R.over(
     R.lensProp(field),
     cs => (cs || []).splice(i + 1, 0, emptyCreator),
     value
   ))
 }
Exemplo n.º 6
0
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);
});
Exemplo n.º 7
0
export const multivarka = (...reqBuildChain) => compose(
  tap(startRequest),
  over(lensProp('query'), RWhen(
    pathSatisfies(equals(0), ['$and', 'length']),
    omit(['$and'])
  )),
  ...reqBuildChain
)(RequestType);
Exemplo n.º 8
0
export const where = prop => apply(
  useWith(
    over(lensPath(['query', '$and'])),
    [
      pipe(flip(call)([]), map(objOf(prop)), concat),
      identity
    ])
);
Exemplo n.º 9
0
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
}
Exemplo n.º 10
0
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);
};
Exemplo n.º 11
0
 onClick: () => {
   onValueChange(R.over(
     R.lensProp(field),
     cs => (cs || []).length < 2
       ? [emptyCreator]
       : cs.splice(i, 1),
     value
   ))
 }
Exemplo n.º 12
0
function cycleTimeVTreeWithLists(lists) {
  return R.compose(
    cycleTimeVTree,
    R.over(
      R.lensIndex(0),
      R.map(getListNameFromId(lists))
    )
  );
}
Exemplo n.º 13
0
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
  }
}
Exemplo n.º 14
0
}).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);
})
Exemplo n.º 15
0
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
  }
}
Exemplo n.º 16
0
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))
})
Exemplo n.º 17
0
 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')))
           )
 }
Exemplo n.º 18
0
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))
Exemplo n.º 19
0
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)
Exemplo n.º 20
0
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
  )
}
Exemplo n.º 21
0
      .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
        )
      })
Exemplo n.º 22
0
        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)
        })
Exemplo n.º 23
0
        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)
        })
Exemplo n.º 24
0
        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)
        })
Exemplo n.º 25
0
 const updateLast = v => over(outputLens, appendNewOutput, v);
Exemplo n.º 26
0
 set: val$ => val$.map(val => ({mod: R.over(stateLens, R.always(val)), ID}))
Exemplo n.º 27
0
 mod: mod$ => mod$.map(mod => ({mod: R.over(stateLens, mod), ID})),
Exemplo n.º 28
0
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;
Exemplo n.º 30
0
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