How to use the takeLast function from ramda

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

1047
1048
1049
1050
1051
1052
1053
1054
1055
1056

// we received less than 2000 headers during initial sync - now it's time to request BTC_MAX_FETCH_BLOCKS <- wrong
//
if (this._initialSyncHeaderHashes.length > BTC_MAX_FETCH_BLOCKS) {
  debug(`Limiting number of blocks fetch to ${BTC_MAX_FETCH_BLOCKS} even though ${this._initialSyncHeaderHashes.length} stored`);
  requestHeaders = takeLast(BTC_MAX_FETCH_BLOCKS, this._initialSyncHeaderHashes);
}

// Store hashes to requested hashes to be able to track and save arriving blocks with height < bestHeight
for (const h of requestHeaders) {
fork icon12
star icon5
watch icon7

83
84
85
86
87
88
89
90
91
92
// Verify if the new blockchain is correct
this.checkChain(newBlockchain);

// Get the blocks that diverges from our blockchain
console.info('Received blockchain is valid. Replacing current blockchain with received blockchain');
let newBlocks = R.takeLast(newBlockchain.length - this.blocks.length, newBlockchain);

// Add each new block to the blockchain
R.forEach((block) => {
    this.addBlock(block, false);
fork icon0
star icon1
watch icon0

95
96
97
98
99
100
101
102
103
104
105
  R.map(R.trim)) 
(content)


const part1 = R.compose(
  R.apply(R.multiply),
  R.takeLast(2),
  R.sort(R.subtract),
  R.pluck('inspects'),
  R.reduce(runRound(Infinity), R.__, Array(20))
)(monkeys1)
fork icon0
star icon0
watch icon0

+ 7 other calls in file

37
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

5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
* @sig Number -> [a] -> [a]
* @sig Number -> String -> String
* @param {Number} n The number of elements of `xs` to skip.
* @param {Array} xs The collection to consider.
* @return {Array}
* @see R.takeLast
* @example
*
*      R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
*      R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
fork icon0
star icon0
watch icon0

+ 107 other calls in file

9
10
11
12
13
14
15
16
17
18
19


function parse(lines) {
    const s1 =  R.splitWhenever(R.isEmpty, lines);
    const s2 = s1.map(x => ({
        items: x[1].split(': ')[1].split(', ').map(Number),
        op: R.takeLast(2, x[2].split(' ')),
        test: Number(R.last(x[3].split(' '))),
        branch1: Number(R.last(x[4].split(' '))),
        branch2: Number(R.last(x[5].split(' '))),
        counter: 0
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)