as-wasi

December 27, 2025 ยท View on GitHub

as-wasi


as-wasi

Classes

Classes

as-wasi


as-wasi / CommandLine

Class: CommandLine

Defined in: as-wasi.ts:986

Constructors

Constructor

new CommandLine(): CommandLine

Defined in: as-wasi.ts:989

Returns

CommandLine

Properties

args

args: string[]

Defined in: as-wasi.ts:987

Accessors

all

Get Signature

get static all(): string[]

Defined in: as-wasi.ts:1016

Return all the command-line arguments

Returns

string[]

Methods

all()

all(): string[]

Defined in: as-wasi.ts:1024

Return all the command-line arguments

Returns

string[]


get()

get(index): string | null

Defined in: as-wasi.ts:1032

Return the i-th command-ine argument

Parameters
index

number

Returns

string | null

as-wasi


as-wasi / Console

Class: Console

Defined in: as-wasi.ts:819

Constructors

Constructor

new Console(): Console

Returns

Console

Methods

error()

static error(s, newline): void

Defined in: as-wasi.ts:855

Write an error to the console

Parameters
s

string

string

newline

bool = true

false to avoid inserting a newline after the string

Returns

void


log()

static log(s): void

Defined in: as-wasi.ts:846

Alias for Console.write()

Parameters
s

string

Returns

void


readAll()

static readAll(): string | null

Defined in: as-wasi.ts:832

Read as much data as possible from the console, convert it to a native string

Returns

string | null


readLine()

static readLine(): string | null

Defined in: as-wasi.ts:839

Read a line of text from the console, convert it from UTF8 to a native string

Returns

string | null


write()

static write(s, newline): void

Defined in: as-wasi.ts:825

Write a string to the console

Parameters
s

string

string

newline

bool = true

false to avoid inserting a newline after the string

Returns

void

as-wasi


as-wasi / Date

Class: Date

Defined in: as-wasi.ts:889

Constructors

Constructor

new Date(): Date

Returns

Date

Methods

now()

static now(): number

Defined in: as-wasi.ts:893

Return the current timestamp, as a number of milliseconds since the epoch

Returns

number

as-wasi


as-wasi / Descriptor

Class: Descriptor

Defined in: as-wasi.ts:90

A descriptor, that doesn't necessarily have to represent a file

Constructors

Constructor

new Descriptor(rawfd): Descriptor

Defined in: as-wasi.ts:115

Build a new descriptor from a raw WASI file descriptor

Parameters
rawfd

number

a raw file descriptor

Returns

Descriptor

Accessors

rawfd

Get Signature

get rawfd(): number

Defined in: as-wasi.ts:119

Returns

number


Invalid

Get Signature

get static Invalid(): Descriptor

Defined in: as-wasi.ts:94

An invalid file descriptor, that can represent an error

Returns

Descriptor


Stderr

Get Signature

get static Stderr(): Descriptor

Defined in: as-wasi.ts:109

The standard error

Returns

Descriptor


Stdin

Get Signature

get static Stdin(): Descriptor

Defined in: as-wasi.ts:99

The standard input

Returns

Descriptor


Stdout

Get Signature

get static Stdout(): Descriptor

Defined in: as-wasi.ts:104

The standard output

Returns

Descriptor

Methods

advise()

advise(offset, len, advice): bool

Defined in: as-wasi.ts:130

Hint at how the data accessible via the descriptor will be used

Parameters
offset

number

len

number

advice

number

Returns

bool

true on success, false on error

Offset

offset

Len

length

Advice

advice.{NORMAL, SEQUENTIAL, RANDOM, WILLNEED, DONTNEED, NOREUSE}


allocate()

allocate(offset, len): bool

Defined in: as-wasi.ts:140

Preallocate data

Parameters
offset

number

where to start preallocating data in the file

len

number

bytes to preallocate

Returns

bool

true on success, false on error


close()

close(): void

Defined in: as-wasi.ts:283

Close a file descriptor

Returns

void


dirName()

dirName(): string

Defined in: as-wasi.ts:261

Return the directory associated to that descriptor

Returns

string


fatime()

fatime(ts): bool

Defined in: as-wasi.ts:207

Update the access time

Parameters
ts

number

Returns

bool

true on success, false on error

Ts

timestamp in seconds


fdatasync()

fdatasync(): bool

Defined in: as-wasi.ts:148

Wait for the data to be written

Returns

bool

true on success, false on error


fileType()

fileType(): number

Defined in: as-wasi.ts:163

Return the file type

Returns

number


fmtime()

fmtime(ts): bool

Defined in: as-wasi.ts:219

Update the modification time

Parameters
ts

number

Returns

bool

true on success, false on error

Ts

timestamp in seconds


fsync()

fsync(): bool

Defined in: as-wasi.ts:156

Wait for the data and metadata to be written

Returns

bool

true on success, false on error


ftruncate()

ftruncate(size): bool

Defined in: as-wasi.ts:198

Change the size of a file

Parameters
size

number = 0

new size

Returns

bool

true on success, false on error


futimes()

futimes(atime, mtime): bool

Defined in: as-wasi.ts:232

Update both the access and the modification times

Parameters
atime

number

mtime

number

Returns

bool

true on success, false on error

Atime

timestamp in seconds

Mtime

timestamp in seconds


read()

read(data, chunk_size): number[] | null

Defined in: as-wasi.ts:348

Read data from a file descriptor

Parameters
data

number[] = []

existing array to push data to

chunk_size

number = 4096

chunk size (default: 4096)

Returns

number[] | null


readAll()

readAll(data, chunk_size): number[] | null

Defined in: as-wasi.ts:378

Read from a file descriptor until the end of the stream

Parameters
data

number[] = []

existing array to push data to

chunk_size

number = 4096

chunk size (default: 4096)

Returns

number[] | null


readLine()

readLine(): string | null

Defined in: as-wasi.ts:411

Read a line of text from a file descriptor

Returns

string | null


readString()

readString(chunk_size): string | null

Defined in: as-wasi.ts:448

Read as much data as possible from a file descriptor, convert it to a native string

Parameters
chunk_size

number = 4096

chunk size (default: 4096)

Returns

string | null


seek()

seek(off, w): bool

Defined in: as-wasi.ts:462

Seek into a stream

Parameters
off

number

w

number

Returns

bool

Off

offset

W

the position relative to which to set the offset of the file descriptor.


setFlags()

setFlags(flags): bool

Defined in: as-wasi.ts:177

Set WASI flags for that descriptor

Parameters
flags

number

Returns

bool

true on success, false on error

Params

flags: one or more of fdflags.{APPEND, DSYNC, NONBLOCK, RSYNC, SYNC}


stat()

stat(): FileStat

Defined in: as-wasi.ts:185

Retrieve information about a descriptor

Returns

FileStat

a FileStat object`


tell()

tell(): number

Defined in: as-wasi.ts:473

Return the current offset in the stream

Returns

number

offset


touch()

touch(): bool

Defined in: as-wasi.ts:247

Update the timestamp of the object represented by the descriptor

Returns

bool

true on success, false on error


write()

write(data): void

Defined in: as-wasi.ts:291

Write data to a file descriptor

Parameters
data

number[]

data

Returns

void


writeString()

writeString(s, newline): void

Defined in: as-wasi.ts:309

Write a string to a file descriptor, after encoding it to UTF8

Parameters
s

string

string

newline

bool = false

true to add a newline after the string

Returns

void


writeStringLn()

writeStringLn(s): void

Defined in: as-wasi.ts:328

Write a string to a file descriptor, after encoding it to UTF8, with a newline

Parameters
s

string

string

Returns

void

as-wasi


as-wasi / Environ

Class: Environ

Defined in: as-wasi.ts:927

Constructors

Constructor

new Environ(): Environ

Defined in: as-wasi.ts:930

Returns

Environ

Properties

env

env: EnvironEntry[]

Defined in: as-wasi.ts:928

Accessors

all

Get Signature

get static all(): EnvironEntry[]

Defined in: as-wasi.ts:958

Return all environment variables

Returns

EnvironEntry[]

Methods

all()

all(): EnvironEntry[]

Defined in: as-wasi.ts:966

Return all environment variables

Returns

EnvironEntry[]


get()

get(key): string | null

Defined in: as-wasi.ts:974

Return the value for an environment variable

Parameters
key

string

environment variable name

Returns

string | null

as-wasi


as-wasi / EnvironEntry

Class: EnvironEntry

Defined in: as-wasi.ts:923

Constructors

Constructor

new EnvironEntry(key, value): EnvironEntry

Defined in: as-wasi.ts:924

Parameters
key

string

value

string

Returns

EnvironEntry

Properties

key

readonly key: string

Defined in: as-wasi.ts:924


value

readonly value: string

Defined in: as-wasi.ts:924

as-wasi


as-wasi / FileStat

Class: FileStat

Defined in: as-wasi.ts:70

Portable information about a file

Constructors

Constructor

new FileStat(st_buf): FileStat

Defined in: as-wasi.ts:77

Parameters
st_buf

number

Returns

FileStat

Properties

access_time

access_time: number

Defined in: as-wasi.ts:73


creation_time

creation_time: number

Defined in: as-wasi.ts:75


file_size

file_size: number

Defined in: as-wasi.ts:72


file_type

file_type: number

Defined in: as-wasi.ts:71


modification_time

modification_time: number

Defined in: as-wasi.ts:74

as-wasi


as-wasi / FileSystem

Class: FileSystem

Defined in: as-wasi.ts:486

A class to access a filesystem

Constructors

Constructor

new FileSystem(): FileSystem

Returns

FileSystem

Methods

dirfdForPath()

protected static dirfdForPath(path): number

Defined in: as-wasi.ts:813

Parameters
path

string

Returns

number


exists()

static exists(path): bool

Defined in: as-wasi.ts:577

Check if a file exists at a given path

Parameters
path

string

Returns

bool

true on success, false on failure

Path

path


static link(old_path, new_path): bool

Defined in: as-wasi.ts:600

Create a hard link @old_path old path @new_path new path

Parameters
old_path

string

new_path

string

Returns

bool

true on success, false on failure


lstat()

static lstat(path): FileStat

Defined in: as-wasi.ts:716

Retrieve information about a file or a symbolic link

Parameters
path

string

Returns

FileStat

a FileStat object

Path

path


mkdir()

static mkdir(path): bool

Defined in: as-wasi.ts:560

Create a new directory

Parameters
path

string

Returns

bool

true on success, false on failure

Path

path


open()

static open(path, flags): Descriptor | null

Defined in: as-wasi.ts:493

Open a path

Parameters
path

string

flags

string = "r"

Returns

Descriptor | null

a descriptor

Path

path

Flags

r, r+, w, wx, w+ or xw+


readdir()

static readdir(path): string[] | null

Defined in: as-wasi.ts:770

Get the content of a directory

Parameters
path

string

the directory path

Returns

string[] | null

An array of file names


rename()

static rename(old_path, new_path): bool

Defined in: as-wasi.ts:742

Rename a file @old_path old path @new_path new path

Parameters
old_path

string

new_path

string

Returns

bool

true on success, false on failure


rmdir()

static rmdir(path): bool

Defined in: as-wasi.ts:674

Remove a directory

Parameters
path

string

Returns

bool

true on success, false on failure

Path

path


stat()

static stat(path): FileStat

Defined in: as-wasi.ts:691

Retrieve information about a file

Parameters
path

string

Returns

FileStat

a FileStat object

Path

path


static symlink(old_path, new_path): bool

Defined in: as-wasi.ts:631

Create a symbolic link @old_path old path @new_path new path

Parameters
old_path

string

new_path

string

Returns

bool

true on success, false on failure


static unlink(path): bool

Defined in: as-wasi.ts:657

Unlink a file

Parameters
path

string

Returns

bool

true on success, false on failure

Path

path

as-wasi


as-wasi / Process

Class: Process

Defined in: as-wasi.ts:912

Constructors

Constructor

new Process(): Process

Returns

Process

Methods

exit()

static exit(status): void

Defined in: as-wasi.ts:918

Cleanly terminate the current process

Parameters
status

number

exit code

Returns

void

as-wasi


as-wasi / Random

Class: Random

Defined in: as-wasi.ts:860

Constructors

Constructor

new Random(): Random

Returns

Random

Methods

randomBytes()

static randomBytes(len): Uint8Array

Defined in: as-wasi.ts:882

Return an array of random bytes

Parameters
len

number

length

Returns

Uint8Array


randomFill()

static randomFill(buffer): void

Defined in: as-wasi.ts:865

Fill a buffer with random data

Parameters
buffer

ArrayBuffer

An array buffer

Returns

void

as-wasi


as-wasi / Time

Class: Time

Defined in: as-wasi.ts:1042

Constructors

Constructor

new Time(): Time

Returns

Time

Properties

MILLISECOND

static MILLISECOND: number

Defined in: as-wasi.ts:1044


NANOSECOND

static NANOSECOND: number = 1

Defined in: as-wasi.ts:1043


SECOND

static SECOND: number

Defined in: as-wasi.ts:1045

Methods

sleep()

static sleep(nanoseconds): void

Defined in: as-wasi.ts:1049

Parameters
nanoseconds

number

Returns

void

as-wasi


as-wasi / WASIError

Class: WASIError

Defined in: as-wasi.ts:60

A WASI error

Extends

  • Error

Constructors

Constructor

new WASIError(message): WASIError

Defined in: as-wasi.ts:61

Parameters
message

string = ""

Returns

WASIError

Overrides

Error.constructor