mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: contest.getRawStatus API
This commit is contained in:
1 parent
2cc9c6a06a
commit
68286607e9
5 files changed
+46
-27
No files matched your search
@@ -1,13 +1,15 @@
|
||||
function* ranked<T>(diter: T[], equ = (a: T, b: T) => a === b): Generator<[number, T], void> {
|
||||
function ranked<T>(diter: T[], equ = (a: T, b: T) => a === b): [number, T][] {
|
||||
let last = null;
|
||||
let r = 0;
|
||||
let count = 0;
|
||||
const results: [number, T][] = [];
|
||||
for (const doc of diter) {
|
||||
count++;
|
||||
if (count === 1 || !equ(last, doc)) r = count;
|
||||
last = doc;
|
||||
yield [r, doc];
|
||||
results.push([r, doc]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
global.Hydro.lib.rank = ranked;
|
||||
|
||||
Reference in new issue
Block a user