Yuari
Documentation
Docs/File system/readfile

readfile(path) / readfileasync(path)

Reads a workspace file; readfileasync yields while the read runs in a deferred task.

Syntax

readfile(path: string) -> string

Parameters

ParameterTypeDescription
pathstringWorkspace-relative path.

Returns

TypeDescription
stringFile contents.

Description

readfile is synchronous and throws when the file does not exist.

Logic change: readfileasync now schedules readfile with task.defer and yields the caller until the result is ready, so background scripts can read files without blocking the current frame.

Example

writefile("notes.txt", "hello")
print(readfileasync("notes.txt"))