server-json/node_modules/ramda/es/last.js
2024-11-01 08:00:42 +00:00

27 lines
No EOL
610 B
JavaScript

import _curry1 from "./internal/_curry1.js";
import _nth from "./internal/_nth.js";
/**
* Returns the last element of the given list or string.
*
* @func
* @memberOf R
* @since v0.1.4
* @category List
* @sig [a] -> a | Undefined
* @sig String -> String | Undefined
* @param {*} list
* @return {*}
* @see R.init, R.head, R.tail
* @example
*
* R.last(['fi', 'fo', 'fum']); //=> 'fum'
* R.last([]); //=> undefined
*
* R.last('abc'); //=> 'c'
* R.last(''); //=> undefined
*/
var last = /*#__PURE__*/_curry1(function (list) {
return _nth(-1, list);
});
export default last;