Share your code. Components are building blocks, you are the architect.

utils/take-last
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
Build: fail
BuildFail
Build Status: fail
Returns a new list containing the last `n` elements of the given list

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/take-last in your project
npm i @bit/bit.ramda.utils.take-last
Copied

takeLast (n:Number, xs:Array) : Array

Returns a new list containing the last n elements of the given list. If n > list.length, returns a list of list.length elements.

Example

R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
     R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
     R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
     R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
     R.takeLast(3, 'ramda');               //=> 'mda'

Arguments

n: Number

The number of elements to return.

xs: Array

The collection to consider.

Returns

Array