How to use the length function from ramda

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

352
353
354
355
356
357
358
359
360
361
    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

51
52
53
54
55
56
57
58
59
60
Modify: (todo, action, model) => {
  const idx = R.indexOf(todo, model.todos)
  return R.evolve({todos: R.adjust(Todo.update(action), idx)}, model)
},
ToggleAll: (model) => {
  const left = R.length(R.reject(R.prop('done'), model.todos)),
        todoAction = left === 0 ? Todo.Action.UnsetDone() : Todo.Action.SetDone();
  return R.evolve({todos: R.map(Todo.update(todoAction))}, model);
},
ClearDone: R.evolve({todos: R.reject(R.prop('done'))}),
fork icon92
star icon0
watch icon2

+ 3 other calls in file

250
251
252
253
254
255
256
257
258
259
  activeFans,
  hlsUrl,
  hlsEnabled,
  status
} = activeBroadcast; // eslint-disable-line  no-unused-vars
const viewers = R.length(R.keys(activeFans)); // eslint-disable-line  no-unused-vars
/* Uncomment the next line if you need to consider the limit */
// const shouldStartBroadcast = hlsEnabled && !hlsUrl && status === 'live' && viewers >= interactiveLimit;
const shouldStartBroadcast = (hlsEnabled || event.rtmpUrl) && !hlsUrl && status === 'live';
if (shouldStartBroadcast) {
fork icon12
star icon5
watch icon0

12
13
14
15
16
17
18
19
20
21
22
23
24
if (res.status != 0)
    throw new Error("Couldn't get search.json")


const newPackages = JSON.parse(res.stdout.toString())


console.log("New packages: " + R.length(newPackages))


const taggedPackagesStr = Fs.readFileSync("public/tagged-packages.js").toString()
const taggedPackages = JSON.parse(taggedPackagesStr.slice(taggedPackagesStr.indexOf("[")))

fork icon1
star icon0
watch icon0

+ 7 other calls in file

17
18
19
20
21
22
23
24
25
26
27
28
	R.filter(R.prop('nom_carto'))
);


//get a random monument object from the list with ramda
const pickRandomFromList = (list) => {
	const index = Math.floor(Math.random() * R.length(list));
	return R.nth(index, list);
}


const randomMonument = (monumentNElement) => {
fork icon0
star icon1
watch icon0

24
25
26
27
28
29
30
31
32
33
34
35
	const { cost = 0 } = city;
	return acc + cost;
};


const totalCost = R.reduce(totalCostReducer, 0, cities);
const cityCount = R.length(cities);
// console.log(totalCost / cityCount);


const groupByPropReducer = (acc, city) => {
	const { cost = [], internetSpeed = [] } = acc;
fork icon0
star icon1
watch icon0

2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
 * @param {Array} list The array to inspect.
 * @return {Number} The length of the array.
 * @example
 *
 *      R.length([]); //=> 0
 *      R.length([1, 2, 3]); //=> 3
 */
var length = _curry1(function length(list) {
    return list != null && _isNumber(list.length) ? list.length : NaN;
});
fork icon0
star icon0
watch icon0

+ 35 other calls in file

107
108
109
110
111
112
113
114
115
116
117
118


const Game = {
  isOver: R.pipe(
    R.prop('players'),
    R.reject(Player.isDead),
    R.length(),
    R.equals(1)),


  opponents: game => R.pipe(
    R.prop('players'),
fork icon0
star icon0
watch icon0

+ 6 other calls in file

6
7
8
9
10
11
12
13
14
15
16
17
const row = R.curry((matrix, index) => R.nth(index, matrix))
const column = R.curry((matrix, index) => R.map(R.nth(index), matrix))


const forest = R.map(R.map(Number), content)
const width = R.compose(R.length, R.head)(forest)
const height = R.length(forest)


const flatForest = R.converge(R.reduce(R.concat), [R.head, R.tail])(forest)
const indexToCoordinates = R.converge(Array.of, [R.modulo(R.__, width), R.compose(Math.floor, R.divide(R.__, height))])

fork icon0
star icon0
watch icon0

+ 2 other calls in file

13
14
15
16
17
18
19
20
21
22
23
    map(split(')')),
)(input);


a = sum(map(countOrbits(orbitMap), keys(orbitMap)));
b = compose(
    ([xs, ys]) => length(xs) + length(ys) - 2 - 2*length(longestCommonPrefix(xs, ys)),
    map(reverse),
    map(orbitPath(orbitMap)),
)(['SAN', 'YOU']);

fork icon0
star icon0
watch icon0

20
21
22
23
24
25
26
27
28
29
30


const isBinaryOperator = (selector, argumentNodes) =>
  R.and(
    isSelectorBinaryOperator(selector),
    R.equals(
      R.length(argumentNodes),
      1
    ),
    R.complement(
      R.equals(
fork icon0
star icon0
watch icon0

10
11
12
13
14
15
16
17
18
19
20
21
const toIntArr = R.map((n) => parseInt(n));
const multiIntersection = (s) => R.reduce(R.intersection, R.head(s), R.tail(s));


// zerosLike :: Num a => [[b]] -> [[a]]
const zerosLike = (board) => {
  const height = R.length(board);
  if (height === 0) return [];
  const width = R.length(board[0]);


  return R.map((_) => R.repeat(0, width), R.range(0, height));
fork icon0
star icon0
watch icon0

+ 5 other calls in file

169
170
171
172
173
174
175
176
177
178
        update.author_id || articles[indexArticles].author_id;
    }
  })(updateArticles);
}

if (!R.isEmpty(updateAuthors) && R.length(updateAuthors) > 0) {
  R.map((update) => {
    const indexAuthor = R.findIndex(R.propEq("id", update.id))(authors);

    if (indexAuthor >= 0) {
fork icon0
star icon0
watch icon0

+ 4 other calls in file

79
80
81
82
83
84
85
86
87
88
    return mandatoryMasksResult && additionalMasksResult && negativeMasksResult;
}

function isUserMaskChainMatch(inotifyMaskChains, userMaskChain) {
    return any((inotifyMaskChain) => {
        const inotifyMaskChainLength = length(inotifyMaskChain);
        const userMaskChainLength = length(userMaskChain);

        const truncatedUserMaskChain = slice(userMaskChainLength - inotifyMaskChainLength, Infinity, userMaskChain);
        return equals(truncatedUserMaskChain, inotifyMaskChain)
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)