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

utils/drop-last
v1.1.0
1.1.0
Returns a list containing all but 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/drop-last in your project
npm i @bit/bit.ramda.utils.drop-last
Copied

dropLast (n:Number, list:Array) : Array

Returns a list containing all but the last n elements of the given list.

Acts as a transducer if a transformer is given in list position.

Example

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

Arguments

n: Number

The number of elements of `list` to skip.

list: Array

The list of elements to consider.

Returns

Array

A copy of the list with only the first `list.length - n` elements