How to use the any function from ramda

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

ramda.any is a higher-order function in Ramda that returns a function which determines if any elements in a list satisfy a provided predicate.

189
190
191
192
193
194
195
196
197
198
199
var isSetHotelAtPrices = function isSetHotelAtPrices() {
  return (0, _reselect.createSelector)(getFlattenPrices(), function (_, _ref7) {
    var hotelID = _ref7.hotelID;
    return hotelID;
  }, function (prices, hotelID) {
    return R.any(R.propEq('hotelID', hotelID), prices);
  });
};


exports.isSetHotelAtPrices = isSetHotelAtPrices;
fork icon0
star icon3
watch icon4

+ 41 other calls in file

1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
 * @see R.all, R.none, R.transduce
 * @example
 *
 *      var lessThan0 = R.flip(R.lt)(0);
 *      var lessThan2 = R.flip(R.lt)(2);
 *      R.any(lessThan0)([1, 2]); //=> false
 *      R.any(lessThan2)([1, 2]); //=> true
 */
var any = _curry2(_dispatchable('any', _xany, function any(fn, list) {
    var idx = 0;
fork icon0
star icon0
watch icon0

+ 53 other calls in file

How does ramda.any work?

ramda.any is a function that takes a predicate function and a list of values, and returns true if the predicate function returns true for any of the values in the list, otherwise it returns false.

158
159
160
161
162
163
164
165
166
167
168


  // Number -> String -> Context -> Boolean
  playerHasRole: R.uncurryN(3, (idx, role) => R.pipe(
    R.view(Player.lens(idx)),
    R.prop('influence'),
    R.any(R.both(
      R.propEq('revealed', false),
      R.propEq('role', role)))
  ))
};
fork icon0
star icon0
watch icon0

+ 6 other calls in file

907
908
909
910
911
912
913
914
915
916
    { ungrouped: true }
  );
}

filterMeasureFilters(measures) {
  return this.measureFilters.filter(f => R.any(m => m.measure === f.measure, measures));
}

keysQuery(primaryKeyDimension, filters) {
  const inlineWhereConditions = [];
fork icon0
star icon0
watch icon0

Ai Example

1
2
3
4
5
6
const R = require("ramda");

const greaterThanTen = R.any((x) => x > 10);

console.log(greaterThanTen([5, 10, 15])); // true
console.log(greaterThanTen([1, 2, 3])); // false

In this example, ramda.any is used to check if any element in an array is greater than 10. The function greaterThanTen returns a new function that takes an array as input and returns true if any element in the array is greater than 10, and false otherwise. When the function is called with the arrays [5, 10, 15] and [1, 2, 3], it returns true and false, respectively.

14
15
16
17
18
19
20
21
22
23
24
25
const distStep = (banks, index, remaining) => (remaining <= 0 ? banks : distStep(incrIndex(index)(banks), nextStep(banks, index), remaining - 1));
const dist = (banks, index) => distStep(setIndex(index, 0)(banks), nextStep(banks, index), banks[index]);
const distMax = (banks) => dist(banks, findMaxIndex(banks));
const dup = (n => [n, n]);
const log = R.tap((obj) => console.log(obj));
const reallocate = unfold2((banks, seq) => R.any(R.equals(banks))(R.init(seq)) ? false : dup(distMax(banks)));


// --- //


const input = [5, 1, 10, 0, 1, 7, 13, 14, 3, 12, 8, 10, 7, 12, 0, 6];
fork icon0
star icon0
watch icon0

18
19
20
21
22
23
24
25
26
27
28
29
30
    R.drop(2))(input);


const markNumber = (n) => R.map(
    R.map(R.ifElse(R.equals(n), R.always(-1), R.identity)));


const isWinner = (b) => R.any(
    R.any(R.all(R.gt(0))),
    [b, R.transpose(b)]);


const score = R.compose(
fork icon0
star icon0
watch icon0

64
65
66
67
68
69
70
71
72
73
    maskCheckPositiveFunc
)(mandatoryMasks);

const additionalMasksResult = ifElse(
    is(Object),
    userMasks => any(maskCheckPositiveFunc, userMasks),
    maskCheckPositiveFunc
)(additionalMasks);

const negativeMasksResult = ifElse(
fork icon0
star icon0
watch icon3

+ 3 other calls in file

Other functions in ramda

Sorted by popularity

function icon

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