Repository URL to install this package:
|
Version:
6.0.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var is_1 = require("../is");
var lastIndex_1 = require("./lastIndex");
/**
* Returns the last element of the given list or string.
*
* @func
* @memberOf fp
* @since 5.0.0-beta.2
*
* @param {*} x list to get last index of
* @return {*}
*
* @tests fp/last
*
* @ramda v0.1.4
* @category List
* @sig [a] -> a | Undefined
* @sig String -> String
*
* @see R.init, R.head, R.tail
* @extends deps/fp/lastIndex
*
* {@link https://github.com/jashkenas/underscore/blob/master/underscore.js#L507 underscore-last}
* @see {@link underscore-last}
*
* @types fp
* @tests fp/*
*
* @example
*
* last(['fi', 'fo', 'fum']); //=> 'fum'
* last([]); //=> undefined
*
* last('abc'); //=> 'c'
* last(''); //=> ''
*
*/
function last(x) {
return is_1.isIndexable(x) ? x[lastIndex_1.default(x)] : undefined;
}
exports.default = last;
//# sourceMappingURL=last.js.map