main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1015 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | var _curry2 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry2.js");
|
---|
| 4 |
|
---|
| 5 | var drop =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./drop.js");
|
---|
| 8 | /**
|
---|
| 9 | * Returns a new list containing the last `n` elements of the given list.
|
---|
| 10 | * If `n > list.length`, returns a list of `list.length` elements.
|
---|
| 11 | *
|
---|
| 12 | * @func
|
---|
| 13 | * @memberOf R
|
---|
| 14 | * @since v0.16.0
|
---|
| 15 | * @category List
|
---|
| 16 | * @sig Number -> [a] -> [a]
|
---|
| 17 | * @sig Number -> String -> String
|
---|
| 18 | * @param {Number} n The number of elements to return.
|
---|
| 19 | * @param {Array} xs The collection to consider.
|
---|
| 20 | * @return {Array}
|
---|
| 21 | * @see R.dropLast
|
---|
| 22 | * @example
|
---|
| 23 | *
|
---|
| 24 | * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
|
---|
| 25 | * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
|
---|
| 26 | * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
|
---|
| 27 | * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
|
---|
| 28 | * R.takeLast(3, 'ramda'); //=> 'mda'
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | var takeLast =
|
---|
| 33 | /*#__PURE__*/
|
---|
| 34 | _curry2(function takeLast(n, xs) {
|
---|
| 35 | return drop(n >= 0 ? xs.length - n : 0, xs);
|
---|
| 36 | });
|
---|
| 37 |
|
---|
| 38 | module.exports = takeLast; |
---|
Note:
See
TracBrowser
for help on using the repository browser.