|
Last change
on this file was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
502 bytes
|
| Line | |
|---|
| 1 | export default function max(values, valueof) {
|
|---|
| 2 | let max;
|
|---|
| 3 | if (valueof === undefined) {
|
|---|
| 4 | for (const value of values) {
|
|---|
| 5 | if (value != null
|
|---|
| 6 | && (max < value || (max === undefined && value >= value))) {
|
|---|
| 7 | max = value;
|
|---|
| 8 | }
|
|---|
| 9 | }
|
|---|
| 10 | } else {
|
|---|
| 11 | let index = -1;
|
|---|
| 12 | for (let value of values) {
|
|---|
| 13 | if ((value = valueof(value, ++index, values)) != null
|
|---|
| 14 | && (max < value || (max === undefined && value >= value))) {
|
|---|
| 15 | max = value;
|
|---|
| 16 | }
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 | return max;
|
|---|
| 20 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.