authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-03-28 18:37:43-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-03-28 18:40:16-07:00
loge5053a06d43a46f83b18f1cc2acc436024a8bcb6
treeb59a3b1dea6e7edd662f1afc8dd8db780a6a0678
parent799a06966ea7692c5fe5abb7b121d2bd541cbddf
signature Signed by SSH key SHA256:xbd+BjjhyBfwk7GVoURf9Yx0gzDerHbvYv7SddNWmAs

chore: module-level jsdoc crashout


19 files changed, 73 insertions(+), 23 deletions(-)

lib/Lru.ts+2-2
......@@ -1,6 +1,6 @@
11/**
2 * Least-recently-used cache.
3 * This module is intended to be imported via the main class.
2 * least-recently-used cache.
3 * this module is intended to be imported via the main class.
44 *
55 * ```ts
66 * import { Lru } from '@clo/lib/Lru';
lib/assert.ts+1
......@@ -1,6 +1,7 @@
11/**
22 * assertions and type narrowing helpers. intended to be imported per symbol.
33 * functions are capitalized to make them stand out in a codebase.
4 *
45 * @module
56 */
67/* node:coverage disable */
lib/async.ts+6
......@@ -1,3 +1,9 @@
1/**
2 * helpers to deal with promises and asynchronous execution.
3 *
4 * @module
5 */
6
17/*** @deprecated */
28interface ARCEValue<T> {
39 value: T;
lib/bytes.ts+6
......@@ -1,3 +1,9 @@
1/**
2 * helpers to deal with `Uint8Array` and other `ArrayBufferView`s
3 *
4 * @module
5 */
6
17export function eql<T extends ArrayBufferView & { [n: number]: number }>(
28 a: T,
39 b: T,
lib/error.ts+1-1
......@@ -1,5 +1,5 @@
11/**
2 * Helper functions for dealing with the `unknown` type, mainly in `catch`
2 * helper functions for dealing with the `unknown` type, mainly in `catch`
33 * blocks or promise rejection callbacks.
44 *
55 * @module
lib/http.ts+12-11
......@@ -1,3 +1,10 @@
1/**
2 * helpers for building applications with an HTTP server, with integrations with
3 * `@clo/lib/progress`
4 *
5 * @module
6 */
7
18export interface Server {
29 port: number;
310 url: string;
......@@ -26,15 +33,6 @@ export interface ServeContext {
2633export async function serve(
2734 { respond, port, progress: rootNode = progress.nullNode }: ServeOptions,
2835): Promise<Server> {
29 const nodeHttp = node.builtin(
30 "http",
31 ) as unknown as typeof import("node:http");
32 const stream = node.builtin("stream");
33 ASSERT(
34 nodeHttp && stream,
35 "http.serve must be called in a node.js compatible runtime",
36 );
37
3836 const server = nodeHttp.createServer((req, res) => {
3937 const headers = new Headers();
4038 for (const key in req.headers) {
......@@ -55,7 +53,8 @@ export async function serve(
5553 headers,
5654 body: hasNoBody
5755 ? undefined
58 : stream.Readable.toWeb(req),
56 : stream.Readable.toWeb(req) as ReadableStream,
57 // @ts-expect-error
5958 duplex: hasNoBody ? undefined : "half",
6059 },
6160 );
......@@ -68,7 +67,7 @@ export async function serve(
6867 Array.from(response.headers.entries()),
6968 );
7069 if (response.body) {
71 stream.Readable.fromWeb(response.body).pipe(res);
70 stream.Readable.fromWeb(response.body as import("node:stream/web").ReadableStream).pipe(res);
7271 } else {
7372 res.end();
7473 }
......@@ -166,6 +165,8 @@ export interface Range {
166165 end: number;
167166}
168167
168import * as nodeHttp from "node:http";
169import * as stream from "node:stream";
169170import { ASSERT, UNWRAP } from "./assert.ts";
170171import * as error from "./error.ts";
171172import * as node from "./node.ts";
lib/log.ts+2-2
......@@ -482,7 +482,7 @@ export function createTerminalWidgetHost(
482482 }
483483 partialLineIndex = partialLineLength(buffer);
484484 buffer = "";
485 rendering = false
485 rendering = false;
486486 return;
487487 }
488488
......@@ -1216,8 +1216,8 @@ export type MessageFormatFunction = (
12161216) => string;
12171217
12181218import { ASSERT, UNWRAP } from "./assert.ts";
1219import * as errors from "./error.ts";
12201219import * as async from "./async.ts";
1220import * as errors from "./error.ts";
12211221import * as stack from "./log/stack.ts";
12221222import * as node from "./node.ts";
12231223import * as string from "./string.ts";
lib/mime.ts+2-1
......@@ -1,5 +1,6 @@
11/**
2 * a small mime type library.
2 * a small mime type lookup table library.
3 *
34 * @module
45 */
56
lib/node.ts+1
......@@ -7,6 +7,7 @@
77 * if you are using a competent bundler, you can define `globalThis.process` as
88 * a bundling constant (esbuild: `--define`) to enable tree shaking across the
99 * library to only include browser code paths.
10 *
1011 * @module
1112 */
1213
lib/progress.ts+1
......@@ -40,6 +40,7 @@
4040 * needs more work and feature development. the API of `Node` is stable, though.
4141 *
4242 * inspired by the [Zig Progress API](https://andrewkelley.me/post/zig-new-cli-progress-bar-explained.html).
43 *
4344 * @module
4445 */
4546
lib/queue.ts+1
......@@ -1,6 +1,7 @@
11/**
22 * implements a priority queue. jobs are be automatically cancelled via
33 * `AbortSignal` and rescheduled when higher priority tasks come in.
4 *
45 * @module
56 */
67
lib/stream.ts+3-1
......@@ -1,6 +1,8 @@
11/**
2 * this @module contains helpers for creating and consuming `ReadableStream`,
2 * this module contains helpers for creating and consuming `ReadableStream`,
33 * particularly with binary payloads.
4 *
5 * @module
46 */
57
68const shared = new Uint8Array(8);
lib/string.ts+7
......@@ -1,3 +1,10 @@
1/**
2 * helpers for strings, escaping, and encoding.
3 *
4 * @module
5 */
6
7/** count the number of `\n` characters are in the string */
18export function countNewlines(str: string): number {
29 let count = 0;
310 for (let i = 0, { length } = str; i < length; i += 1) {
lib/string/ansi.ts+1-1
......@@ -6,7 +6,7 @@
66 * note that this file only produces escape sequences, and does not yet feature
77 * detection or fallback code.
88 *
9 * @module
9 * @module ansi
1010 */
1111
1212/** resets all ansi styles */
lib/subprocess.ts+6-2
......@@ -1,5 +1,9 @@
1// This file is expecting a full rewrite to abstract the Node API away
2// entirely, exposing web streams I/O.
1/**
2 * This file is expecting a full rewrite to abstract the Node API away
3 * entirely, exposing web streams I/O.
4 *
5 * @module
6 */
37
48const execFileRaw: typeof child_process.execFile.__promisify__ = util.promisify(
59 child_process.execFile,
lib/subprocess/ffmpeg.ts+8
......@@ -1,3 +1,11 @@
1/**
2 * subprocess bindings for `ffmpeg`, expecting the binary to be in `$PATH` or
3 * given as the `ffmpeg` option when relevant.
4 *
5 * @module ffmpeg
6 */
7
8/** options for {@linkcode spawn} */
19export interface SpawnOptions {
210 args: string[];
311 ffmpeg?: string;
lib/testing.ts+3-1
......@@ -1,6 +1,8 @@
11/**
2 * @module contains some utilities for writing tests. many are only useful for
2 * contains some utilities for writing tests. many are only useful for
33 * testing against other library modules.
4 *
5 * @module testing
46 */
57
68/**
lib/ts.ts+8
......@@ -1,4 +1,12 @@
1/**
2 * helpers for the typescript language
3 *
4 * @module ts
5 */
6
7/** return type of `setTimeout` regardless of the environment */
18export type Timer = ReturnType<typeof setTimeout>;
9/** return type of `setInterval` regardless of the environment */
210export type Interval = ReturnType<typeof setInterval>;
311/** opposite of the built-in `Readonly` type */
412export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
src/source-of-truth.ts+2-1
......@@ -1,4 +1,4 @@
1/** @module
1/**
22 * The "source of truth" server is the canonical storage for
33 * paper clover's files. This is technically needed because
44 * the VPS she uses can only store about 20gb of content, where
......@@ -18,6 +18,7 @@
1818 * need cache busts (paper clover does not), the proper way
1919 * would be to push a message to all VPS nodes instead of
2020 * checking upstream if a file changed every time.
21 * @module
2122 */
2223const app = new Hono();
2324export default app;