UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

19 lines (17 loc) 475 B
function max(items) { if (!items || items.length === 0) { return undefined; } let maxResult = undefined; for (let i = 0; i < items.length; i++) { const current = items[i]; if (current == null || Number.isNaN(current) || typeof current === 'symbol') { continue; } if (maxResult === undefined || current > maxResult) { maxResult = current; } } return maxResult; } export { max };