From c1fcfaaeff72aeebf47a25822f0135fbbde07ef8 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 14 Dec 2024 21:23:09 +0100 Subject: client: document readFile, writeFile; add getenv, setenv Both are quite useful. readFile and writeFile got a small makeover in error handling; in particular, readFile now returns null instead of the empty string when the file is missing and writeFile throws a TypeError on I/O errors. --- doc/api.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'doc/api.md') diff --git a/doc/api.md b/doc/api.md index 08e9f234..fae58e51 100644 --- a/doc/api.md +++ b/doc/api.md @@ -71,6 +71,36 @@ SIGTSTP signal.
Note: this suspends the entire process group. + +`readFile(path)` +Read a file at `path`.
+Returns the file's content as a string, or null if the file does not +exist. + + + + +`writeFile(path, content)` +Write `content` to the file at `path`.
+Throws a TypeError if this failed for whatever reason. + + + + +`getenv(name, fallback = null)` +Get an environment variable by `name`.
+Returns `fallback` if the variable does not exist. + + + + +`setenv(name, value)` +Set an environment variable by `name`.
+Throws a type error if the operation failed (e.g. because the variable's +size exceeded an OS-specified limit.) + + + `pager` The pager object. Implements `Pager`, as described below. -- cgit