How to use the both function from ramda

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

364
365
366
367
368
369
370
371
372

<blockquote><pre><code class="language-javascript">
var gt10 = x => x > 10;
var even = x => x % 2 === 0;

var f = R.both(gt10, even);
f(15) // false
f(30) // true
</code></pre></blockquote>
fork icon5
star icon19
watch icon12

20
21
22
23
24
25
26
27
28
29
30
31
const stringIsOneOf = R.curry((selectionArr, str) => {
  return R.allPass([R.is(String), R.contains(R.__, selectionArr)])(str);
});


const isStringOfLengthBetween = R.curry((min, max, str) => {
  return R.both(isStringLongerThan(min), isStringShorterThan(max))(str);
});


const isStringOfLengthBetweenInclusive = R.curry((min, max, str) => {
  return R.both(isStringOfLengthAtLeast(min), isStringOfLengthAtMost(max))(str);
fork icon2
star icon11
watch icon0

1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
* @category Logic
* @sig * -> * -> *
* @param {Boolean} a A boolean value
* @param {Boolean} b A boolean value
* @return {Boolean} `true` if both arguments are `true`, `false` otherwise
* @see R.both
* @example
*
*      R.and(true, true); //=> true
*      R.and(true, false); //=> false
fork icon0
star icon0
watch icon0

+ 35 other calls in file

62
63
64
65
66
67
68
69
70
71
72
var even = x => x % 2 === 0;
var f = R.either(gt10, even);
log(f(101));
log(f(8));


var b = R.both(gt10, even);
log(b(101));
log(b(102));
log(b(8));

fork icon0
star icon0
watch icon0

+ 9 other calls in file

1274
1275
1276
1277
1278
1279
1280
1281
1282
*      const lt20 = R.lt(R.__, 20)
*      const f = R.both(gt10, lt20);
*      f(15); //=> true
*      f(30); //=> false
*
*      R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false)
*      R.both([false, false, 'a'], [11]); //=> [false, false, 11]
*/

fork icon0
star icon0
watch icon2

+ 11 other calls in file

Other functions in ramda

Sorted by popularity

function icon

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