var saveAnimal = function (animal){
		var getOwner = R.view(R.lensProp('owner'))
		var getVaccines = R.view(R.lensProp('vaccines'))

		var saveOwnerTask = saveObjectAndIdFor(db.owners, getOwner(animal))
		var saveVaccinesTask = saveObjectsAndIdsFor(db.vaccines, getVaccines(animal))

		var getFlatAnimalTask = R.lift(getFlatAnimal)(Task.of(animal), saveOwnerTask, saveVaccinesTask)
		var saveFlatAnimal = saveObjectAndIdFor(db.animals)

		return getFlatAnimalTask.chain(saveFlatAnimal)
}
示例#2
0
        it('should view the billing address name', () => {
            let billingAddressName = R.compose(billingAddress, name)
            let result = R.view(billingAddressName, user) 

            let output = "Home"
            expect(result).to.eql(output)
        })
示例#3
0
  create: (empty, vnode) => {
    const inData = view(inLens, vnode)

    if (inData) {
      const {className} = inData
      vnode.elm.className += ` ${className}`
    }
  },
示例#4
0
 it('should view the pet', () => {
     let result = R.view(pet, user) 
     let output = {
         name: "Nipper",
         type: "dog"
     }
     expect(result).to.eql(output)
 })
示例#5
0
export function treadmil(state) {
    const dxLens = R.lensProp('dx')
    const dyLens = R.lensProp('dy')
    const xPosLens = R.lensProp('x')
    const yPosLens = R.lensProp('y')
    const position = action.updatePosition({ x: R.view(dxLens, state),
                                             y: R.view(dyLens, state),
                                             velocity: state.velocity })
    const updatedState = R.compose(R.set(dxLens,
                                         R.view(xPosLens, position)),
                                   R.set(dyLens,
                                         R.view(yPosLens, position)))(state)
    let to = setTimeout(() => {
        renderer.scene(updatedState)
        clearTimeout(to)
        treadmil(updatedState)
    }, 60)
}
示例#6
0
 constructor(props) {
   super(props);
   const eventSupportsPropagation = R.view(
     R.lensPath(['nativeEvent', 'stopImmediatePropagation'])
   );
   this.handleClick = e => {
     if (eventSupportsPropagation(e)) e.nativeEvent.stopImmediatePropagation();
     this.props.toggleSlidingPanel();
   };
 }
示例#7
0
        res.on('end', () => {
          let object = JSON.parse(responseData);
          let meaning = R.view(firstMeaning, object);
          if (meaning) {

            resolve(meaning);
          } else {
            reject();
          }
        });
示例#8
0
 it('should view the billing address', () => {
     let result = R.view(billingAddress, user)
     let output = {
         name: "Home",
         number: 12,
         line1: "Rowan Place",
         country: "Colchester",
         city: "Essex",
         postcode: "CO1 1AJ"
     }
     expect(result).to.eql(output)
 })
示例#9
0
function main({DOM, Notify}) {
    const stop_ = DOM.select('#stop').events('click');
    const start_ = DOM.select('.start').events('click');

    const countDown_ =
        start_
            .map( e => event.target.dataset.time )
            .debug(console.log.bind(console))
            .map( () => {
            const timer_ = setTimer(.05);
            const timerWithEnd_ = timer_
                .endWhen(
                    xs.merge(
                        start_,
                        stop_,
                        timer_.filter( ({time}) => time < 0 )
                    )
                );

            return xs.merge(
                timerWithEnd_,
                timerWithEnd_
                    .last()
                    .map( pipe(set(typeL, STOP), set(endL, Date.now())) )
                    .debug(console.log.bind(console))
            )
        })
        .compose(flattenConcurrently);


    return {
        Notify: countDown_
            .filter( pipe(view(typeL), equals(STOP)) )
            .mapTo({msg: 'Hellllokk'}),

        DOM: countDown_
            .startWith({time: 0})
            .map(({time}) =>
                div('.container.text-center', [
                    h1('hello paradicsom'),
                    div('.row', [
                        button('.start.btn.btn-success-outline', {props: {time: 20}}, 'start 20 min'),
                        ' ',
                        //button('#stop.btn.btn-warning-outline', 'Pause!'),
                        ' ',
                        button('#stop.btn.btn-danger-outline', 'Stop!')
                    ]),
                    h1(formatTime(time))
                ])
            )
    };
}
示例#10
0
const identities = ( state = {}, action ) => {
	const { user } = action;
	switch ( action.type ) {
		case DESERIALIZE:
			return map( identityState => identity( identityState, action ), state );
		case UPDATE_IDENTITY:
		case SET_USER_OFFLINE:
			const lens = lensUser( action );
			return set_ramda(
				lens,
				identity( view( lens, state ), action )
			)( state );
		case SET_OPERATOR_REQUESTING_CHAT:
		case SET_OPERATOR_STATUS:
			return set_ramda(
				lensRemoteUser( action ),
				identity( view( lensRemoteUser( action ), state ), action )
			)( state );
		case REMOVE_USER:
			return omit( state, user.id );
		default:
			return state;
	}
};
示例#11
0
 render() {
   const expanded = R.view(
     makeExpandedLens(this.props),
     this.props.slidingPanel
   );
   return (
     <BaseSlidingPanelDropdown
       id={this.props.id}
       styles={this.props.styles}
       label={this.props.label}
       expanded={expanded}
       onClick={() => this.props.toggleFilterDropdown(this.props.id)}
     >
       {this.props.children}
     </BaseSlidingPanelDropdown>
   );
 }
示例#12
0
            ]).then(([owner,place])=> {
                var description = formatDescription(event.description);
                if (!place && owner) {
                    place = owner;
                } else if (!owner && place) {
                    owner = place;
                } else if (!place && !owner) {
                    place = owner = {};
                }
                place.seo_url = `/${SeoUrl.createURL(place.name)}`;
                owner.seo_url = `/${SeoUrl.createURL(owner.name)}`;

                return Object.assign({
                    image: R.view(R.lensPath(['cover', 'source']), event)
                }, event, {
                    description
                    , raw_description: event.description
                    , owner
                    , place
                })
            });
示例#13
0
      requests.push(function (callback) {

        var usd_btc = R.view(R.lensProp('btc_usd'), d.stats);
        var opp = {
          "spread"  : ( parseFloat(d.lower) - parseFloat(d.upper) ) - 100,
          "grow"    : d.grow.join(' '),
          "btc_usd" : usd_btc
        };
        var oppString = 'Spread: ' + opp['spread'] + "\n" + 'Currency Path: ' + opp['grow'] + "\n" + 'BTC Price: ' + opp['btc_usd'];

        request({
          url     : site_root,
          method  : 'POST',
          json    : opp,
          headers: {
            "Authorization": "Basic " + btoa(keyPair)
          }
        }, function (err, res, body) {
          console.log('Short Sell Share Opportunity:');
          console.log(oppString);
        });
      });
示例#14
0
        var findEvents = R.map(event=> {
                var place_id = event.place.id;
                var owner_id = event.owner.id;

                var place = R.find(place=>place.id_facebook.includes(place_id), my_places) || {};
                var owner = R.find(place=>place.id_facebook.includes(owner_id), my_places) || {};
                if (!place._id && owner._id) {
                    place = owner;
                } else if (!owner._id && place._id) {
                    owner = place;
                }
                place.seo_url = `/${SeoUrl.createURL(place.name)}`;
                owner.seo_url = `/${SeoUrl.createURL(owner.name)}`;
                var seo_url = `/${SeoUrl.createURL(event.name)}`;

                return Object.assign(event, {
                    image: R.view(R.lensPath(['cover', 'source']), event)
                    , seo_url
                    , owner
                    , place
                })

            }
示例#15
0
 it('focuses the specified object property', function() {
   eq(R.view(I.lensPath(['d']), testObj), 3);
   eq(R.view(I.lensPath(['a', 'b']), testObj), 2);
   eq(R.view(I.lensPath([]), testObj), testObj);
 });
示例#16
0
 state => ({ active: R.view(slidingPanelActiveLens, state) }),
示例#17
0
 state => ({ toggleIconState: R.view(slidingPanelActiveLens, state) }),
示例#18
0
 state => ({ slidingPanel: R.view(slidingPanelLens, state) }),
示例#19
0
文件: index.js 项目: sives/Plio
 status: async (milestone, args, { loaders: { Organization: { byId } } }) => {
   const { timezone } = await byId.load(view(organizationId, milestone));
   return getMilestoneStatus(timezone, milestone);
 },
示例#20
0
文件: index.js 项目: sives/Plio
import { view, compose, map } from 'ramda';
import { getMilestoneStatus } from '../../../../../share/helpers';

const {
  createdBy,
  updatedBy,
  notify,
  completedBy,
  organizationId,
  linkedTo,
  documentId,
} = lenses;

export default {
  Milestone: {
    createdBy: loadUserById(view(createdBy)),
    updatedBy: loadUserById(view(updatedBy)),
    organization: loadOrganizationById(view(organizationId)),
    notify: loadUsersById(view(notify)),
    completedBy: loadUserById(view(completedBy)),
    // TODO: subscribe cuz it may change over time
    status: async (milestone, args, { loaders: { Organization: { byId } } }) => {
      const { timezone } = await byId.load(view(organizationId, milestone));
      return getMilestoneStatus(timezone, milestone);
    },
    goals: loadGoalsById(compose(
      map(view(documentId)),
      view(linkedTo),
    )),
  },
};
示例#21
0
 it('get (set(set s v1) v2) === v2', function() {
   var p = 'd';
   var q = ['a', 'b'];
   eq(R.view(I.lensPath(p), R.set(I.lensPath(p), 11, R.set(I.lensPath(p), 10, testObj))), 11);
   eq(R.view(I.lensPath(q), R.set(I.lensPath(q), 11, R.set(I.lensPath(q), 10, testObj))), 11);
 });
示例#22
0
文件: index.js 项目: sives/Plio
 status: async (action, args, { loaders: { Organization: { byId } } }) => {
   const { timezone } = await byId.load(view(organizationId, action));
   return getActionStatus(timezone, action);
 },
示例#23
0
  INSTANTIATE_EFFECT,
  INSTANTIATE_INSTRUMENT,
  LOAD_PLUGIN_EFFECT,
  LOAD_PLUGIN_INSTRUMENT,
  REMOVE_CHANNEL,
  REMOVE_EFFECT_FROM_CHANNEL,
  REMOVE_INSTRUMENT_FROM_CHANNEL
} from '../actions'

const channelsLens = lensProp('channels')
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'))
	return stat;
	
};

const mapCountries = fnMap(persons, getCountry);
const reduceCountries = fnReduce(mapCountries, gatherStats, {});

console.log(reduceCountries);	// -> { US: 2, Hungary: 1, Greece: 1 }


var R = require('ramda');

const cityPath = ['address','city'];
const cityLens = R.lens(R.path(cityPath), R.assocPath(cityPath));

const cityStats = _(persons).map(R.view(cityLens)).reduce(gatherStats, {});


console.log(cityStats);		//  -> { undefined: 4 }


const c = _.groupBy(persons, R.view(cityLens));
console.log(c);

/*
	{ undefined: 
   [ Person {
       _firstname: 'Alonzo',
       _lastname: 'Church',
       _ssn: '444-44-4444',
       _address: [Object],
示例#25
0
import {lensProp, lensPath, view, lens, compose, over, toUpper, set} from 'ramda';
let log = console.log
const person = {
    firstName: 'loki',
    child: {
        firstName: 'dddd'
    }
}

const lensHa = lensPath(['child', 'firstName'])
const fLens = lensProp('firstName')
  
//到这里看跟 person.firstName完全一样。。
// view 是跟lensProp配套使用
const firstName = view(fLens, person) // => 'loki'

// len
const temperature = { fahrenheit: 68 }
const far2cel = far => (far - 32) * (5 / 9)

const cel2far = cel => (cel * 9) / 5 + 32

const fahrenheit = lensProp('fahrenheit')
const lcelsius = lens(far2cel, cel2far)
const celsius = compose(
  fahrenheit,
  lcelsius
)

log(view(celsius, temperature))// => 20
示例#26
0
 it('can be composed', function() {
   var composedLens = R.compose(I.lensPath('a'), I.lensPath('b'));
   eq(R.view(composedLens, testObj), 2);
 });
示例#27
0
文件: index.js 项目: sives/Plio
  updatedBy,
  completedBy,
  completionAssignedBy,
  verificationAssignedBy,
  deletedBy,
  toBeCompletedBy,
  toBeVerifiedBy,
  verifiedBy,
  notify,
  organizationId,
  ownerId,
} = lenses;

export default {
  Action: {
    createdBy: loadUserById(view(createdBy)),
    updatedBy: loadUserById(view(updatedBy)),
    completedBy: loadUserById(view(completedBy)),
    completionAssignedBy: loadUserById(view(completionAssignedBy)),
    verificationAssignedBy: loadUserById(view(verificationAssignedBy)),
    deletedBy: loadUserById(view(deletedBy)),
    toBeCompletedBy: loadUserById(view(toBeCompletedBy)),
    toBeVerifiedBy: loadUserById(view(toBeVerifiedBy)),
    verifiedBy: loadUserById(view(verifiedBy)),
    notify: loadUsersById(view(notify)),
    organization: loadOrganizationById(view(organizationId)),
    owner: loadUserById(view(ownerId)),
    // TODO: subscribe cuz it may change over time
    status: async (action, args, { loaders: { Organization: { byId } } }) => {
      const { timezone } = await byId.load(view(organizationId, action));
      return getActionStatus(timezone, action);
示例#28
0
 it('set s (get s) === s', function() {
   eq(R.set(I.lensPath('d'), R.view(I.lensPath('d'), testObj), testObj), testObj);
   eq(R.set(I.lensPath(['a', 'b']), R.view(I.lensPath(['a', 'b']), testObj), testObj), testObj);
 });
示例#29
0
文件: state.js 项目: sives/Plio
import { view } from 'ramda';
import { lenses } from 'plio-util';

export const getOrganizationId = view(lenses.organizations.organizationId);

export const getOrganization = view(lenses.organizations.organization);

export const getOrgSerialNumber = view(lenses.organizations.orgSerialNumber);

export const getRiskGuidelines = view(lenses.organizations.organization.rkGuidelines);

export const getNonConformitiesGuidelines = view(lenses.organizations.organization.ncGuidelines);
示例#30
0
 it('get (set s v) === v', function() {
   eq(R.view(I.lensPath('d'), R.set(I.lensPath('d'), 0, testObj)), 0);
   eq(R.view(I.lensPath(['a', 'b']), R.set(I.lensPath(['a', 'b']), 0, testObj)), 0);
 });