Skip to content

Latest commit

 

History

History
1694 lines (923 loc) · 30.1 KB

REFERENCE_API_DOCS.md

File metadata and controls

1694 lines (923 loc) · 30.1 KB

as-wasi

Globals

as-wasi

Index

Classes

Type aliases

Functions

Type aliases

aisize

Ƭ aisize: i32

Defined in assembly/as-wasi.ts:55

Functions

wasi_abort

wasi_abort(message?: string, fileName?: string, lineNumber?: u32, columnNumber?: u32): void

Defined in assembly/as-wasi.ts:1102

Parameters:

Name Type Default value
message string ""
fileName string ""
lineNumber u32 0
columnNumber u32 0

Returns: void

Classes

as-wasi

Globals / CommandLine

Class: CommandLine

Hierarchy

  • CommandLine

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new CommandLine(): CommandLine

Defined in assembly/as-wasi.ts:989

Returns: CommandLine

Properties

args

args: string[]

Defined in assembly/as-wasi.ts:989

Accessors

all

Staticget all(): Array<string>

Defined in assembly/as-wasi.ts:1018

Return all the command-line arguments

Returns: Array<string>

Methods

all

all(): Array<string>

Defined in assembly/as-wasi.ts:1026

Return all the command-line arguments

Returns: Array<string>


get

get(index: usize): string | null

Defined in assembly/as-wasi.ts:1034

Return the i-th command-ine argument

Parameters:
Name Type
index usize

Returns: string | null

as-wasi

Globals / Console

Class: Console

Hierarchy

  • Console

Index

Methods

Methods

error

Staticerror(s: string, newline?: bool): void

Defined in assembly/as-wasi.ts:857

Write an error to the console

Parameters:
Name Type Default value Description
s string - string
newline bool true false to avoid inserting a newline after the string

Returns: void


log

Staticlog(s: string): void

Defined in assembly/as-wasi.ts:848

Alias for Console.write()

Parameters:
Name Type
s string

Returns: void


readAll

StaticreadAll(): string | null

Defined in assembly/as-wasi.ts:834

Read an UTF8 string from the console, convert it to a native string

Returns: string | null


readLine

StaticreadLine(): string | null

Defined in assembly/as-wasi.ts:841

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

Returns: string | null


write

Staticwrite(s: string, newline?: bool): void

Defined in assembly/as-wasi.ts:827

Write a string to the console

Parameters:
Name Type Default value Description
s string - string
newline bool true false to avoid inserting a newline after the string

Returns: void

as-wasi

Globals / Date

Class: Date

Hierarchy

  • Date

Index

Methods

Methods

now

Staticnow(): f64

Defined in assembly/as-wasi.ts:895

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

Returns: f64

as-wasi

Globals / Descriptor

Class: Descriptor

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

Hierarchy

  • Descriptor

Index

Constructors

Accessors

Methods

Constructors

constructor

+ new Descriptor(rawfd: fd): Descriptor

Defined in assembly/as-wasi.ts:109

Build a new descriptor from a raw WASI file descriptor

Parameters:
Name Type Description
rawfd fd a raw file descriptor

Returns: Descriptor

Accessors

rawfd

• get rawfd(): fd

Defined in assembly/as-wasi.ts:119

Returns: fd


Invalid

Staticget Invalid(): Descriptor

Defined in assembly/as-wasi.ts:94

An invalid file descriptor, that can represent an error

Returns: Descriptor


Stderr

Staticget Stderr(): Descriptor

Defined in assembly/as-wasi.ts:109

The standard error

Returns: Descriptor


Stdin

Staticget Stdin(): Descriptor

Defined in assembly/as-wasi.ts:99

The standard input

Returns: Descriptor


Stdout

Staticget Stdout(): Descriptor

Defined in assembly/as-wasi.ts:104

The standard output

Returns: Descriptor

Methods

advise

advise(offset: u64, len: u64, advice: advice): bool

Defined in assembly/as-wasi.ts:130

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

offset offset

len length

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

Parameters:
Name Type
offset u64
len u64
advice advice

Returns: bool

true on success, false on error


allocate

allocate(offset: u64, len: u64): bool

Defined in assembly/as-wasi.ts:140

Preallocate data

Parameters:
Name Type Description
offset u64 where to start preallocating data in the file
len u64 bytes to preallocate

Returns: bool

true on success, false on error


close

close(): void

Defined in assembly/as-wasi.ts:283

Close a file descriptor

Returns: void


dirName

dirName(): string

Defined in assembly/as-wasi.ts:261

Return the directory associated to that descriptor

Returns: string


fatime

fatime(ts: f64): bool

Defined in assembly/as-wasi.ts:207

Update the access time

ts timestamp in seconds

Parameters:
Name Type
ts f64

Returns: bool

true on success, false on error


fdatasync

fdatasync(): bool

Defined in assembly/as-wasi.ts:148

Wait for the data to be written

Returns: bool

true on success, false on error


fileType

fileType(): filetype

Defined in assembly/as-wasi.ts:163

Return the file type

Returns: filetype


fmtime

fmtime(ts: f64): bool

Defined in assembly/as-wasi.ts:219

Update the modification time

ts timestamp in seconds

Parameters:
Name Type
ts f64

Returns: bool

true on success, false on error


fsync

fsync(): bool

Defined in assembly/as-wasi.ts:156

Wait for the data and metadata to be written

Returns: bool

true on success, false on error


ftruncate

ftruncate(size?: u64): bool

Defined in assembly/as-wasi.ts:198

Change the size of a file

Parameters:
Name Type Default value Description
size u64 0 new size

Returns: bool

true on success, false on error


futimes

futimes(atime: f64, mtime: f64): bool

Defined in assembly/as-wasi.ts:232

Update both the access and the modification times

atime timestamp in seconds

mtime timestamp in seconds

Parameters:
Name Type
atime f64
mtime f64

Returns: bool

true on success, false on error


read

read(data?: u8[], chunk_size?: usize): u8[] | null

Defined in assembly/as-wasi.ts:348

Read data from a file descriptor

Parameters:
Name Type Default value Description
data u8[] [] existing array to push data to
chunk_size usize 4096 chunk size (default: 4096)

Returns: u8[] | null


readAll

readAll(data?: u8[], chunk_size?: usize): u8[] | null

Defined in assembly/as-wasi.ts:378

Read from a file descriptor until the end of the stream

Parameters:
Name Type Default value Description
data u8[] [] existing array to push data to
chunk_size usize 4096 chunk size (default: 4096)

Returns: u8[] | null


readLine

readLine(): string | null

Defined in assembly/as-wasi.ts:411

Read a line of text from a file descriptor

Returns: string | null


readString

readString(chunk_size?: usize): string | null

Defined in assembly/as-wasi.ts:450

Read an UTF8 string from a file descriptor, convert it to a native string

Parameters:
Name Type Default value Description
chunk_size usize 4096 chunk size (default: 4096)

Returns: string | null


seek

seek(off: u64, w: whence): bool

Defined in assembly/as-wasi.ts:464

Seek into a stream

off offset

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

Parameters:
Name Type
off u64
w whence

Returns: bool


setFlags

setFlags(flags: fdflags): bool

Defined in assembly/as-wasi.ts:177

Set WASI flags for that descriptor

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

Parameters:
Name Type
flags fdflags

Returns: bool

true on success, false on error


stat

stat(): FileStat

Defined in assembly/as-wasi.ts:185

Retrieve information about a descriptor

Returns: FileStat

a FileStat object`


tell

tell(): u64

Defined in assembly/as-wasi.ts:475

Return the current offset in the stream

Returns: u64

offset


touch

touch(): bool

Defined in assembly/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: u8[]): void

Defined in assembly/as-wasi.ts:291

Write data to a file descriptor

Parameters:
Name Type Description
data u8[] data

Returns: void


writeString

writeString(s: string, newline?: bool): void

Defined in assembly/as-wasi.ts:309

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

Parameters:
Name Type Default value Description
s string - string
newline bool false true to add a newline after the string

Returns: void


writeStringLn

writeStringLn(s: string): void

Defined in assembly/as-wasi.ts:328

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

Parameters:
Name Type Description
s string string

Returns: void

as-wasi

Globals / Environ

Class: Environ

Hierarchy

  • Environ

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new Environ(): Environ

Defined in assembly/as-wasi.ts:930

Returns: Environ

Properties

env

env: Array<EnvironEntry>

Defined in assembly/as-wasi.ts:930

Accessors

all

Staticget all(): Array<EnvironEntry>

Defined in assembly/as-wasi.ts:960

Return all environment variables

Returns: Array<EnvironEntry>

Methods

all

all(): Array<EnvironEntry>

Defined in assembly/as-wasi.ts:968

Return all environment variables

Returns: Array<EnvironEntry>


get

get(key: string): string | null

Defined in assembly/as-wasi.ts:976

Return the value for an environment variable

Parameters:
Name Type Description
key string environment variable name

Returns: string | null

as-wasi

Globals / EnvironEntry

Class: EnvironEntry

Hierarchy

  • EnvironEntry

Index

Constructors

Properties

Constructors

constructor

+ new EnvironEntry(key: string, value: string): EnvironEntry

Defined in assembly/as-wasi.ts:925

Parameters:
Name Type
key string
value string

Returns: EnvironEntry

Properties

key

Readonly key: string

Defined in assembly/as-wasi.ts:926


value

Readonly value: string

Defined in assembly/as-wasi.ts:926

as-wasi

Globals / FileStat

Class: FileStat

Portable information about a file

Hierarchy

  • FileStat

Index

Constructors

Properties

Constructors

constructor

+ new FileStat(st_buf: usize): FileStat

Defined in assembly/as-wasi.ts:75

Parameters:
Name Type
st_buf usize

Returns: FileStat

Properties

access_time

access_time: f64

Defined in assembly/as-wasi.ts:73


creation_time

creation_time: f64

Defined in assembly/as-wasi.ts:75


file_size

file_size: filesize

Defined in assembly/as-wasi.ts:72


file_type

file_type: filetype

Defined in assembly/as-wasi.ts:71


modification_time

modification_time: f64

Defined in assembly/as-wasi.ts:74

as-wasi

Globals / FileSystem

Class: FileSystem

A class to access a filesystem

Hierarchy

  • FileSystem

Index

Methods

Methods

dirfdForPath

Static ProtecteddirfdForPath(path: string): fd

Defined in assembly/as-wasi.ts:815

Parameters:
Name Type
path string

Returns: fd


exists

Staticexists(path: string): bool

Defined in assembly/as-wasi.ts:579

Check if a file exists at a given path

path path

Parameters:
Name Type
path string

Returns: bool

true on success, false on failure


link

Staticlink(old_path: string, new_path: string): bool

Defined in assembly/as-wasi.ts:602

Create a hard link

old_path old path

new_path new path

Parameters:
Name Type
old_path string
new_path string

Returns: bool

true on success, false on failure


lstat

Staticlstat(path: string): FileStat

Defined in assembly/as-wasi.ts:718

Retrieve information about a file or a symbolic link

path path

Parameters:
Name Type
path string

Returns: FileStat

a FileStat object


mkdir

Staticmkdir(path: string): bool

Defined in assembly/as-wasi.ts:562

Create a new directory

path path

Parameters:
Name Type
path string

Returns: bool

true on success, false on failure


open

Staticopen(path: string, flags?: string): Descriptor | null

Defined in assembly/as-wasi.ts:495

Open a path

path path

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

Parameters:
Name Type Default value
path string -
flags string "r"

Returns: Descriptor | null

a descriptor


readdir

Staticreaddir(path: string): Array<string> | null

Defined in assembly/as-wasi.ts:772

Get the content of a directory

Parameters:
Name Type Description
path string the directory path

Returns: Array<string> | null

An array of file names


rename

Staticrename(old_path: string, new_path: string): bool

Defined in assembly/as-wasi.ts:744

Rename a file

old_path old path

new_path new path

Parameters:
Name Type
old_path string
new_path string

Returns: bool

true on success, false on failure


rmdir

Staticrmdir(path: string): bool

Defined in assembly/as-wasi.ts:676

Remove a directory

path path

Parameters:
Name Type
path string

Returns: bool

true on success, false on failure


stat

Staticstat(path: string): FileStat

Defined in assembly/as-wasi.ts:693

Retrieve information about a file

path path

Parameters:
Name Type
path string

Returns: FileStat

a FileStat object


symlink

Staticsymlink(old_path: string, new_path: string): bool

Defined in assembly/as-wasi.ts:633

Create a symbolic link

old_path old path

new_path new path

Parameters:
Name Type
old_path string
new_path string

Returns: bool

true on success, false on failure


unlink

Staticunlink(path: string): bool

Defined in assembly/as-wasi.ts:659

Unlink a file

path path

Parameters:
Name Type
path string

Returns: bool

true on success, false on failure

as-wasi

Globals / Performance

Class: Performance

Hierarchy

  • Performance

Index

Methods

Methods

now

Staticnow(): f64

Defined in assembly/as-wasi.ts:905

Returns: f64

as-wasi

Globals / Process

Class: Process

Hierarchy

  • Process

Index

Methods

Methods

exit

Staticexit(status: u32): void

Defined in assembly/as-wasi.ts:920

Cleanly terminate the current process

Parameters:
Name Type Description
status u32 exit code

Returns: void

as-wasi

Globals / Random

Class: Random

Hierarchy

  • Random

Index

Methods

Methods

randomBytes

StaticrandomBytes(len: usize): Uint8Array

Defined in assembly/as-wasi.ts:884

Return an array of random bytes

Parameters:
Name Type Description
len usize length

Returns: Uint8Array


randomFill

StaticrandomFill(buffer: ArrayBuffer): void

Defined in assembly/as-wasi.ts:867

Fill a buffer with random data

Parameters:
Name Type Description
buffer ArrayBuffer An array buffer

Returns: void

as-wasi

Globals / StringUtils

Class: StringUtils

Hierarchy

  • StringUtils

Index

Methods

Methods

fromCString

StaticfromCString(cstring: usize): string

Defined in assembly/as-wasi.ts:1091

Returns a native string from a zero-terminated C string

Parameters:
Name Type
cstring usize

Returns: string

native string

as-wasi

Globals / Time

Class: Time

Hierarchy

  • Time

Index

Properties

Methods

Properties

MILLISECOND

Static MILLISECOND: i32 = Time.NANOSECOND * 1000000

Defined in assembly/as-wasi.ts:1046


NANOSECOND

Static NANOSECOND: i32 = 1

Defined in assembly/as-wasi.ts:1045


SECOND

Static SECOND: i32 = Time.MILLISECOND * 1000

Defined in assembly/as-wasi.ts:1047

Methods

sleep

Staticsleep(nanoseconds: i32): void

Defined in assembly/as-wasi.ts:1051

Parameters:
Name Type
nanoseconds i32

Returns: void

as-wasi

Globals / WASIError

Class: WASIError

A WASI error

Hierarchy

  • Error

    WASIError

Index

Constructors

Properties

Methods

Constructors

constructor

+ new WASIError(message?: string): WASIError

Overrides void

Defined in assembly/as-wasi.ts:60

Parameters:
Name Type Default value
message string ""

Returns: WASIError

Properties

message

message: string

Inherited from WASIError.message

Defined in node_modules/assemblyscript/std/assembly/index.d.ts:1718

Message provided on construction.


name

name: string

Inherited from WASIError.name

Defined in node_modules/assemblyscript/std/assembly/index.d.ts:1715

Error name.


stack

Optional stack: undefined | string

Inherited from WASIError.stack

Defined in node_modules/assemblyscript/std/assembly/index.d.ts:1721

Stack trace.

Methods

toString

toString(): string

Inherited from WASIError.toString

Defined in node_modules/assemblyscript/std/assembly/index.d.ts:1727

Method returns a string representing the specified Error class.

Returns: string