How to use the propOr function from ramda

Find comprehensive JavaScript ramda.propOr code examples handpicked from public code repositorys.

351
352
353
354
355
356
357
358
359
360
willSendResponse: data => {
  const { response } = data;
  newrelic.addCustomAttribute(
    'errorCount',
    R.pipe(
      R.propOr([], 'errors'),
      R.length
    )(response)
  );
}
fork icon142
star icon475
watch icon0

+ 4 other calls in file

55
56
57
58
59
60
61
62
63
64

fs.writeFileSync(
  path.join(JSX_OUTPUT, `${chapterBasename}.jsx`),
  wrapChapterInTemplate(
    jsxElements,
    R.propOr("Untitled Chapter", "sectionName", linkData)
  )
);
return {
  module: `${chapterBasename}`,
fork icon16
star icon19
watch icon4

+ 6 other calls in file

65
66
67
68
69
70
71
72
73
    isSensitive =
      typeof isSensitive === 'string' ? isSensitive === 'true' : isSensitive; // handle string and bool value ('true', 'false', true or false)
  }
  return {
    ...reqBodyWithoutId,
    geology: ramda.propOr('Q35758', 'geology', req.body),
    isSensitive,
  };
},
fork icon2
star icon13
watch icon8

+ 377 other calls in file

293
294
295
296
297
298
299
300
301
302
303
304
function pathOr$1 (defaultValue, path, obj) {
  return R.pathOr(defaultValue, path, obj)
}


function propOr$1 (defaultValue, key, obj) {
  return R.propOr(defaultValue, key, obj)
}


function findIndex$1 (list, fn) {
  return R.findIndex(fn)(list)
fork icon2
star icon5
watch icon3

93
94
95
96
97
98
99
100
101
102
  return search.get('results');
});
var searchByKey = (0, _reselect.createSelector)(getResults, getQueryID, function (results, key) {
  return results.get(key) ? results.get(key).toObject() : EMPTY_OBJ;
});
var getSearchCountry = (0, _reselect.createSelector)(searchByKey, R.propOr(EMPTY_OBJ, 'country'));
exports.getSearchCountry = getSearchCountry;
var getTotal = (0, _reselect.createSelector)(searchByKey, R.propOr(0, 'total'));
exports.getTotal = getTotal;
var isSetSearch = (0, _reselect.createSelector)(searchByKey, function (search) {
fork icon0
star icon3
watch icon4

+ 167 other calls in file

37
38
39
40
41
42
43
44
45
46
exports.getAllServices = getAllServices;
var getServicesByCountryID = (0, _reselect.createSelector)(getServicesStore, function (_, _ref) {
  var countryID = _ref.countryID;
  return countryID;
}, function (servicesStore, countryID) {
  return R.propOr(EMPTY_OBJ, countryID, servicesStore);
});
exports.getServicesByCountryID = getServicesByCountryID;
var getCommonServicesByCountry = (0, _reselect.createSelector)(getServicesByCountryID, function (servicesMap) {
  return R.isEmpty(servicesMap) ? servicesMap : {
fork icon0
star icon3
watch icon0

+ 2 other calls in file

55
56
57
58
59
60
61
62
63
64
65
66
  return geo.get('departures');
});


var getDepartures = function getDepartures() {
  return (0, _reselect.createSelector)(getDeparturesByImmutableStructure, departureGeoID, function (map, geoID) {
    return R.propOr(EMPTY_ARRAY, geoID, map.toJS());
  });
};


exports.getDepartures = getDepartures;
fork icon0
star icon3
watch icon0

+ 3 other calls in file

8
9
10
11
12
13
14
15
16
17
18
	R.isNil,
	R.prop(name),
)


const makeProcessContexts = (cur_flow_ctx) => {
	const cur_name = R.propOr('_null', 'name')(cur_flow_ctx)
	const max_retain = R.propOr(DEFAULT_MAX_RETAIN, 'retain')(cur_flow_ctx)
	const eqName = R.eqBy(R.prop('name'))
	const getDiffCtxs = R.symmetricDifferenceWith(eqName)
	const dcr = R.evolve({
fork icon1
star icon0
watch icon0

+ 3 other calls in file

29
30
31
32
33
34
35
36
37
38
39
40


const concatUntilText = R.curry((limitText, index) => concatUntil((item) => R.trim(item.str).startsWith(limitText), index));


const takeSecondPartOfString = (index) => (arr) => R.pipe(
  take(index),
  R.propOr('', 'str'),
  R.split(':'),
  R.nth(1),
  R.defaultTo(''), // in case nothing is found, use a blank string
  R.trim,
fork icon0
star icon1
watch icon0

+ 5 other calls in file

3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
*      var alice = {
*        name: 'ALICE',
*        age: 101
*      };
*      var favorite = R.prop('favoriteLibrary');
*      var favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
*
*      favorite(alice);  //=> undefined
*      favoriteWithDefault(alice);  //=> 'Ramda'
*/
fork icon0
star icon0
watch icon0

+ 17 other calls in file

43
44
45
46
47
48
49
50
51
52
       return this.secret;
   }

   getAddressByIndex(index)
{
       return R.propOr(null, 'publicKey', R.find(R.propEq('index', index), this.keyPairs));
   }

   getAddressByPublicKey(publicKey)
{
fork icon0
star icon0
watch icon0

+ 5 other calls in file

8
9
10
11
12
13
14
15
16
17
18
const descriptionOrMessage = either(
    pick(['message', 'errors', 'data']),
    path(['props', 'description'])
)
const conditionOf = pathOr('', ['props', 'condition'])
const statusOf = propOr(500, 'code')


const releasable = (target, props) =>
    Object.assign(target, { props, conclude: (delivery) => delivery.release(props) })

fork icon0
star icon0
watch icon0

11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
*      const alice = {
*        name: 'ALICE',
*        age: 101
*      };
*      const favorite = R.prop('favoriteLibrary');
*      const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
*
*      favorite(alice);  //=> undefined
*      favoriteWithDefault(alice);  //=> 'Ramda'
*/
fork icon0
star icon0
watch icon2

+ 3 other calls in file

59
60
61
62
63
64
65
66
67
68
},
optionId: root => R.path(['items', 0, 'arrivalTime'], root) || 'default',
optionName: root => R.path(['items', 0, 'arrivalTime'], root)
  || R.path(['items', 0, 'name'], root),
// TODO
// resellerReference: R.propOr('', 'resellerReference'),
// publicUrl: R.prop('confirmation_url'),
// privateUrl: R.prop('dashboard_url'),
// pickupRequested: R.prop('pickupRequested'),
// pickupPointId: R.prop('pickupPointId'),
fork icon0
star icon0
watch icon0

21
22
23
24
25
26
27
28
29
30
  }
  return [{ id: 'default', name: root.name, demographics: root.demographics }];
},
// options: root => {
//   // https://developers.xola.com/docs/price-schemes
//   const priceSchemes = R.propOr([], 'priceSchemes', root);
//   return priceSchemes.map(priceScheme => {
//     let id;
//     const priceTypeObj = priceScheme.constraints.find(c => c.object === 'price_type_constraint');
//     const privacyObj = priceScheme.constraints.find(c => c.object === 'privacy_constraint');
fork icon0
star icon0
watch icon0

+ 2 other calls in file

103
104
105
106
107
108
109
110
111
112
let coveredCount = 0
let coveredMap = {}

for (let x = extent.left; x <= extent.right; x++) {
  const isCovered = isPointCovered(x, row, sensorList)
  const hasBeacon = R.propOr(false, pointToKey({ x, y: row }), beaconMap)
  //`if (hasBeacon) console.log('HAS BEACON')
  //if (isCovered && !hasBeacon) coveredCount++
  coveredMap[pointToKey({ x, y: row })] = isCovered
}
fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)