/**
 * Returns the last value, or `undefined` if the iterable is empty.
 *
 * Performance-related note: if the iterable is an array, retrieves the last
 * value by index, otherwise iterates to the end.
 */ export const lastInIterable = < T > ( iterable ) : T | undefined => { if ( Array . isArray ( iterable ) ) { return iterable [ iterable . length - 1 ] ; } let result = undefined ; for ( result of iterable ) { } return result ; } ;