How to use the take function from ramda

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

120
121
122
123
124
125
126
127
128
129
// uncomment to export expectations:
// fs.writeFileSync('/tmp/failing-test-expected-ads.json', JSON.stringify(foundAds));

let errorMsg = "Failed to correctly detect the ads:";
if (unexpectedAds.length > 0) {
  const examples = R.take(
    numExamples,
    R.sortWith([R.prop("key"), R.prop("url")], unexpectedAds)
  );
  examples.forEach((example) => {
fork icon14
star icon29
watch icon0

87
88
89
90
91
92
93
94
95
96
97
98
  return R.call(R.pipe(convertPricesListToMap, R.toPairs, R.map(function (_ref3) {
    var _ref4 = _slicedToArray(_ref3, 2),
        price = _ref4[1];


    return R.over(R.lensProp('offers'), sortOffers(offersHub, currency), price);
  }), sortPrices(currency), simplifyPrices, R.take(_constants.COUNT_AT_PAGE)), prices);
};


exports.generateNextPrices = generateNextPrices;

fork icon0
star icon3
watch icon0

5
6
7
8
9
10
11
12
13
14
const result = R.pipe(
    // countBy is used to count the frequency by it's identity and returns as object
    R.countBy(R.identity),  // count using its identity[x => x] => {1:3, 2:2, 3:1} 
    R.toPairs,  // =>[[1,3], [2,2], [3,1]]
    R.sort((a, b) => b[1] - a[1]),  // sort using value =>[[1,3], [2,2], [3,1]]
    R.take(k),  // slice array => [[1,3], [2,2]]
    R.map(ele => ele[0]), // return all first elements as array => [1,2]
    R.map(R.unary(parseInt))
);
console.log(result(nums));
fork icon0
star icon1
watch icon0

+ 2 other calls in file

70
71
72
73
74
75
76
77
78
79
80
81


const getMonkeyBusiness = R.pipe(
  R.pluck('inspected'),
  R.values,
  R.sort(R.descend(R.identity)),
  R.take(2),
  R.apply(R.multiply),
)


const getCommonMultiple = R.pipe(
fork icon0
star icon1
watch icon0

70
71
72
73
74
75
76
77
78
79
80
81
82
//   filteredCities,
// );


// console.log(sortedCities);


// const top10 = R.take(10, sortedCities);


// console.log(top10);
// console.log(R.length(top10));

fork icon0
star icon1
watch icon0

38
39
40
41
42
43
44
45
46
let {stacks, moves} = data;

moves.forEach(m => {
    const {num, from, to} = m;
    const a = R.takeLast(num, stacks[from - 1]);
    stacks[from - 1]= R.take(stacks[from - 1].length - num, stacks[from - 1]);
    stacks[to - 1] = R.concat(stacks[to - 1], a);
    
});
fork icon0
star icon0
watch icon0

+ 3 other calls in file

4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
* @param {*} list
* @return {*}
* @see R.drop
* @example
*
*      R.take(1, ['foo', 'bar', 'baz']); //=> ['foo']
*      R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
*      R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
*      R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
*      R.take(3, 'ramda');               //=> 'ram'
fork icon0
star icon0
watch icon0

+ 107 other calls in file

19
20
21
22
23
24
25
26
27
28


// part 2
R.pipe(
  R.map(R.sum),
  R.sort((a, b) => (b - a)),
  R.take(3),
  R.sum,
  console.log,
)(elves);
fork icon0
star icon0
watch icon0

93
94
95
96
97
98
99
100
101
102
const topCities = R.pipe(
  R.map(updateTemperature(KtoF)),
  R.filter(filterByWeather),
  R.map(calcScore),
  R.sortWith([R.descend(city => city.score)]),
  R.take(10),
  R.map(cityToArray),
  R.prepend(interestingProps),
  table,
)(cities);
fork icon0
star icon0
watch icon0

+ 5 other calls in file

13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
*      ];
*
*      const takeFive = R.take(5);
*      takeFive(personnel);
*      //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan']
* @symb R.take(-1, [a, b]) = [a, b]
* @symb R.take(0, [a, b]) = []
* @symb R.take(1, [a, b]) = [a]
* @symb R.take(2, [a, b]) = [a, b]
*/
fork icon0
star icon0
watch icon2

+ 39 other calls in file

54
55
56
57
58
59
60
61
62
63
            stack.push(cmd.arg);
        }
    } else if (cmd.cmd === 'ls') {
        const size = R.reduce(R.add, 0, cmd.output.filter(x => x.type === 'file').map(x => x.size));
        stack.forEach((p, i) => {
            const key = R.take(i + 1, stack).join('/');
            sizes[key] = (sizes[key] || 0) + size;
        })
    }
});
fork icon0
star icon0
watch icon0

55
56
57
58
59
60
61
62
63
64
    R.pluck(0)
  )(series[0])
),
series => R.append(
  others(limit)(otherLabel)(series),
  R.take(limit, series)
),
R.sort((a, b) => R.sum(R.tail(b)) - R.sum(R.tail(a))),
mapIndexed(
  (s, idx) => R.compose(
fork icon0
star icon0
watch icon1

Other functions in ramda

Sorted by popularity

function icon

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