/
dropLast.js
31 lines (29 loc) · 1.11 KB
/
dropLast.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import _curry2 from './internal/_curry2';
import _dispatchable from './internal/_dispatchable';
import _dropLast from './internal/_dropLast';
import _xdropLast from './internal/_xdropLast';
/**
* 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.
*
* @func
* @memberOf R
* @since v0.16.0
* @category List
* @sig Number -> [a] -> [a]
* @sig Number -> String -> String
* @param {Number} n The number of elements of `list` to skip.
* @param {Array} list The list of elements to consider.
* @return {Array} A copy of the list with only the first `list.length - n` elements
* @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile
* @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'
*/
var dropLast = _curry2(_dispatchable([], _xdropLast, _dropLast));
export default dropLast;