mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* WIP * WIP * WIP * WIP * Improve typechecking in type files * Fix typechecking * Update * Update submodule * CI for typechecking * Add ci * Update commands * Format after build * Dont use bunx * Rename job * Use nodemodules prettier * Update workflow * Use symlink * Debug * Debug * Clean up and rename jobs
31 lines
749 B
TypeScript
31 lines
749 B
TypeScript
import type { Serve } from "bun";
|
|
import { heapStats } from "bun:jsc";
|
|
var prevCounts: Record<string, number>;
|
|
export default {
|
|
fetch(req: Request) {
|
|
const out: Record<string, number> = {};
|
|
const counts = heapStats().objectTypeCounts;
|
|
for (const key in counts) {
|
|
if (prevCounts) {
|
|
if (prevCounts[key] && counts[key] > prevCounts[key]) {
|
|
out[key] = counts[key];
|
|
}
|
|
} else {
|
|
if (counts[key] > 1) {
|
|
out[key] = counts[key];
|
|
}
|
|
}
|
|
}
|
|
prevCounts = counts;
|
|
if (req.url.includes("gc")) {
|
|
Bun.gc(false);
|
|
}
|
|
|
|
return new Response(JSON.stringify(out), {
|
|
headers: {
|
|
"content-type": "application/json",
|
|
},
|
|
});
|
|
},
|
|
} satisfies Serve;
|