char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somgenerate std typedefs from typescript impl38d7f6c

main
3.7 KiB90 linesraw
1import * as file from "ext:file/sync.js";
2import * as stdio from "ext:stdio/sync.js";
3
4import type { DirEntry, FileInfo, OpenOptions } from "avril:std";
5export type { DirEntry, FileInfo, OpenOptions } from "avril:std";
6export type FileHandle = import("avril:std").FileHandle;
7
8export const errors: typeof import("avril:std").errors = file.errors;
9export const FileHandle: typeof import("avril:std").FileHandle = file.FileHandle;
10export const SeekMode: typeof import("avril:std").SeekMode = file.SeekMode;
11
12/** Blocking stdin. Overlapping native reads throw Busy; canceling the async stream also closes this input. Unavailable in the REPL and workers. */
13export const stdin: Readonly<{
14  read(buffer: Uint8Array): number | null;
15}> = stdio.stdin;
16/** Blocking output, ordered with already-submitted stream and console writes. Does not run JS callbacks while waiting. */
17export const stdout: Readonly<{
18  write(bytes: Uint8Array): number;
19}> = stdio.stdout;
20export const stderr: Readonly<{
21  write(bytes: Uint8Array): number;
22}> = stdio.stderr;
23
24export const open: (
25  path: string | URL,
26  options?: OpenOptions,
27) => FileHandle = file.open;
28export const create: (path: string | URL) => FileHandle = file.create;
29export const stat: (path: string | URL) => FileInfo = file.stat;
30export const lstat: (path: string | URL) => FileInfo = file.lstat;
31export const readDir: (path: string | URL) => Iterable<DirEntry> = file.readDir;
32export const mkdir: (
33  path: string | URL,
34  options?: { mode?: number },
35) => void = file.mkdir;
36export const remove: (
37  path: string | URL,
38  options?: { recursive?: boolean },
39) => void = file.remove;
40/** Requires directory-shaped authority over the source (read/write) and destination (write). Scoped directory renames containing symlinks are not yet implemented. */
41export const rename: (
42  source: string | URL,
43  destination: string | URL,
44) => void = file.rename;
45export const copyFile: (
46  source: string | URL,
47  destination: string | URL,
48) => void = file.copyFile;
49/** Stores target text unchanged; requires write at the link and read/write tree authority over its target. Creation on Windows is not yet implemented. */
50export const symlink: (
51  target: string | URL,
52  linkPath: string | URL,
53  options?: { type?: "file" | "dir" },
54) => void = file.symlink;
55/** Reads the link's stored text, not its referent. */
56export const readLink: (path: string | URL) => string = file.readLink;
57export const realPath: (path: string | URL) => string = file.realPath;
58/** Changes the file mode bits. Follows links. */
59export const chmod: (path: string | URL, mode: number) => void = file.chmod;
60/** Null keeps that id; 4294967295 is rejected. Follows links. */
61export const chown: (
62  path: string | URL,
63  uid: number | null,
64  gid: number | null,
65) => void = file.chown;
66/** Like chown but acts on the link itself. */
67export const lchown: (
68  path: string | URL,
69  uid: number | null,
70  gid: number | null,
71) => void = file.lchown;
72/** Times are seconds since the Unix epoch, like Deno and Node; Dates are accepted. Follows links. */
73export const utime: (
74  path: string | URL,
75  atime: number | Date,
76  mtime: number | Date,
77) => void = file.utime;
78/** Like utime but acts on the link itself; a trailing slash follows instead. */
79export const lutime: (
80  path: string | URL,
81  atime: number | Date,
82  mtime: number | Date,
83) => void = file.lutime;
84/** Requires read and write authority over the source and write over the destination; symlink sources are refused. */
85export const link: (
86  oldpath: string | URL,
87  newpath: string | URL,
88) => void = file.link;
89/** Sets the file size, zero-filling growth. Follows links. */
90export const truncate: (path: string | URL, length?: number) => void = file.truncate;