UNPKG

jsmodern

Version:

An extension to existing JavaScript, influenced by other great languages such as Rust, Dart, Java, Golang, etc.

29 lines 816 B
export const max = { label: 'max', fn: function arrayMax() { const ctx = this; const len = ctx.length; if (!len) return void 0; if (1 === len) return ctx[0]; let maxTemp = Number.NEGATIVE_INFINITY; let maxValue; for (const n of ctx) { const nType = typeof (n); if ('string' === nType && 1 === n.length) { const pt = n.codePointAt(0); if (pt > maxTemp) { maxTemp = pt; maxValue = n; continue; } } else if ('number' === nType && n > maxTemp) { maxTemp = maxValue = n; } } return maxValue; }, }; //# sourceMappingURL=max.js.map