mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
547 B
22 lines
547 B
/**
|
|
* @fileoverview Common utilities.
|
|
*/
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Gets the last element of a given array.
|
|
* @param {any[]} xs - An array to get.
|
|
* @returns {any|null} The last element, or `null` if the array is empty.
|
|
*/
|
|
function getLast(xs) {
|
|
var length = xs.length;
|
|
return (length === 0 ? null : xs[length - 1]);
|
|
}
|
|
|
|
module.exports = {
|
|
getLast: getLast
|
|
};
|
|
|