swc/crates/swc_bundler/tests/.cache/deno/1e70110a27b77ce4047986f5401326ad4ef7b5c8.ts

34 lines
1.0 KiB
TypeScript
Raw Normal View History

// Loaded from https://deno.land/x/ramda@v0.27.2/source/takeLast.js
import _curry2 from './internal/_curry2.js';
import drop from './drop.js';
/**
* Returns a new list containing the last `n` elements of the given list.
* If `n > list.length`, returns a list of `list.length` elements.
*
* @func
* @memberOf R
* @since v0.16.0
* @category List
* @sig Number -> [a] -> [a]
* @sig Number -> String -> String
* @param {Number} n The number of elements to return.
* @param {Array} xs The collection to consider.
* @return {Array}
* @see R.dropLast
* @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'
*/
var takeLast = _curry2(function takeLast(n, xs) {
return drop(n >= 0 ? xs.length - n : 0, xs);
});
export default takeLast;