How to use the flip function from ramda

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

12
13
14
15
16
17
18
19
20
21
22
23
  if (R.is(String, log)) return log
  if (R.is(Error, log.message)) log.message = serializeError(log.message, { maxDepth: 10 })
  return stringifySafe(log, null, 0, () => '~')
}


const pickProperties = R.flip(pokeprop)


const generateLogLevel = statusCode => {
  if (statusCode < 400 || R.isNil(statusCode)) return 'info'
  if (statusCode < 500) return 'warn'
fork icon4
star icon39
watch icon96

+ 283 other calls in file

49
50
51
52
53
54
55
56
57
58
59
 * @function
 * @param {locale[]} locales
 * @param {string} day
 * @return {string}
 */
const formatDay = flip(formatOrdinal)('neuter');


/**
 * Ordinalise given day if it is the first day of the month,
 * Leave any other days as is.
fork icon0
star icon0
watch icon0

1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
 *         otherwise.
 * @see R.any, R.none, R.transduce
 * @example
 *
 *      var lessThan2 = R.flip(R.lt)(2);
 *      var lessThan3 = R.flip(R.lt)(3);
 *      R.all(lessThan2)([1, 2]); //=> false
 *      R.all(lessThan3)([1, 2]); //=> true
 */
var all = _curry2(_dispatchable('all', _xall, function all(fn, list) {
fork icon0
star icon0
watch icon0

+ 89 other calls in file

206
207
208
209
210
211
212
213
214
215
216
217
var equals3 = R.equals(3);
log(R.all(equals3)([3, 3, 3, 3]));
log(R.all(equals3)([3, 3, 1, 3]));


var lessThan0 = R.flip(R.lt)(0);
var lessThan2 = R.flip(R.lt)(2);
log(R.any(lessThan0)([1, 2]));
log(R.any(lessThan2)([1, 2]));



fork icon0
star icon0
watch icon0

+ 19 other calls in file

25
26
27
28
29
30
31
32
33
34
const consolePrettyList = R.tap(
    R.pipe(R.pluck('id'), R.join(', '),console.log)
);
const initGen = (list) => {
    R.pipe(
        R.flip(R.repeat)(5),
        R.map(R.sort(() => Math.random() - 0.5)),
        R.map(consolePrettyList)
    )(list);
};
fork icon0
star icon0
watch icon0

35
36
37
38
39
40
41
42
43
44
45


module.exports = (runDate) => {
  const bands = bandsOnDate(runDate || moment.utc());
  return R.compose(
    RD.sum,
    R.flip(R.map)(bands),
    calcForBand,
  );
};

fork icon0
star icon0
watch icon0

610
611
612
613
614
615
616
617
618
619
* @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
*         otherwise.
* @see R.all, R.none, R.transduce
* @example
*
*      const lessThan0 = R.flip(R.lt)(0);
*      const lessThan2 = R.flip(R.lt)(2);
*      R.any(lessThan0)([1, 2]); //=> false
*      R.any(lessThan2)([1, 2]); //=> true
*/
fork icon0
star icon0
watch icon2

+ 15 other calls in file

74
75
76
77
78
79
80
81
82
83

  return opFn(left, right)
}

const divideBy = R.flip(R.divide)
const moduloBy = R.flip(R.modulo)

const monkeyTurn = monkey => {
  const nextItems = monkey.items
    .map(worry => applyOperation(worry, monkey.operation))
fork icon0
star icon0
watch icon0

+ 3 other calls in file

4
5
6
7
8
9
10
11
12
13
14
15


const lines = R.split('\n', input);
const mismatchScores = {')': 3, ']': 57, '}': 1197, '>': 25137};
const completionScores = {')': 1, ']': 2, '}': 3, '>': 4};
const matchingParens = {'(': ')', '[': ']', '{': '}', '<': '>'};
const isOpen = R.flip(R.includes)(R.keys(matchingParens));
const isMatchingClose = (l, r) => (matchingParens[l] === r);


const findLineMismatch = R.reduce((stack, p) => {
  if (isOpen(p)) return R.prepend(p, stack);
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)