Skip to content
velt/process exports

velt/process

API reference

Write to standard output and read environment variables on the builtin process, with no import, as in Node: For a walkthrough, read the guide.

import { args, Stderr } from "velt/process";

Exports

argsThe arguments after the program path.argvEvery command-line argument, starting with the program path (like C's argv).chdirChanges the current working directory of the whole process (throws IoError).cwdThe current working directory (throws IoError).envAllEvery environment variable, as a snapshot (Node's process.env as an object): names in the order the OS keeps them, which is Node's order too.removeEnvRemoves the environment variable name (see setEnv).setEnvNot synchronized with concurrent process.env reads on other threads: set variables at startup.exitFlushes stdout/stderr and ends the process with code (same as process.exit).linesThe remaining lines, as readLine reads them: for await (const line of lines()).readAllEverything left on standard input.readAllBytesEverything left on standard input, as raw bytes (the runtime's read buffer, not a copy).readAllBytesSyncreadAllBytes that blocks the calling thread.readAllSyncreadAll that blocks the calling thread.readLineThe next line without its "\n" / "\r\n", or null at end of input.readLineSyncreadLine that blocks the calling thread.isattyWhether file descriptor fd is open and refers to a terminal (Node's tty.isatty(fd)): 0 is standard input, 1 standard output, 2 standard error.StderrStandard error, for its isTTY (write strings to it with process.stderr.write(s)).StdinStandard input, for its isTTY (read it with readLine, lines or readAll).StdoutStandard output as a synchronous byte sink (for strings, process.stdout.write(s) needs no import).stderrStandard error (for stderr.isTTY).stdinStandard input (for stdin.isTTY).stdoutStandard output, as a byte sink (stdout.write(bytes)).

Re-exported from velt/process/args

function args(): string[]

The arguments after the program path.

Re-exported from velt/process/args

function argv(): string[]

Every command-line argument, starting with the program path (like C's argv).

Re-exported from velt/process/env

function chdir(path: string)

Changes the current working directory of the whole process (throws IoError).

Re-exported from velt/process/env

function cwd(): string

The current working directory (throws IoError).

Re-exported from velt/process/env

function envAll(): Record<string, string>

Every environment variable, as a snapshot (Node's process.env as an object): names in the order the OS keeps them, which is Node's order too. On Windows names keep their case, and lookups in the record are case-sensitive (process.env.NAME is not); the per-drive =C: entries are left out, as in Node.

function

removeEnv

#std/process/env.vlt:37

Re-exported from velt/process/env

function removeEnv(name: string)

Removes the environment variable name (see setEnv).

Re-exported from velt/process/env

function setEnv(name: string, value: string)

Not synchronized with concurrent process.env reads on other threads: set variables at startup.

Re-exported from velt/process/exit

function exit(code: i32)

Flushes stdout/stderr and ends the process with code (same as process.exit).

functionasync

lines

#std/process/stdin.vlt:35

Re-exported from velt/process/stdin

async function lines(): AsyncGenerator<string, IoError>

The remaining lines, as readLine reads them: for await (const line of lines()).

functionasync

readAll

#std/process/stdin.vlt:51

Re-exported from velt/process/stdin

async function readAll(): Promise<string>

Everything left on standard input.

functionasync

readAllBytes

#std/process/stdin.vlt:61

Re-exported from velt/process/stdin

async function readAllBytes(): Promise<u8[]>

Everything left on standard input, as raw bytes (the runtime's read buffer, not a copy).

function

readAllBytesSync

#std/process/stdin.vlt:66

Re-exported from velt/process/stdin

function readAllBytesSync(): u8[]

readAllBytes that blocks the calling thread.

function

readAllSync

#std/process/stdin.vlt:56

Re-exported from velt/process/stdin

function readAllSync(): string

readAll that blocks the calling thread.

functionasync

readLine

#std/process/stdin.vlt:30

Re-exported from velt/process/stdin

async function readLine(): Promise<string | null>

The next line without its "\n" / "\r\n", or null at end of input.

function

readLineSync

#std/process/stdin.vlt:46

Re-exported from velt/process/stdin

function readLineSync(): string | null

readLine that blocks the calling thread.

Re-exported from velt/process/tty

function isatty(fd: i32): bool

Whether file descriptor fd is open and refers to a terminal (Node's tty.isatty(fd)): 0 is standard input, 1 standard output, 2 standard error. On Windows only those three can be terminals.

Re-exported from velt/process/stderr

Standard error, for its isTTY (write strings to it with process.stderr.write(s)).

get isTTY(): bool

Whether standard error is a terminal (Node's process.stderr.isTTY). Cached.

Re-exported from velt/process/stdin

Standard input, for its isTTY (read it with readLine, lines or readAll).

get isTTY(): bool

Whether standard input is a terminal (Node's process.stdin.isTTY). Cached.

Re-exported from velt/process/stdout

Standard output as a synchronous byte sink (for strings, process.stdout.write(s) needs no import). Writes are ordered with console.log and buffered the same way; a large array (64 KiB or more) goes straight to the OS from the caller's buffer, without a copy. Portable: no /dev/stdout needed.

write(bytes: u8[])

Writes raw bytes (the array stays the caller's, ready to be refilled).

get isTTY(): bool

Whether standard output is a terminal (Node's process.stdout.isTTY): false when it is redirected to a file or a pipe, so a CLI can leave out colours. Asked once, then cached.

Re-exported from velt/process/stderr

const stderr: Stderr = {}

Standard error (for stderr.isTTY).

Re-exported from velt/process/stdin

const stdin: Stdin = {}

Standard input (for stdin.isTTY).

Re-exported from velt/process/stdout

const stdout: Stdout = {}

Standard output, as a byte sink (stdout.write(bytes)).