Skip to content

Standard Constants / Functions

Refers to constants/functions that are defined in Aiscript from the beginning and can be used anywhere.
They are also called std constants/functions without standard.

Syntax

#Core:v

Represents a standard constant named Core:v.

@Core:type(v: value): str

Represents a standard function named Core:type.
It takes one argument of type value (i.e., any type) named v and returns a value of type str (string type).

List

std

Displays a string on the screen.

@readline(message: str): str

Accepts string input.

:: Core

#Core:v

Type: str
Version of AiScript runtime that's currently running.

@Core:type(v: value): str

Get the type name of the value.

@Core:to_str(v: value): str

Obtains a string representing a value.

@Core:sleep(time: num): void

Wait for the specified time (milliseconds).

@Core:abort(message: str): never

Aborts the execution.

:: Util

@Util:uuid(): str

Generates new UUID.

:: Json

@Json:stringify(v: value): str

Generate JSON string.

@Json:parse(json: str): value

Parse JSON into object. Returns an error type value (name='not_json') if the argument is not parsable as JSON.

@Json:parsable(str: str): bool

Determines if a string can be parsed as JSON. Exists for historical reasons.

:: Date

@Date:now(): num

Returns current date.

@Date:year(date?: num): num

Get the year of the time.
If date is passed, the year corresponding to date,
If not passed, the year of the current time is returned.

@Date:month(date?: num): num

Get the month of the time.
If date is passed, the month corresponding to date,
If not passed, the month of the current time is returned.

@Date:day(date?: num): num

Get the day of the current time.
If date is passed, the day corresponding to date,
If not passed, the day of the current time is returned.

@Date:hour(date?: num): num

Get the hour of the current time.
If date is passed, the time corresponding to date,
If not passed, the current time is returned.

@Date:minute(date?: num): num

Get the minutes of the current time.
If date is passed, the minute corresponding to date,
If not passed, the minute of the current time is returned.

@Date:second(date?: num): num

Get the seconds of the current time.
If date is passed, the second corresponding to date,
If not passed, the second of the current time is returned.

@Date:millisecond(date?: num): num

Get the milliseconds of the current time.
If date is passed, the millisecond corresponding to date,
If not passed, the millisecond of the current time is returned.

@Date:parse(date: str): num

Generates a numeric value representing a date/time from a string that can be interpreted as a date.
Interpretation depends on JavaScript's Date constructor.
If the argument is not interpretable as a date, it returns a value of type error (name='not_date').

@Date:to_iso_str(date?: num, time_offset?: num): str

Returns a string with date in extended notation ISO format.
If date is not passed, the current time is used.
time_offset is the time difference (in minutes) from UTC.
If time_offset is not passed, the local one is used.

:: Math

Click here

:: Num

@Num:from_hex(hex: str): num

Return number from a hexadecimal string.

:: Str

#Str:lf

Type: str Line feed (LF).

@Str:lt(a: str, b: str): num

Returns -1 if a < b, 0 if a == b, or 1 if a > b. Can be used as a comparison function for arr.sort.

@Str:gt(a: str, b: str): num

Returns -1 if a > b, 0 if a == b, or 1 if a < b. Can be used as a comparison function for arr.sort.

@Str:from_codepoint(codepoint: num): str

Generates characters from Unicode codepoints.
codepoint must be greater than or equal to 0 and less than or equal to 10FFFFF16.

@Str:from_unicode_codepoints(codePoints: arr<num>): str

Generates characters from an array of numbers representing a sequence of Unicode code points.
Each element of _codePoints must be greater than or equal to 0 and less than or equal to 10FFFFFF16.

@Str:from_utf8_bytes(bytes: arr<num>): str

Generates characters from an array of numbers representing a UTF-8 byte sequence.
Each element of bytes must be greater than or equal to 0 and less than or equal to 255.

:: Uri

@Uri:encode_full(uri: str): str

Returns a string with uri encoded as a URI. The following characters are not encoded:
A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; , / ? : @ & = + $ #

@Uri:encode_component(text: str): str

Returns a string with text encoded as a URI component. The following characters are not encoded:
A-Z a-z 0-9 - _ . ! ~ * ' ( )

@Uri:decode_full(encoded_uri: str): str

Returns a string that decodes encoded_uri as an encoded URI.
Escape sequences corresponding to the following characters are not decoded:
; , / ? : @ & = + $ #

@Uri:decode_component(encoded_text: str): str

Returns a string that decodes encoded_text as an encoded URI component.

:: Arr

@Arr:create(length: num, initial?: value): arr

Creates an array of length length.
The array will be filled with initial if given, otherwise with null.

:: Obj

@Obj:keys(v: obj): arr

@Obj:vals(v: obj): arr

@Obj:kvs(v: obj): arr

Returns an array of object keys, values, and key/value pairs.

@Obj:get(v: obj, key: str): value

@Obj:set(v: obj, key: str, val: value): null

@Obj:has(v: obj, key: str): bool

@Obj:copy(v: obj): obj

Generates the copy of the object.

@Obj:merge(o1: obj, o2: obj): obj

Returns a merged version of the two objects.

:: Error

@Error:create(name: str, info?: value): error

Create error type value.

:: Async

@Async:interval(interval: num, callback: fn, immediate?: bool): fn

Calls the callback function at the specified period.
Returns a stop function.

@Async:timeout(delay: num, callback: fn):

Calls the callback function after the specified time has elapsed.
Returns a stop function as the return value.