|
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:
339 bytes
|
| Line | |
|---|
| 1 | import none from "./none.js";
|
|---|
| 2 |
|
|---|
| 3 | export default function(series) {
|
|---|
| 4 | var peaks = series.map(peak);
|
|---|
| 5 | return none(series).sort(function(a, b) { return peaks[a] - peaks[b]; });
|
|---|
| 6 | }
|
|---|
| 7 |
|
|---|
| 8 | function peak(series) {
|
|---|
| 9 | var i = -1, j = 0, n = series.length, vi, vj = -Infinity;
|
|---|
| 10 | while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i;
|
|---|
| 11 | return j;
|
|---|
| 12 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.