1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { paginateAPI } from "https://esm.town/v/andreterron/paginateAPI";
import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
let max: { lines: number; name: string } | undefined;
const opts = {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
},
};
const me = await fetchJSON(
`${API_URL}/v1/me`,
opts,
);
// TODO: Paginate
const vals = await paginateAPI(
`${API_URL}/v1/users/${me.id}/vals?limit=100`,
opts,
);
for (let val of vals) {
const lines = ((val.code as (string | null)) ?? "").trim().split("\n").length;
if (max === undefined || lines > max.lines) {
max = { lines, name: val.name };
}
}
console.log("Longest val:", max?.name, `(${max.lines ?? 0} lines)`);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
January 24, 2024