First commit.

Signed-off-by: Chen Xiao <abigwc@gmail.com>
This commit is contained in:
Chen Xiao
2026-05-08 14:43:16 +08:00
commit 0b64e2de94
10989 changed files with 2253791 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import none from "./none.js";
export default function(series) {
var peaks = series.map(peak);
return none(series).sort(function(a, b) { return peaks[a] - peaks[b]; });
}
function peak(series) {
var i = -1, j = 0, n = series.length, vi, vj = -Infinity;
while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i;
return j;
}
+12
View File
@@ -0,0 +1,12 @@
import none from "./none.js";
export default function(series) {
var sums = series.map(sum);
return none(series).sort(function(a, b) { return sums[a] - sums[b]; });
}
export function sum(series) {
var s = 0, i = -1, n = series.length, v;
while (++i < n) if (v = +series[i][1]) s += v;
return s;
}
+5
View File
@@ -0,0 +1,5 @@
import ascending from "./ascending.js";
export default function(series) {
return ascending(series).reverse();
}
+27
View File
@@ -0,0 +1,27 @@
import appearance from "./appearance.js";
import {sum} from "./ascending.js";
export default function(series) {
var n = series.length,
i,
j,
sums = series.map(sum),
order = appearance(series),
top = 0,
bottom = 0,
tops = [],
bottoms = [];
for (i = 0; i < n; ++i) {
j = order[i];
if (top < bottom) {
top += sums[j];
tops.push(j);
} else {
bottom += sums[j];
bottoms.push(j);
}
}
return bottoms.reverse().concat(tops);
}
+5
View File
@@ -0,0 +1,5 @@
export default function(series) {
var n = series.length, o = new Array(n);
while (--n >= 0) o[n] = n;
return o;
}
+5
View File
@@ -0,0 +1,5 @@
import none from "./none.js";
export default function(series) {
return none(series).reverse();
}