"quickjs:os" (namespace)
(fd: number, offset: number, whence: number): number;
(fd: number, offset: bigint, whence: number): bigint;
}
fd: number,
buffer: ArrayBuffer,
offset: number,
length: number,
): number;
fd: number,
buffer: ArrayBuffer,
offset: number,
length: number,
): number;
uid: number;
gid: number;
};
func: null | undefined | (() => void),
): void;
cwd?: string;
[key: string | number]: string | number | boolean;
};
uid?: number;
gid?: number;
};
| "win32"
| "darwin"
| "emscripten"
| "wasm"
| "freebsd"
| "linux"
| "unknown";
| string
| number
| boolean
| null
| undefined
| Boolean
| String
| Date
| RegExp
| ArrayBuffer
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array
| DataView
| SharedArrayBuffer
| {
};
constructor(
moduleFilename: string,
options?: {
overrideCode?: string;
},
);
| null
| ((event: {
message: string;
filename: string;
lineno: number;
error: Error | null;
}) => void);
}
private constructor();
readonly [Symbol.toStringTag]: "Win32Handle";
}
cwd?: string;
[key: string]: string;
};
};
};
| undefined
| ((
commandLine: string | null,
};
};
undefined | ((options?: CreatePipeOptions) => CreatePipeResult);
}
"quickjs:os".open (exported function)
Open a file handle. Returns a number; the file descriptor.
@paramfilename — The path to the file to open.@paramflags — Numeric flags that set the mode to use when opening the file. Seeos.O_*@parammode — Octal access mask. Defaults to 0o666.
"quickjs:os".O_RDONLY (exported number)
POSIX open flag, used in open.
"quickjs:os".O_WRONLY (exported number)
"quickjs:os".O_RDWR (exported number)
"quickjs:os".O_APPEND (exported number)
"quickjs:os".O_CREAT (exported number)
"quickjs:os".O_EXCL (exported number)
"quickjs:os".O_TRUNC (exported number)
"quickjs:os".O_BINARY (exported number)
"quickjs:os".O_TEXT (exported number)
"quickjs:os".close (exported function)
Close the file with descriptor fd.
"quickjs:os".OsSeek (interface)
(fd: number, offset: number, whence: number): number;
(fd: number, offset: bigint, whence: number): bigint;
}
OsSeek(...) (call signature)
(fd: number, offset: number, whence: number): number;
OsSeek(...) (call signature)
(fd: number, offset: bigint, whence: number): bigint;
"quickjs:os".seek (exported OsSeek)
"quickjs:os".read (exported function)
fd: number,
buffer: ArrayBuffer,
offset: number,
length: number,
): number;
"quickjs:os".write (exported function)
fd: number,
buffer: ArrayBuffer,
offset: number,
length: number,
): number;
"quickjs:os".isatty (exported function)
"quickjs:os".ttyGetWinSize (exported function)
"quickjs:os".ttySetRaw (exported function)
"quickjs:os".remove (exported function)
"quickjs:os".rename (exported function)
"quickjs:os".realpath (exported function)
"quickjs:os".getcwd (exported function)
"quickjs:os".chdir (exported function)
"quickjs:os".mkdir (exported function)
"quickjs:os".readdir (exported function)
"quickjs:os".Stats (exported type)
Stats.dev (number property)
Stats.ino (number property)
Stats.mode (number property)
Stats.nlink (number property)
Stats.uid (number property)
uid: number;
Stats.gid (number property)
gid: number;
Stats.rdev (number property)
Stats.size (number property)
Stats.blocks (number property)
Stats.atime (number property)
Stats.mtime (number property)
Stats.ctime (number property)
"quickjs:os".stat (exported function)
"quickjs:os".lstat (exported function)
"quickjs:os".S_IFMT (exported number)
"quickjs:os".S_IFIFO (exported number)
"quickjs:os".S_IFCHR (exported number)
"quickjs:os".S_IFDIR (exported number)
"quickjs:os".S_IFBLK (exported number)
"quickjs:os".S_IFREG (exported number)
"quickjs:os".S_IFSOCK (exported number)
"quickjs:os".S_IFLNK (exported number)
"quickjs:os".S_ISGID (exported number)
"quickjs:os".S_ISUID (exported number)
"quickjs:os".S_IRWXU (exported number)
"quickjs:os".S_IRUSR (exported number)
"quickjs:os".S_IWUSR (exported number)
"quickjs:os".S_IXUSR (exported number)
"quickjs:os".S_IRWXG (exported number)
"quickjs:os".S_IRGRP (exported number)
"quickjs:os".S_IWGRP (exported number)
"quickjs:os".S_IXGRP (exported number)
"quickjs:os".S_IRWXO (exported number)
"quickjs:os".S_IROTH (exported number)
"quickjs:os".S_IWOTH (exported number)
"quickjs:os".S_IXOTH (exported number)
"quickjs:os".utimes (exported function)
"quickjs:os".symlink (exported function)
"quickjs:os".readlink (exported function)
"quickjs:os".setReadHandler (exported function)
Register a function to be called when fd becomes readable.
Pass null as func to unregister.
Windows: only fd === 0 (stdin) is supported. Calling with any
other fd throws — the underlying Windows event loop has no plumbing
for arbitrary fds (it special-cases the stdin console handle), so
registering would silently never fire.
"quickjs:os".setWriteHandler (exported function)
Register a function to be called when fd becomes writable.
Pass null as func to unregister.
Windows: not supported — the Windows event loop has no plumbing
for write readiness on any fd. Calling this with a non-null
handler throws on Windows.
"quickjs:os".signal (exported function)
"quickjs:os".SIGINT (exported number)
"quickjs:os".SIGABRT (exported number)
"quickjs:os".SIGFPE (exported number)
"quickjs:os".SIGILL (exported number)
"quickjs:os".SIGSEGV (exported number)
"quickjs:os".SIGTERM (exported number)
"quickjs:os".SIGQUIT (exported number)
"quickjs:os".SIGPIPE (exported number)
"quickjs:os".SIGALRM (exported number)
"quickjs:os".SIGUSR1 (exported number)
"quickjs:os".SIGUSR2 (exported number)
"quickjs:os".SIGCHLD (exported number)
"quickjs:os".SIGCONT (exported number)
"quickjs:os".SIGSTOP (exported number)
"quickjs:os".SIGTSTP (exported number)
"quickjs:os".SIGTTIN (exported number)
"quickjs:os".SIGTTOU (exported number)
"quickjs:os".kill (exported function)
"quickjs:os".ExecOptions (exported type)
ExecOptions.block (boolean property)
ExecOptions.usePath (boolean property)
ExecOptions.file (string property)
ExecOptions.cwd (string property)
cwd?: string;
ExecOptions.stdin (property)
ExecOptions.stdout (property)
ExecOptions.stderr (property)
ExecOptions.env (object property)
[key: string | number]: string | number | boolean;
};
ExecOptions.uid (number property)
uid?: number;
ExecOptions.gid (number property)
gid?: number;
"quickjs:os".exec (exported function)
"quickjs:os".getpid (exported function)
Return the current process ID.
"quickjs:os".waitpid (exported function)
"quickjs:os".WNOHANG (exported number)
"quickjs:os".WUNTRACED (exported number)
"quickjs:os".WEXITSTATUS (exported function)
"quickjs:os".WTERMSIG (exported function)
"quickjs:os".WSTOPSIG (exported function)
"quickjs:os".WIFEXITED (exported function)
"quickjs:os".WIFSIGNALED (exported function)
"quickjs:os".WIFSTOPPED (exported function)
"quickjs:os".WIFCONTINUED (exported function)
"quickjs:os".dup (exported function)
"quickjs:os".dup2 (exported function)
"quickjs:os".pipe (exported function)
"quickjs:os".sleep (exported function)
"quickjs:os".now (exported function)
Return a timestamp in milliseconds with more precision than
Date.now(). The time origin is unspecified and is normally not
impacted by system clock adjustments.
"quickjs:os".platform (exported value)
"win32" | "darwin" | "emscripten" | "wasm" | "freebsd" | "linux" | "unknown";
"quickjs:os".StructuredClonable (exported type)
| string
| number
| boolean
| null
| undefined
| Boolean
| String
| Date
| RegExp
| ArrayBuffer
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array
| DataView
| SharedArrayBuffer
| {
};
"quickjs:os".Worker (exported class)
constructor(
moduleFilename: string,
options?: {
overrideCode?: string;
},
);
| null
| ((event: {
message: string;
filename: string;
lineno: number;
error: Error | null;
}) => void);
}
Worker (constructor)
Create a Worker which runs the module at moduleFilename.
If options.overrideCode is present, the Worker instead runs a synthetic
module with filename moduleFilename and source code
options.overrideCode (JS source code string). In this case,
moduleFilename is not read from disk and is only used as the module's
assigned filename for import.meta, module resolution, etc.
If options.initialData is present, it'll be available within the worker
as the static initialData property on the Worker constructor.
constructor(moduleFilename: string, options?: {
overrideCode?: string;
});
Worker.initialData (static StructuredClonable property)
If accessed within a Worker, and the Worker was constructed with
non-undefined initialData, then this will be a structured clone of that
initial data.
Outside of a worker, this is always undefined.
Worker.parent (static property)
Worker-side communication channel back to the parent context that invoked it (ie. the main thread).
Worker.prototype.postMessage (method)
Worker.prototype.terminate (method)
Terminate the worker thread. Equivalent to setting onmessage to null.
Worker.prototype.onmessage (property)
}) => void);
Worker.prototype.onerror (property)
Fires on the parent side whenever an uncaught exception escapes
anywhere in the worker: top-level errors at startup, the worker's
global onmessage throwing, timer / I/O / signal callbacks
throwing, microtask rejections, and unhandled promise rejections.
The event is a plain object shaped like a WHATWG ErrorEvent
(minus colno, which this event does not surface):
message— the error's message, orString(reason)for a non-Error throw.filename— from the error'sfileNameown-prop when present, otherwise the worker's entry-module filename.lineno— from the error'slineNumberown-prop, otherwise0.error— a realErrorinstance when the worker threw an Error (one of the nine recognized classes:Error,TypeError,RangeError,SyntaxError,ReferenceError,URIError,EvalError,AggregateError,InternalError, with user subclasses reified to baseErrorwith.namepreserved).nullwhen the thrown value was not an Error.
Cycles and shared references in the error graph (e.g.
err.cause === err, or shared nodes inside
AggregateError.errors[]) are preserved, matching the HTML
structured-clone algorithm.
A handler assigned same-tick as new Worker(...) is guaranteed
to be in place before any error dispatch: the parent's event
loop cannot drain and dispatch error-pipe messages until the
current synchronous tick finishes, and the error-port
registration (on which dispatch is gated) happens synchronously
in the Worker ctor. Cross-tick late assignment (setTimeout(() => w.onerror = fn, 100)) is still racy with any error that fires
before the timeout — such errors fall through to the stderr
fallback. When onerror is unset, errors print to stderr in the
same format as an uncaught exception would.
message: string;
filename: string;
lineno: number;
error: Error | null;
}) => void);
"quickjs:os".Win32Handle (exported class)
An opaque wrapper around a Win32 HANDLE.
Win32Handle objects cannot be created directly from JavaScript code. They are created by native functions like CreateProcess.
On non-Windows platforms, this class exists but no instances will ever be created.
private constructor();
readonly [Symbol.toStringTag]: "Win32Handle";
}
Win32Handle (constructor)
private constructor();
"quickjs:os".CreateProcessOptions (exported type)
cwd?: string;
[key: string]: string;
};
};
CreateProcessOptions.moduleName (string property)
The name of the module to be executed (maps to lpApplicationName).
CreateProcessOptions.flags (number property)
Process creation flags (maps to dwCreationFlags).
CreateProcessOptions.cwd (string property)
The working directory of the new process.
cwd?: string;
CreateProcessOptions.env (object property)
Environment variables for the new process. If not specified, the parent's environment is inherited. Values must be strings.
[key: string]: string;
};
CreateProcessOptions.stdin (property)
FILE object or file descriptor number to use for the child's stdin.
CreateProcessOptions.stdout (property)
FILE object or file descriptor number to use for the child's stdout.
CreateProcessOptions.stderr (property)
FILE object or file descriptor number to use for the child's stderr.
"quickjs:os".CreateProcessResult (exported type)
};
CreateProcessResult.pid (number property)
The process ID of the newly created process.
CreateProcessResult.processHandle (Win32Handle property)
A Win32Handle for the process.
CreateProcessResult.tid (number property)
The thread ID of the primary thread of the newly created process.
CreateProcessResult.threadHandle (Win32Handle property)
A Win32Handle for the primary thread.
"quickjs:os".CreateProcess (exported value)
Create a new process using the Win32 CreateProcessW API.
@paramcommandLine — The command line to execute.@paramoptions — Optional settings for module name, flags, cwd, env, and stdio redirection.@returnsAn object withpid,processHandle,tid, andthreadHandle.
NOTE: this function is only present on windows
| undefined
| ((
commandLine: string | null,
"quickjs:os".WaitForSingleObject (exported value)
Wait for a Win32 handle to be signaled (wrapper for Win32 WaitForSingleObject).
@paramhandle — The handle to wait on.@paramtimeoutMs — Timeout in milliseconds. Defaults toInfinity(INFINITE). PassInfinityto wait indefinitely.@returnsOne of theWAIT_*constants.
NOTE: this function is only present on windows
"quickjs:os".GetExitCodeProcess (exported value)
Retrieve the exit code of a process (wrapper for Win32 GetExitCodeProcess).
@paramhandle — A process handle.@returnsThe exit code of the process.
NOTE: this function is only present on windows
"quickjs:os".TerminateProcess (exported value)
Terminate a process (wrapper for Win32 TerminateProcess).
@paramhandle — A process handle.@paramexitCode — The exit code to assign to the process.
NOTE: this function is only present on windows
"quickjs:os".CloseHandle (exported value)
Close a Win32 handle. The handle will automatically be closed when the Win32Handle object is garbage-collected, but it's safe to close it yourself as well; a handle that has already been closed will not be closed again during garbage collection.
@paramhandle — The handle to close.
NOTE: this function is only present on windows
"quickjs:os".CreatePipeOptions (exported type)
};
CreatePipeOptions.inheritHandle (boolean property)
Whether the pipe handles should be inheritable. Defaults to true.
"quickjs:os".CreatePipeResult (exported type)
};
CreatePipeResult.readEnd (FILE property)
The read end of the pipe (a FILE object opened in binary read mode).
CreatePipeResult.writeEnd (FILE property)
The write end of the pipe (a FILE object opened in binary write mode).
"quickjs:os".CreatePipe (exported value)
Create an anonymous pipe (wrapper for Win32 CreatePipe).
Returns FILE objects for both ends of the pipe. The read end is opened in binary read mode ("rb") and the write end in binary write mode ("wb"). You can use all standard FILE methods (readAsString, getline, puts, write, read, close, etc.) on the returned objects.
@paramoptions — Optional settings.inheritHandledefaults to true.@returnsAn object withreadEndandwriteEndFILE properties.
NOTE: this function is only present on windows
"quickjs:os".WAIT_OBJECT_0 (exported value)
Win32 wait result constant: the object was signaled.
NOTE: this property is only present on windows
"quickjs:os".WAIT_ABANDONED (exported value)
Win32 wait result constant: the object was an abandoned mutex.
NOTE: this property is only present on windows
"quickjs:os".WAIT_TIMEOUT (exported value)
Win32 wait result constant: the wait timed out.
NOTE: this property is only present on windows
"quickjs:os".WAIT_FAILED (exported value)
Win32 wait result constant: the function call failed.
NOTE: this property is only present on windows
"quickjs:os".R_OK (exported number)
"quickjs:os".W_OK (exported number)
"quickjs:os".X_OK (exported number)
"quickjs:os".F_OK (exported number)
"quickjs:os".access (exported function)
"quickjs:os".execPath (exported function)
"quickjs:os".chmod (exported function)
"quickjs:os".gethostname (exported function)