Avatar

@u

19 public vals
Joined April 10, 2023
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const regex = {
"'": /\\'/g,
"\"": /\\"/g,
};
function parse(str: string) {
var i = 0;
var parts = [];
var dot, bracket, quote, closing;
while (i < str.length) {
dot = str.indexOf(".", i);
bracket = str.indexOf("[", i);
// we've reached the end
if (dot === -1 && bracket === -1) {
parts.push(str.slice(i, str.length));
i = str.length;
}
// dots
else if (bracket === -1 || (dot !== -1 && dot < bracket)) {
parts.push(str.slice(i, dot));
i = dot + 1;
}
// brackets
else {
if (bracket > i) {
parts.push(str.slice(i, bracket));
i = bracket;
}
quote = str.slice(bracket + 1, bracket + 2);
if (quote !== "\"" && quote !== "'") {
closing = str.indexOf("]", bracket);
if (closing === -1) {
closing = str.length;
}
parts.push(str.slice(i + 1, closing));
i = str.slice(closing + 1, closing + 2) === "."
? closing + 2
: closing + 1;
} else {
closing = str.indexOf(quote + "]", bracket);
if (closing === -1) {
closing = str.length;
}
while (
str.slice(closing - 1, closing) === "\\"
&& bracket < str.length
) {
bracket++;
Fork
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { gron } from "https://esm.town/v/u/gron";
export default async function untitled_roseClownfish(req: Request): Promise<Response> {
let url: URL;
try {
url = new URL(new URL(req.url).searchParams.get("url"));
}
catch {
return new Response(
"<html><body>Not a valid URL - " + new URL(req.url).search
+ "</body></html>",
{
headers: {
"Content-Type": "text/html",
},
},
);
}
return new Response(gron(await (await fetch(url)).json()));
}
1
2
export function schema(req, res) {
}
1
2
3
4
5
import { fetch } from "https://esm.town/v/std/fetch";
export async function json(url: string): Promise<any> {
return await (await fetch(url)).json();
}
1
2
3
4
import { msPerHour } from "https://esm.town/v/u/msPerHour";
import { hourPerDay } from "https://esm.town/v/u/hourPerDay";
export let msPerDay = hourPerDay * msPerHour;
1
2
3
4
import { secPerHour } from "https://esm.town/v/u/secPerHour";
import { hourPerDay } from "https://esm.town/v/u/hourPerDay";
export let secPerDay = hourPerDay * secPerHour;
1
2
3
4
import { minPerHour } from "https://esm.town/v/u/minPerHour";
import { hourPerDay } from "https://esm.town/v/u/hourPerDay";
export let minPerDay = hourPerDay * minPerHour;
1
export let hourPerDay = 24;
1
2
3
4
import { minPerHour } from "https://esm.town/v/u/minPerHour";
import { msPerMin } from "https://esm.town/v/u/msPerMin";
export let msPerHour = msPerMin * minPerHour;
1
2
3
4
import { secPerMin } from "https://esm.town/v/u/secPerMin";
import { minPerHour } from "https://esm.town/v/u/minPerHour";
export let secPerHour = minPerHour * secPerMin;