Full API signatures

The complete callable reference for core builtins, standard-library registrations, and the standalone runner. Each entry shows arguments, defaults, result, effects, and availability. Host applications may register additional APIs.

Reference overview · Machine-readable catalog

Reading signatures

These signatures use documentation notation, rather than declaration syntax: name(argument: type = default) -> result. T, K, V, and R stand for element, key, value, and callback-result types. number means int or float, text means string or utf8_string, and Self means the receiver's text type. An or joins accepted types; it does not introduce a script union type. Optional callback indices appear in brackets. Signal type names describe a host-bound family.

Effects: observe reads; copy returns new values; mutate changes the receiver; advance changes a cursor or coroutine; callback may execute script; filesystem, network, output, and audio affect the host environment. Receiver text mutators return text for chaining. Core APIs exist on every engine; stdlib APIs require their registration; runner additions are provided by jaiscript.exe.

Sorting arrays

values.sort() sorts the receiver in place using the language's <. A class's explicit operator< takes precedence; when absent, operator<=> supplies the comparison with zero. values.sort(predicate) uses a boolean predicate: true means the left item comes before the right. Equal items may be reordered. The receiver method returns no value; array::sort(values[, predicate]) returns a sorted copy. Default numeric sorting groups all NaNs last and treats signed zeros as equivalent; an explicit predicate supplies its own ordering.

jaiscript
array<int> values = [3, 1, 2];
values.sort();
print(to_json(values));
values.sort((a, b) => a > b);
print(to_json(values));
output
[1,2,3]
[3,2,1]

Typed integer, floating, boolean, byte, char, and string buffers use native sorting without per-element boxing or script comparisons when ordinary built-in ordering applies. Generic values and user comparisons use a temporary snapshot, committing the ordering after comparisons succeed. Comparison errors propagate; callback side effects are not rolled back. The predicate and element order should be a strict weak ordering that does not mutate the compared values or ordering rule; a predicate that breaks this still leaves a permutation of the elements, in an unspecified order. This is a C++-style boolean comparator, rather than JavaScript/C#'s signed comparison result.

Builtin booleans, vectors, arrays and maps have an order. Records use their explicit < or <=> operator; otherwise choose a predicate. For example, flags.sort((a, b) => !a && b) orders false before true; points.sort((a, b) => a.x < b.x) orders by x. Sorting is O(n log n); user callback cost is additional, and callback paths use O(n) temporary storage.

Browse callable signatures

Download

Download.cancel() -> void

Standalone jaiscript.exe · mutate

Download.done() -> bool

Standalone jaiscript.exe · observe

Download.error() -> string

Standalone jaiscript.exe · observe

Completed failure description; empty before completion.

Download.fraction() -> float

Standalone jaiscript.exe · observe

Progress ratio when total is known.

Download.pump() -> bool

Standalone jaiscript.exe · advance, callback

Polls completion; returns done state.

Download.received() -> int

Standalone jaiscript.exe · observe

Bytes received so far.

Download.start(url: string, destination: string) -> bool

Standalone jaiscript.exe · network, filesystem

Download.success() -> bool

Standalone jaiscript.exe · observe

True only after successful completion.

Download.total() -> int

Standalone jaiscript.exe · observe

Expected total bytes when known.

NetChannel

NetChannel.close() -> void

Standalone jaiscript.exe · network

NetChannel.connect(host: string, port: int) -> bool

Standalone jaiscript.exe · network

Asynchronous: true while the connection is being made; pump() then fires on_connect(), or on_disconnect("connect refused"). False when the attempt fails at once.

NetChannel.connected() -> bool

Standalone jaiscript.exe · observe

NetChannel.listen(port: int) -> bool

Standalone jaiscript.exe · network

NetChannel.pump() -> int

Standalone jaiscript.exe · network, callback

Pumps networking and returns fired event count.

NetChannel.send(bytes: string) -> bool

Standalone jaiscript.exe · network

Length-prefixed packet, not raw stream writes.

NetChannel.status() -> string

Standalone jaiscript.exe · observe

NetServer

NetServer.broadcast(bytes: string) -> int

Standalone jaiscript.exe · network

Returns reached-client count.

NetServer.client_count() -> int

Standalone jaiscript.exe · observe

NetServer.close() -> void

Standalone jaiscript.exe · network

NetServer.kick(client: int) -> void

Standalone jaiscript.exe · network

NetServer.listen(port: int) -> bool

Standalone jaiscript.exe · network

NetServer.listening() -> bool

Standalone jaiscript.exe · observe

NetServer.pump() -> int

Standalone jaiscript.exe · network, callback

Pumps networking and returns fired event count.

NetServer.send(client: int, bytes: string) -> bool

Standalone jaiscript.exe · network

Signal

Signal.connect(id: string, callback: function or string) -> void

When the host binds this signal type · mutate

Callback or script text; named connection remains owned by the signal.

Signal.connected(id: string) -> bool

When the host binds this signal type · observe

Signal.disconnect(id: string) -> void

When the host binds this signal type · mutate

SignalEmitter

SignalEmitter.connect(id: string, callback: function or string) -> void

When the host binds this signal type · mutate

Callback or script text; named connection remains owned by the signal.

SignalEmitter.connected(id: string) -> bool

When the host binds this signal type · observe

SignalEmitter.disconnect(id: string) -> void

When the host binds this signal type · mutate

SignalEmitter.emit(payload: bound_signal_arguments...) -> void

When the host binds this signal type · callback

Argument types follow the host-bound signal signature; emit discards receiver return values.

Sound

Sound.format() -> string

Standalone jaiscript.exe · observe

"wav", "midi" or "mp3".

Sound.play(loop: bool = false) -> bool

Standalone jaiscript.exe · audio

Starts from the beginning (a playing Sound restarts), looping when loop is true, and returns at once; false once the file proved unplayable.

Sound.playing() -> bool

Standalone jaiscript.exe · observe

True from play() until stop(), stop_sounds() or the end of a sound played once.

Sound.stop() -> void

Standalone jaiscript.exe · audio

Sound.volume(level: float) -> void

Standalone jaiscript.exe · audio

Level 0..1, clamped; 1 until set.

array

array::append(values: array<T>, other: array<T> or array<var>) -> array<T>

Every engine · copy

Returns a new array, preserving the first input constraints; inputs do not mutate. Same-kind typed buffers avoid boxing. Handles retain identity.

array::concat(values: array<T>, other: array<T> or array<var>) -> array<T>

Every engine · copy

Copying alias of array::append; inputs do not mutate.

array::filter(values: array<T>, predicate: function(T[, int]) -> bool) -> array<T>

Every engine · copy; callback

Preserves element constraints and copies selected values only. Reference callback parameters still target live input elements.

jaiscript
array<int> xs = [1, 2, 3, 4];
print(to_json(array::filter(xs, x => x > 2)), " ", to_json(xs));
output
[3,4] [1,2,3,4]

array::map(values: array<T>, callback: function(T[, int]) -> R) -> array<R>

Every engine · copy; callback

A declared callback return type R gives array<R>; an undeclared return gives an array of the results' type when they all share one, and array<var> when they differ. Reference callbacks can mutate input elements.

jaiscript
array<int> xs = [1, 2, 3];
auto labels = array::map(xs, [](int x) -> string { return "#" + to_string(x); });
print(to_json(labels), " ", to_json(xs));
output
["#1","#2","#3"] [1,2,3]

array::reverse(values: array<T>) -> array<T>

Every engine · copy

Returns a reversed value copy with input constraints; handles retain identity.

array::slice(values: array<T>, start: int = 0, end: int = size()) -> array<T>

Every engine · copy

Copies only the selected range with the input element constraints; handles retain identity.

array::sort(values: array<T>, predicate: function(T, T) -> bool = omitted) -> array<T>

Every engine · copy; callback

Returns a sorted value copy with input constraints; handles retain identity. Default numeric sorting treats signed zeros as equivalent and groups all NaNs last; an explicit predicate supplies its own order.

jaiscript
array<int> xs = [3, 1, 2];
print(to_json(array::sort(xs)), " ", to_json(xs));
output
[1,2,3] [3,1,2]

array<T>

array<T>.append(other: array<var> or array<T>) -> array<T>

Every engine · mutate

Appends the other array in place, retaining input element constraints. Same-kind primitive/string/vector buffers avoid per-element boxing. Added values copy; handles share. Returns the receiver; alias of concat.

jaiscript
array<int> xs = [1, 2];
xs.append([3, 4]);        // changes xs and returns it
print(to_json(xs));
output
[1,2,3,4]

array<T>.back() -> T

Every engine · observe

Empty array raises. An object, array or map element comes back as a reference to it, like a C++ reference return: binding the result to var, auto or T copies the element, while var&, T& and a member call on the result reach the stored element.

jaiscript
array<int> xs = [4, 5, 6];
print(xs.front(), " ", xs.back());
output
4 6

array<T>.clear() -> void

Every engine · mutate

jaiscript
array<int> xs = [4, 5, 6];
xs.clear();
print(xs.size());
output
0

array<T>.concat(other: array<var> or array<T>) -> array<T>

Every engine · mutate

Appends the other array in place, retaining input element constraints. Same-kind primitive/string/vector buffers avoid per-element boxing. Added values copy; handles share. Returns the receiver; alias of append.

jaiscript
array<int> a = [1];
print(to_json(array::concat(a, [2, 3])), " ", to_json(a));
output
[1,2,3] [1]

array<T>.contains(value: var) -> bool

Every engine · observe

Alias of has.

jaiscript
array<int> xs = [1, 2, 3];
print(xs.contains(2), " ", xs.contains(9));
output
true false

array<T>.empty() -> bool

Every engine · observe

array<T>.erase(index: int) -> bool

Every engine · mutate

Alias of remove(index); false without change when out of range.

jaiscript
array<int> xs = [10, 20, 30];
print(xs.erase(1), " ", to_json(xs), " ", xs.erase(9));
output
true [10,30] false

array<T>.every(predicate: function(T[, int]) -> bool) -> bool

Every engine · callback

True if all match; empty array is true.

jaiscript
array<int> xs = [2, 4, 7];
print(xs.every(x => x % 2 == 0));
output
false

array<T>.filter(predicate: function(T[, int]) -> bool) -> array<T>

Every engine · mutate; callback

Filters in place, retaining element constraints and selected values without cloning. Reference callback parameters target live elements. Returns the receiver; array::filter returns a copy.

jaiscript
array<int> hp = [5, 0, 12, 0];
array<int> alive = array::filter(hp, h => h > 0);   // a copy
hp.filter(h => h > 10);                            // in place
print(to_json(alive), " ", to_json(hp));
output
[5,12] [12]

array<T>.find(predicate: function(T[, int]) -> bool) -> T or null

Every engine · copy, callback

First match, copied; null if absent. Value results copy, while shared_ptr/weak_ptr handles retain identity.

jaiscript
array<string> names = ["ann", "bob", "cy"];
print(names.find(n => n.size() == 3), " ", names.find(n => n == "zed"));
output
ann null

array<T>.find_index(predicate: function(T[, int]) -> bool) -> int

Every engine · callback

First match index; -1 if absent.

jaiscript
array<string> names = ["ann", "bob", "cy"];
print(names.find_index(n => n == "cy"), " ", names.find_index(n => n == "zed"));
output
2 -1

array<T>.first() -> T

Every engine · observe

Alias of front. An object, array or map element comes back as a reference to it, like a C++ reference return: binding the result to var, auto or T copies the element, while var&, T& and a member call on the result reach the stored element.

array<T>.for_each(callback: function(T[, int]) -> var) -> void

Every engine · callback

T& callback parameters bind live elements.

jaiscript
array<string> xs = ["a", "b"];
xs.for_each((s, i) => print(i, ": ", s));
output
0: a
1: b

array<T>.front() -> T

Every engine · observe

Empty array raises. An object, array or map element comes back as a reference to it, like a C++ reference return: binding the result to var, auto or T copies the element, while var&, T& and a member call on the result reach the stored element.

array<T>.has(value: var) -> bool

Every engine · observe

Language equality.

array<T>.index_of(value: var) -> int

Every engine · observe

Language equality; -1 if absent.

jaiscript
array<string> xs = ["a", "b"];
print(xs.index_of("b"), " ", xs.index_of("z"));
output
1 -1

array<T>.insert(index: int, value: T) -> void

Every engine · mutate

Index from 0 through size inclusive.

jaiscript
array<string> xs = ["a", "c"];
xs.insert(1, "b");
print(to_json(xs));
output
["a","b","c"]

array<T>.join(separator: string = "") -> string

Every engine · observe

Stringifies values between separators.

jaiscript
array<int> xs = [1, 2, 3];
print(xs.join(", "));
output
1, 2, 3

array<T>.last() -> T

Every engine · observe

Alias of back. An object, array or map element comes back as a reference to it, like a C++ reference return: binding the result to var, auto or T copies the element, while var&, T& and a member call on the result reach the stored element.

array<T>.length() -> int

Every engine · observe

Alias of size.

array<T>.map(callback: function(T[, int]) -> var) -> array<T>

Every engine · mutate; callback

Maps in place, retaining input element constraints; results convert through the usual typed-element rules. Reference callback parameters target live elements. Returns the receiver; array::map can change result type.

jaiscript
array<int> xs = [1, 2, 3];
xs.map(x => x * 10);       // in place, keeps array<int>
print(to_json(xs));
output
[10,20,30]

array<T>.pop() -> T

Every engine · mutate

Removes the last element; empty array raises.

jaiscript
array<int> xs = [1, 2, 3];
print(xs.pop(), " ", to_json(xs));
output
3 [1,2]

array<T>.push(value: T) -> void

Every engine · mutate

Converts through the element boundary.

jaiscript
array<int> xs = [1, 2];
xs.push(3);
print(to_json(xs));
output
[1,2,3]

array<T>.reduce(callback: function(var, T[, int]) -> R, initial: var = first_element) -> R

Every engine · callback

Without initial, empty array raises; callback receives accumulator and element, optionally index. The accumulator starts as a copy of the initial value (or of the first element), as std::accumulate takes its init by value.

jaiscript
array<int> xs = [1, 2, 3, 4];
print(xs.reduce((sum, x) => sum + x), " ", xs.reduce((sum, x) => sum + x, 100));
output
10 110

array<T>.remove(index: int) -> bool

Every engine · mutate

Removes by index; false without change when out of range.

array<T>.remove_if(predicate: function(T) -> bool) -> int

Every engine · mutate, callback

Removes matches; returns removed count.

jaiscript
array<int> xs = [1, 2, 3, 4, 5];
print(xs.remove_if(x => x % 2 == 0), " ", to_json(xs));
output
2 [1,3,5]

array<T>.reverse() -> void

Every engine · mutate

jaiscript
array<int> xs = [1, 2, 3];
xs.reverse();
print(to_json(xs), " ", to_json(array::reverse(xs)));
output
[3,2,1] [1,2,3]

array<T>.size() -> int

Every engine · observe

jaiscript
array<int> xs = [4, 5, 6];
print(xs.size(), " ", xs.empty());
output
3 false

array<T>.slice(start: int = 0, end: int = size()) -> array<T>

Every engine · mutate

Retains the selected range in place, end exclusive; defaults 0 and size, negative indices relative to end, bounds clamp. Retained elements move without cloning. Returns the receiver; array::slice returns a copy.

jaiscript
array<int> xs = [0, 1, 2, 3, 4];
array<int> part = array::slice(xs, 1, 3);   // a copy
xs.slice(3);                                 // xs itself becomes [3, 4]
print(to_json(part), " ", to_json(xs));
output
[1,2] [3,4]

array<T>.some(predicate: function(T[, int]) -> bool) -> bool

Every engine · callback

True if any match; short circuits.

jaiscript
array<int> xs = [1, 3, 4];
print(xs.some(x => x % 2 == 0), " ", xs.every(x => x > 0));
output
true true

array<T>.sort(predicate: function(T, T) -> bool = omitted) -> void

Every engine · mutate, callback

Mutates in place; optional bool predicate, otherwise language <, with <=> fallback for class and builtin orders. Errors stop sorting without committing the order; callback side effects remain. Strict weak ordering required. Typed primitive buffers avoid boxing. Default numeric sorting treats signed zeros as equivalent and groups all NaNs last; an explicit predicate supplies its own order.

jaiscript
array<int> xs = [3, 1, 2];
xs.sort();
print(to_json(xs));
xs.sort((a, b) => a > b);
print(to_json(xs));
output
[1,2,3]
[3,2,1]

binary

binary::bytes(count: int) -> binary::width

Every engine · construct

Fixed byte count for a layout byte-buffer field.

binary::layout(field_and_width_pairs: string, binary::width, ...) -> binary::layout

Every engine · construct

Alternating field name and width values; at least one pair.

binary::reader(bytes: string) -> binary::reader

Every engine · construct

binary::text(count: int) -> binary::width

Every engine · construct

Fixed byte count for a layout text field.

binary::writer() -> binary::writer

Every engine · construct

binary::layout

binary::layout.count() -> int

Every engine · observe

binary::layout.size() -> int

Every engine · observe

binary::reader

binary::reader.at_end() -> bool

Every engine · observe

binary::reader.big_endian() -> binary::reader

Every engine · configure

binary::reader.bytes(count: int) -> array<uint8>

Every engine · advance

binary::reader.float32() -> float

Every engine · advance

binary::reader.float64() -> float

Every engine · advance

binary::reader.int16() -> int

Every engine · advance

binary::reader.int32() -> int

Every engine · advance

binary::reader.int64() -> int

Every engine · advance

binary::reader.int8() -> int

Every engine · advance

binary::reader.little_endian() -> binary::reader

Every engine · configure

binary::reader.pos() -> int

Every engine · observe

binary::reader.read(class: class, layout: binary::layout) -> class_instance

Every engine · advance, construct

binary::reader.remaining() -> int

Every engine · observe

binary::reader.seek(position: int) -> binary::reader

Every engine · mutate

binary::reader.size() -> int

Every engine · observe

binary::reader.skip(count: int) -> binary::reader

Every engine · mutate

binary::reader.text() -> string

Every engine · advance

Reads a NUL-terminated text field.

binary::reader.text(count: int) -> string

Every engine · advance

binary::reader.uint16() -> int

Every engine · advance

jaiscript
binary::writer w;
w.uint16(513).int32(-2);
auto r = w.to_string().reader();
print(r.uint16(), " ", r.int32(), " ", r.at_end());
output
513 -2 true

binary::reader.uint32() -> int

Every engine · advance

binary::reader.uint8() -> int

Every engine · advance

binary::reader.unpack(layout: binary::layout) -> map<string,var>

Every engine · advance

jaiscript
auto entry = binary::layout("id", binary::uint16, "hp", binary::int32);
binary::writer w;
w.pack(entry, {"id": 7, "hp": 120});
auto row = w.to_string().reader().unpack(entry);
print(row["id"], " ", row["hp"]);
output
7 120

binary::width

binary::width.name() -> string

Every engine · observe

binary::width.size() -> int

Every engine · observe

binary::writer

binary::writer.big_endian() -> binary::writer

Every engine · configure

binary::writer.bytes(value: array<uint8> or string) -> binary::writer

Every engine · mutate

binary::writer.float32(value: number) -> binary::writer

Every engine · mutate

binary::writer.float64(value: number) -> binary::writer

Every engine · mutate

binary::writer.int16(value: int) -> binary::writer

Every engine · mutate

binary::writer.int32(value: int) -> binary::writer

Every engine · mutate

binary::writer.int64(value: int) -> binary::writer

Every engine · mutate

binary::writer.int8(value: int) -> binary::writer

Every engine · mutate

binary::writer.little_endian() -> binary::writer

Every engine · configure

binary::writer.pack(layout: binary::layout, values: map<string,var>) -> binary::writer

Every engine · mutate

binary::writer.pos() -> int

Every engine · observe

binary::writer.seek(position: int) -> binary::writer

Every engine · mutate

binary::writer.size() -> int

Every engine · observe

binary::writer.text(value: string, count: int = encoded_length) -> binary::writer

Every engine · mutate

jaiscript
binary::writer w;
w.text("ab", 4).text("c");
print(w.size(), " ", to_json(w.to_string().to_bytes()));
output
6 [97,98,0,0,99,0]

binary::writer.to_string() -> string

Every engine · copy

Written raw bytes.

binary::writer.uint16(value: int) -> binary::writer

Every engine · mutate

binary::writer.uint32(value: int) -> binary::writer

Every engine · mutate

binary::writer.uint8(value: int) -> binary::writer

Every engine · mutate

coroutine

coroutine.advance(v: var&) -> bool

Every engine · advance, callback

Resumes once: true when the body yielded, with the yielded value stored into v (converted to v's declared type); false when the body ran to its end, or had already ended, leaving v as it was; the return value is then result(). v binds as a T& parameter does: a temporary raises Cannot pass non-lvalue to reference parameter before anything runs.

coroutine.done() -> bool

Every engine · observe

Whether the body finished (returned or failed); it never starts or advances the coroutine.

coroutine.next(count: int = 1) -> var

Every engine · advance, callback

Runs to the next yield and returns its value; next(count) advances count yields and returns the last one's value. The call that finishes the body returns the return value; a step on a completed coroutine raises Cannot resume a completed coroutine. count is an int of at least 1. Nothing in the body runs before the first next().

coroutine.result() -> var

Every engine · observe

A copy of the value the body returned, once done() is true, however the body was driven (advance, next() or range-for); null for a body that returns nothing or failed. Before then it raises Coroutine has not finished: result() is available once done() is true. The checker types it as the coroutine's declared type.

crypto

crypto::equals(a: text, b: text) -> bool

register_all() or area registration · observe

Equal bytes, compared in time that depends only on the length.

crypto::hmac_sha256(key: text, message: text) -> string

register_all() or area registration · observe

HMAC-SHA-256 (RFC 2104), hex.

crypto::hmac_sha256_bytes(key: text, message: text) -> string

register_all() or area registration · observe

The 32 raw MAC bytes.

crypto::hmac_sha512(key: text, message: text) -> string

register_all() or area registration · observe

HMAC-SHA-512 (RFC 2104), hex.

crypto::hmac_sha512_bytes(key: text, message: text) -> string

register_all() or area registration · observe

The 64 raw MAC bytes.

crypto::md5(bytes: text) -> string

register_all() or area registration · observe

MD5 (RFC 1321), 32 hex digits: for interoperability only, never for security.

crypto::md5_bytes(bytes: text) -> string

register_all() or area registration · observe

The 16 raw digest bytes.

crypto::password_hash(password: text, cost: int = 12) -> string

register_all() or area registration · random

bcrypt as PHP's password_hash writes it ($2y$, a fresh 16-byte salt, cost 4 to 31); the first 72 bytes count.

crypto::password_verify(password: text, hash: string) -> bool

register_all() or area registration · observe

Checks a $2y$, $2b$, $2a$ or $2x$ bcrypt hash; any other text is false.

crypto::random_bytes(count: int) -> string

register_all() or area registration · random

count bytes from the operating system's secure generator; never seedable.

crypto::random_hex(count: int) -> string

register_all() or area registration · random

count secure random bytes as 2 * count lowercase hex digits.

crypto::random_int(lo: int, hi: int) -> int

register_all() or area registration · random

A secure random int over lo..hi, both inclusive, unbiased.

crypto::sha1(bytes: text) -> string

register_all() or area registration · observe

SHA-1, 40 hex digits: for interoperability with formats that name it, never for security.

crypto::sha1_bytes(bytes: text) -> string

register_all() or area registration · observe

The 20 raw digest bytes.

crypto::sha256(bytes: text) -> string

register_all() or area registration · observe

The SHA-256 digest (FIPS 180-4) of the bytes (a utf8_string's UTF-8 bytes), 64 lowercase hex digits.

jaiscript
print(crypto::sha256("abc"));
output
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

crypto::sha256_bytes(bytes: text) -> string

register_all() or area registration · observe

The 32 raw digest bytes.

crypto::sha256_file(path: string) -> string

register_all() or area registration · filesystem

The SHA-256 digest of the file's bytes, streamed in chunks; a file it cannot read raises Cannot read file '<path>': <reason>.

crypto::sha512(bytes: text) -> string

register_all() or area registration · observe

The SHA-512 digest (FIPS 180-4), 128 lowercase hex digits.

crypto::sha512_bytes(bytes: text) -> string

register_all() or area registration · observe

The 64 raw digest bytes.

global

Download() -> Download

Standalone jaiscript.exe · construct

NetChannel() -> NetChannel

Standalone jaiscript.exe · construct

NetServer() -> NetServer

Standalone jaiscript.exe · construct

app_cache_dir(application: string) -> string

Every engine · filesystem

Creates application cache folder.

app_data_dir(application: string) -> string

Every engine · filesystem

Creates application data folder.

base64_decode(text: string) -> string

register_all() or area registration · copy

base64_encode(bytes: string) -> string

register_all() or area registration · copy

Encodes raw bytes, not an archive.

bin_dir() -> string

Every engine · observe

Alias of executable_dir.

current_script_dir() -> string

Every engine · observe

current_script_path() -> string

Every engine · observe

delete_file(path: string) -> bool

Standalone jaiscript.exe · filesystem

dir_exists(path: string) -> bool

Standalone jaiscript.exe · filesystem

executable_dir() -> string

Every engine · observe

executable_path() -> string

Every engine · observe

extend(object: var, class: class) -> var

Every engine · mutate

Attaches/re-derives script behavior to a native or script object.

file_data(path: string) -> map<string,var> or null

Every engine · filesystem

Resolved path metadata: path, filename, extension, created, modified and entry flags.

file_exists(path: string) -> bool

Standalone jaiscript.exe · filesystem

file_name(path: string) -> string

Every engine · observe

jaiscript
print(file_name("assets/maps/e1m1.jai"));
output
e1m1.jai

format(template: string, values: var...) -> string

register_all() or area registration · callback

Creates formatted text.

jaiscript
print(format("{} has {} hp", "orc", 7));
output
orc has 7 hp

format_value(value: var, specification: string) -> string

Every engine · observe

from_base64(text: string) -> var

register_all() or area registration · deserialize

from_binary(bytes: string) -> var

register_all() or area registration · deserialize

from_json(text: string) -> var

register_all() or area registration · deserialize

Reconstructs registered classes when tagged; otherwise values/maps/arrays.

jaiscript
var v = from_json("{\"hp\": 3, \"tags\": [\"a\"]}");
print(v["hp"], " ", v["tags"][0]);
output
3 a

import_recheck_interval() -> float

Every engine · configure

Queries import polling window in seconds.

import_recheck_interval(seconds: number) -> void

Every engine · configure

Sets polling window; zero checks every reach.

is_registered_type(value: var) -> bool

register_all() or area registration · observe

key_down(name: string) -> bool

Standalone jaiscript.exe · input

Current held key; arrows and named keys or letters; console/platform dependent.

list_dir(path: string) -> array<string>

Standalone jaiscript.exe · filesystem

load_sound(path: string) -> Sound

Standalone jaiscript.exe · audio

Opens a WAV, MIDI or MP3 file (the header decides, else the extension) and preloads it in the background; null for a missing file, an unknown format, or off Windows.

make_dirs(path: string) -> bool

Standalone jaiscript.exe · filesystem

merge(first: map<K,V>, second: map) -> map<K,V>

register_all() or area registration · copy

Preserves the first input key/value constraints and converts selected second values through normal map-store rules. Second entries replace colliding keys. Only values retained in the result copy; explicit handles retain identity. Inputs do not mutate.

jaiscript
print(to_json(merge({"a": 1, "b": 2}, {"b": 3})));
output
{"a":1,"b":3}

move_file(from: string, to: string) -> bool

Standalone jaiscript.exe · filesystem

Replaces destination; may copy across volumes.

net_host_name() -> string

Standalone jaiscript.exe · observe

net_local_addresses() -> array<string>

Standalone jaiscript.exe · observe

Non-loopback IPv4 addresses.

pair(first: var, second: var) -> pair

register_all() or area registration · construct

The element type of a range-for over a map; pair() holds two nulls.

parallel_reduce(values: array<T>, init: A, step: function(A, T) -> A, combine: function(A, A) -> A) -> A

Every engine · callback, parallel

Chunks sized by values.size() alone fold in element order from a copy of init each, then combine left to right in chunk order: the same result on every machine.

parallel_transform(values: array<T>, callback: function(T) -> R, weight: function(T) -> number = default) -> array<R>

Every engine · callback, parallel

Admission and ordered results follow the parallel contract.

parent_dir(path: string) -> string

Every engine · observe

play_sound(path: string, loop: bool = false) -> Sound

Standalone jaiscript.exe · audio

load_sound then play: the Sound keeps playing when the result is dropped, and stops with stop() or stop_sounds(); null as load_sound.

print(format_or_values: var...) -> void

register_all() or area registration · output, callback

Format string placeholders when applicable; each value prints its display text (containers their contents, instances their to_string methods or fields); skip_newline/skip_flush are control tokens.

print(values: var...) -> void

Every engine · output

Core concatenates display texts; stdlib replacement supports formatting and print tokens.

random() -> random

register_all() or area registration · random

A generator seeded from the operating system's secure generator: its draws differ every run. `random r;` declares one.

random(seed: int) -> random

register_all() or area registration · construct

A generator whose draws are fixed by the seed on every platform and backend. `random r(seed);` declares one.

jaiscript
random r(42);
print(r.next_int(1, 6), " ", r.next_int(1, 6), " ", r.next_int(1, 6));
output
1 3 5

read_file(path: string) -> string

Standalone jaiscript.exe · filesystem

Missing/unreadable file raises; empty file returns empty string.

read_key() -> string

Standalone jaiscript.exe · input

Nonblocking; consumes one queued edge; empty string if idle; named arrows and lowercase letters.

regex(pattern: string = "", flags: string = "") -> regex

Every engine · construct

Flags i, m, s, x; literal texts compile once at load and an invalid one fails the load.

jaiscript
regex r = regex(R"((\w+)@(\w+))", "i");
print(r.pattern, " ", r.search("mail BOB@example now")[2]);
output
(\w+)@(\w+) example

resolve_path(path: string) -> string

Every engine · filesystem

Uses import's search ladder.

root_script_dir() -> string

Every engine · observe

root_script_path() -> string

Every engine · observe

same_object(left: var, right: var) -> bool

Every engine · observe

Object/storage identity, not memberwise equality.

jaiscript
array<int> a = [1];
array<int> b = a;
auto& r = a;
print(same_object(a, b), " ", same_object(a, r), " ", a == b);
output
false true true

shared_from_this() -> shared_ptr<T>

Every engine · observe

Method context only.

sleep(seconds: number) -> void

Every engine · wait

Waits seconds on the engine's time source: inside a run engine::start began, the run suspends and returns to the host until then; elsewhere it blocks.

stop_sounds() -> void

Standalone jaiscript.exe · audio

Stops every Sound.

term_cols() -> int

Standalone jaiscript.exe · observe

term_rows() -> int

Standalone jaiscript.exe · observe

thread_count() -> int

Every engine · observe

The threads a parallel region runs on: the count the host set, else the performance cores, at most one fewer than the hardware threads.

to_base64(value: var) -> string

register_all() or area registration · serialize

Binary archive encoded as Base64.

to_binary(value: var) -> string

register_all() or area registration · serialize

Binary archive bytes, not a human-readable format.

to_char(code: int) -> char

register_all() or area registration · convert

Byte code conversion.

jaiscript
print(to_char(65), " ", type_of(to_char(65)));
output
A char

to_json(value: var, indent: int = -1) -> string

register_all() or area registration · serialize

jaiscript
print(to_json({"hp": 3, "tags": ["a"]}));
print(to_json([1, 2], 2));
output
{"hp":3,"tags":["a"]}
[
  1,
  2
]

to_string(value: var) -> string

register_all() or area registration · callback

The display text print shows: a container's contents, an instance's to_string(), else its class name and fields.

jaiscript
print(to_string(3) + "!", " ", to_string(2.5), " ", to_string([1, "two"]));
output
3! 2.5 [1, "two"]

type_of(value: var) -> string

register_all() or area registration · observe

jaiscript
print(type_of(1), " ", type_of(1.5), " ", type_of("s"), " ", type_of([1]));
output
int float string array

utf8_string(value: var) -> utf8_string

register_all() or area registration · convert

weak_from_this() -> weak_ptr<T>

Every engine · observe

Method context only.

working_dir() -> string

Every engine · observe

writable_dir(path: string) -> bool

Standalone jaiscript.exe · filesystem

Creates folder and performs a write/remove probe.

write_file(path: string, content: string) -> bool

Standalone jaiscript.exe · filesystem

Creates missing parent folders.

zip_entries(path: string) -> array<string>

Standalone jaiscript.exe · filesystem

zip_extract(zip: string, entry: string, destination: string) -> bool

Standalone jaiscript.exe · filesystem

Checks CRC-32.

language

cast<T>(value: var) -> T

Every engine · convert

Explicit conversion; cast<T&> binds compatible storage; handle casts check class compatibility.

import(paths: string or array<string>..., force: jai::force = omitted) -> bool

Every engine · execute

True when a module group ran on this reach; import statement has the same loading effect.

include(path: string) -> var

Every engine · execute

Executes included source every reach; literal function-body include is textual.

map

map::filter(values: map<K,V>, predicate: function(K, V) -> bool) -> map<K,V>

Every engine · copy, callback

Returns a new map of the entries the predicate accepts, preserving key/value constraints; the input does not mutate. Only selected value elements copy; explicit handles retain identity.

map<K,V>

map<K,V>.clear() -> void

Every engine · mutate

map<K,V>.contains(key: K) -> bool

Every engine · observe

Keys never coerce.

jaiscript
map<string, int> stock = {"axe": 2};
print(stock.contains("axe"), " ", stock.contains("bow"));
output
true false

map<K,V>.empty() -> bool

Every engine · observe

map<K,V>.erase(key: K) -> bool

Every engine · mutate

Alias of remove(key); true if an entry was removed, false when absent.

jaiscript
map<string, int> stock = {"axe": 2, "bow": 1};
print(stock.erase("axe"), " ", stock.erase("axe"), " ", to_json(stock));
output
true false {"bow":1}

map<K,V>.filter(predicate: function(K, V) -> bool) -> map<K,V>

Every engine · mutate; callback

Keeps the entries the predicate accepts in place, retaining key/value constraints, and returns the receiver; map::filter returns a copy. Callback value references target live entries.

jaiscript
map<string, int> stock = {"axe": 2, "bow": 0, "cup": 5};
map<string, int> big = map::filter(stock, (k, v) => v > 2);   // a copy
stock.filter((k, v) => v > 0);                                 // in place
print(to_json(big), " ", to_json(stock));
output
{"cup":5} {"axe":2,"cup":5}

map<K,V>.get(key: K, fallback: var = null) -> V or var

Every engine · observe

Does not insert; returns the stored value or fallback; missing keys default to null. An object, array or map element comes back as a reference to it, like a C++ reference return: binding the result to var, auto or T copies the element, while var&, T& and a member call on the result reach the stored element.

jaiscript
map<string, int> stock = {"axe": 2};
print(stock.get("axe"), " ", stock.get("bow"), " ", stock.get("bow", 0), " ", stock.size());
output
2 null 0 1

map<K,V>.has(key: K) -> bool

Every engine · observe

Alias of contains.

map<K,V>.keys() -> array<var>

Every engine · copy

Key order; keys become detached values. Value results copy, while shared_ptr/weak_ptr handles retain identity.

jaiscript
map<string, int> stock = {"bow": 1, "axe": 2};
print(to_json(stock.keys()), " ", to_json(stock.values()));
output
["axe","bow"] [2,1]

map<K,V>.length() -> int

Every engine · observe

Alias of size.

map<K,V>.remove(key: K) -> bool

Every engine · mutate

True if an entry was removed; false when absent.

map<K,V>.remove_if(predicate: function(K, V) -> bool) -> int

Every engine · mutate, callback

Returns removed count; keys remain immutable.

jaiscript
map<string, int> stock = {"axe": 2, "bow": 0, "cap": 0};
print(stock.remove_if((k, v) => v == 0), " ", to_json(stock));
output
2 {"axe":2}

map<K,V>.size() -> int

Every engine · observe

map<K,V>.to_array() -> array<array<var>>

Every engine · copy

Ordered [key,value] arrays; not Pair objects. Value results copy, while shared_ptr/weak_ptr handles retain identity.

jaiscript
map<string, int> stock = {"axe": 2};
print(to_json(stock.to_array()));
output
[["axe",2]]

map<K,V>.values() -> array<var>

Every engine · copy

Values in key order. Value results copy, while shared_ptr/weak_ptr handles retain identity.

math

math::abs(value: number or vector) -> number or vector

Every engine · observe

Integral arguments retain exact integral results.

math::angle_between(left: vector, right: matching_vector) -> float

Every engine · observe

Radians.

math::atan2(y: number or vector, x: number or vector) -> float or vector

Every engine · observe

math::ceil(value: number or vector) -> float or vector

Every engine · observe

math::clamp(value: number or vector, minimum: number or vector, maximum: number or vector) -> number or vector

Every engine · observe

math::color() -> math::color

Every engine · construct

Opaque white.

math::color(red: number, green: number, blue: number, alpha: number = 1) -> math::color

Every engine · construct

math::color(value: math::color) -> math::color

Every engine · construct

Copies a color; a lone scalar or other vector kind is rejected.

math::cos(angle: number or vector) -> float or vector

Every engine · observe

math::cross(left: vector2 or vector3, right: matching_vector) -> number or vector3

Every engine · observe

2D determinant or 3D cross product.

math::degrees_to_radians(angle: number or vector) -> float or vector

Every engine · observe

math::distance(left: vector, right: matching_vector) -> float

Every engine · observe

Vector form; scalar-coordinate form has four arguments.

math::distance(x1: number, y1: number, x2: number, y2: number) -> float

Every engine · observe

Vector form; scalar-coordinate form has four arguments.

math::distance_squared(left: vector, right: matching_vector) -> number

Every engine · observe

Vector form; scalar-coordinate form has four arguments.

math::distance_squared(x1: number, y1: number, x2: number, y2: number) -> number

Every engine · observe

Vector form; scalar-coordinate form has four arguments.

math::dot(left: vector, right: matching_vector) -> number

Every engine · observe

math::floor(value: number or vector) -> float or vector

Every engine · observe

Component-wise for floating vectors; integers accepted.

math::ifloor(value: number) -> int

Every engine · convert

math::itrunc(value: number) -> int

Every engine · convert

Truncates toward zero.

math::ivec2() -> math::ivec2

Every engine · construct

Zero initialized.

math::ivec2(value: same_dimension_vector) -> math::ivec2

Every engine · construct

Copies/converts matching dimensions; a lone scalar is rejected.

math::ivec2(x: number, y: number) -> math::ivec2

Every engine · construct

math::ivec3() -> math::ivec3

Every engine · construct

Zero initialized.

math::ivec3(value: same_dimension_vector) -> math::ivec3

Every engine · construct

Copies/converts matching dimensions; a lone scalar is rejected.

math::ivec3(x: number, y: number, z: number = 0) -> math::ivec3

Every engine · construct

math::ivec3(xy: vector2, z: number) -> math::ivec3

Every engine · construct

math::length(vector: vector) -> float

Every engine · observe

math::length_squared(vector: vector) -> number

Every engine · observe

Integral vector result remains exact when representable.

math::lerp(start: number or vector or color, end: same_shape, percent: number) -> same_shape

Every engine · observe

Color interpolation uses OKLab.

math::max(left: number or vector, right: number or vector) -> number or vector

Every engine · observe

math::min(left: number or vector, right: number or vector) -> number or vector

Every engine · observe

Scalar selected operand retains its kind; vectors component-wise.

math::mix(start: number or vector or color, end: same_shape, percent: number) -> same_shape

Every engine · observe

Alias of lerp.

math::mix_hsv(start: color, end: color, percent: number) -> color

Every engine · observe

math::mix_in(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::mix_in_out(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::mix_out(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::mix_out_in(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::mix_rgb(start: color, end: color, percent: number) -> color

Every engine · observe

math::normalize(vector: vector) -> floating_vector

Every engine · observe

Zero vector gives zero vector.

math::perpendicular(vector: vector2) -> vector2

Every engine · observe

math::pow(base: number or vector, exponent: number or vector) -> float or vector

Every engine · observe

math::project(vector: vector, onto: matching_vector) -> floating_vector

Every engine · observe

math::radians_to_degrees(angle: number or vector) -> float or vector

Every engine · observe

math::reflect(vector: vector, normal: matching_vector) -> floating_vector

Every engine · observe

math::remap(value: number or vector, in_start: same_shape, in_end: same_shape, out_start: same_shape, out_end: same_shape) -> number or vector

Every engine · observe

math::rotate(vector: vector2, angle: number) -> vector2

Every engine · observe

Radians.

math::rotate(vector: vector3, axis: vector3, angle: number) -> vector3

Every engine · observe

math::round(value: number or vector) -> float or vector

Every engine · observe

math::sin(angle: number or vector) -> float or vector

Every engine · observe

Radians.

math::sqrt(value: number or vector) -> float or vector

Every engine · observe

math::tan(angle: number or vector) -> float or vector

Every engine · observe

math::unmix(start: number or vector, end: same_shape, value: same_shape) -> number or vector

Every engine · observe

math::unmix_in(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::unmix_in_out(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::unmix_out(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::unmix_out_in(start: number or vector or color, end: same_shape, value: number or same_shape, strength: number) -> same_shape

Every engine · observe

math::vec2() -> math::vec2

Every engine · construct

Zero initialized.

math::vec2(value: same_dimension_vector) -> math::vec2

Every engine · construct

Copies/converts matching dimensions; a lone scalar is rejected.

math::vec2(x: number, y: number) -> math::vec2

Every engine · construct

math::vec3() -> math::vec3

Every engine · construct

Zero initialized.

math::vec3(value: same_dimension_vector) -> math::vec3

Every engine · construct

Copies/converts matching dimensions; a lone scalar is rejected.

math::vec3(x: number, y: number, z: number = 0) -> math::vec3

Every engine · construct

math::vec3(xy: vector2, z: number) -> math::vec3

Every engine · construct

math::vec4() -> math::vec4

Every engine · construct

Zero initialized.

math::vec4(value: same_dimension_vector) -> math::vec4

Every engine · construct

Copies/converts matching dimensions; a lone scalar is rejected.

math::vec4(x: number, y: number, z: number = 0, w: number = 0) -> math::vec4

Every engine · construct

math::vec4(xy: vector2, z: number, w: number) -> math::vec4

Every engine · construct

math::vec4(xyz: vector3, w: number) -> math::vec4

Every engine · construct

math::wrap_add(left: int, right: int) -> int

Every engine · observe

Modulo 2^64 regardless of overflow build policy.

math::wrap_mul(left: int, right: int) -> int

Every engine · observe

math::wrap_sub(left: int, right: int) -> int

Every engine · observe

math::acos(value: number) -> float

Every engine · observe

math::asin(value: number) -> float

Every engine · observe

math::atan(value: number) -> float

Every engine · observe

math::cbrt(value: number) -> float

Every engine · observe

math::cosh(value: number) -> float

Every engine · observe

math::degrees(value: number) -> float

Every engine · observe

Alias of math::radians_to_degrees.

math::exp(value: number) -> float

Every engine · observe

math::exp2(value: number) -> float

Every engine · observe

math::fmod(value: number, divisor: number) -> float

Every engine · observe

math::hypot(x: number, y: number) -> float

Every engine · observe

math::is_inf(value: number) -> bool

Every engine · observe

math::is_nan(value: number) -> bool

Every engine · observe

math::log(value: number) -> float

Every engine · observe

math::log10(value: number) -> float

Every engine · observe

math::log2(value: number) -> float

Every engine · observe

math::radians(value: number) -> float

Every engine · observe

Alias of math::degrees_to_radians.

math::saturate(value: number) -> float

Every engine · observe

math::sign(value: number) -> int

Every engine · observe

math::sinh(value: number) -> float

Every engine · observe

math::tanh(value: number) -> float

Every engine · observe

math::trunc(value: number) -> float

Every engine · observe

math::wrap(minimum: number, maximum: number, value: number) -> float

Every engine · observe

The bounds may come in either order.

math::ivec2

math::ivec2.cross(other: matching_vector) -> number or vector3

Every engine · observe

math::ivec2.distance_to(other: matching_vector) -> float

Every engine · observe

math::ivec2.dot(other: matching_vector) -> number

Every engine · observe

math::ivec2.length() -> float

Every engine · observe

math::ivec2.length_squared() -> number

Every engine · observe

math::ivec2.normalized() -> floating_vector

Every engine · copy

math::ivec2.rotated(angle: number) -> vector2

Every engine · copy

math::ivec3

math::ivec3.cross(other: matching_vector) -> number or vector3

Every engine · observe

math::ivec3.distance_to(other: matching_vector) -> float

Every engine · observe

math::ivec3.dot(other: matching_vector) -> number

Every engine · observe

math::ivec3.length() -> float

Every engine · observe

math::ivec3.length_squared() -> number

Every engine · observe

math::ivec3.normalized() -> floating_vector

Every engine · copy

math::ivec3.rotated(axis: vector3, angle: number) -> vector3

Every engine · copy

math::vec2

math::vec2.cross(other: matching_vector) -> number or vector3

Every engine · observe

math::vec2.distance_to(other: matching_vector) -> float

Every engine · observe

math::vec2.dot(other: matching_vector) -> number

Every engine · observe

math::vec2.length() -> float

Every engine · observe

math::vec2.length_squared() -> number

Every engine · observe

math::vec2.normalized() -> floating_vector

Every engine · copy

math::vec2.rotated(angle: number) -> vector2

Every engine · copy

math::vec3

math::vec3.cross(other: matching_vector) -> number or vector3

Every engine · observe

math::vec3.distance_to(other: matching_vector) -> float

Every engine · observe

math::vec3.dot(other: matching_vector) -> number

Every engine · observe

math::vec3.length() -> float

Every engine · observe

math::vec3.length_squared() -> number

Every engine · observe

math::vec3.normalized() -> floating_vector

Every engine · copy

math::vec3.rotated(axis: vector3, angle: number) -> vector3

Every engine · copy

math::vec4

math::vec4.distance_to(other: matching_vector) -> float

Every engine · observe

math::vec4.dot(other: matching_vector) -> number

Every engine · observe

math::vec4.length() -> float

Every engine · observe

math::vec4.length_squared() -> number

Every engine · observe

math::vec4.normalized() -> floating_vector

Every engine · copy

random

random.next_bool() -> bool

register_all() or area registration · random

The top bit of a draw.

random.next_bytes(count: int) -> string

register_all() or area registration · random

count bytes, eight per draw, low byte first.

random.next_float() -> float

register_all() or area registration · random

Uniform in [0, 1): the top 53 bits of a draw over 2^53.

random.next_float(lo: float, hi: float) -> float

register_all() or area registration · random

Uniform in [lo, hi); the bounds must be finite and in order.

random.next_int(lo: int, hi: int) -> int

register_all() or area registration · random

Uniform over lo..hi, both inclusive, unbiased; an inverted range raises.

random.pick(values: array) -> var

register_all() or area registration · random

One element, each equally likely; an empty array raises.

random.seed(seed: int) -> void

register_all() or area registration · configure

Restarts the generator as random(seed) would.

random.shuffle(values: array&) -> void

register_all() or area registration · random

Shuffles the array in place (Fisher-Yates from the last element down).

reflect

reflect::bases(object_or_class: var) -> array<string>

register_all() or area registration · observe

reflect::bind(object: var, method: string) -> function

register_all() or area registration · bind

Pins receiver; later calls follow reloaded methods.

jaiscript
class Orc { int hp = 7; void hit() { hp -= 1; } }
auto o = new Orc();
auto hit = reflect::bind(o, "hit");
hit();
hit();
print(o.hp);
output
5

reflect::call(name: string, args: var...) -> var

register_all() or area registration · callback

reflect::classes() -> array<string>

register_all() or area registration · observe

reflect::construct(class_name: string, args: var...) -> var

register_all() or area registration · construct

jaiscript
class Orc { int hp = 7; Orc(int h) { hp = h; } }
var o = reflect::construct("Orc", 12);
print(o.hp);
output
12

reflect::construct_shared(class_name: string, args: var...) -> shared_ptr

register_all() or area registration · construct

reflect::fields(object_or_class: var) -> array<map<string,var>>

register_all() or area registration · observe

jaiscript
class Orc { int hp = 7; string name = "grok"; }
for (auto f : reflect::fields(Orc())) { print(f["name"], ": ", f["type"]); }
output
hp: int
name: string

reflect::function_arguments(name: string) -> array<array<map<string,var>>>

register_all() or area registration · observe

One parameter-description array per overload.

reflect::functions() -> array<map<string,var>>

register_all() or area registration · observe

reflect::generation(object_or_class: var) -> int

register_all() or area registration · observe

reflect::get(object: var, field: string) -> var

register_all() or area registration · observe, callback

Reads through normal field/accessor semantics.

jaiscript
class Orc { int hp = 7; }
Orc o;
reflect::set(o, "hp", 9);
print(reflect::get(o, "hp"));
output
9

reflect::globals() -> array<map<string,var>>

register_all() or area registration · observe

reflect::has_field(object_or_class: var, name: string) -> bool

register_all() or area registration · observe

reflect::has_method(object_or_class: var, name: string) -> bool

register_all() or area registration · observe

jaiscript
class Orc { int hp = 7; void hit() {} }
print(reflect::has_field(Orc(), "hp"), " ", reflect::has_method(Orc(), "hit"), " ", reflect::has_method(Orc(), "fly"));
output
true true false

reflect::instances(class: class or string) -> array<var>

register_all() or area registration · observe

reflect::invoke(object: var, method: string, args: var...) -> var

register_all() or area registration · callback

jaiscript
class Orc { int add(int a, int b) { return a + b; } }
print(reflect::invoke(Orc(), "add", 2, 3));
output
5

reflect::is_cpp_bound(value: var) -> bool

register_all() or area registration · observe

reflect::is_enabled(privileges: int or string...) -> bool

Every engine · observe

At least one privilege; scripts query grants, hosts change them.

reflect::method_arguments(object_or_class: var, name: string) -> array<array<map<string,var>>>

register_all() or area registration · observe

One parameter-description array per overload.

reflect::methods(object_or_class: var) -> array<map<string,var>>

register_all() or area registration · observe

reflect::set(object: var, field: string, value: var) -> void

register_all() or area registration · mutate, callback

reflect::type_name(value: var) -> string

register_all() or area registration · observe

regex

regex::escape(text: string) -> string

Every engine · copy

A pattern matching the text literally; keeps a utf8_string's kind.

regex.find_all(text: string) -> array<regex::match>

Every engine · observe

Left to right; an empty match moves the next search one character on.

regex.matches(text: string) -> bool

Every engine · observe

The whole text, any way through the pattern.

regex.replace(text: string, replacement: (regex::match) -> string) -> string

Every engine · copy, callback

Called once per match, in order.

regex.replace(text: string, replacement: string) -> string

Every engine · copy

$1..$99, ${n}, ${name}, $0, $$.

jaiscript
print(regex(R"((\w+) (\w+))").replace("ada lovelace", "$2, $1"));
output
lovelace, ada

regex.replace_first(text: string, replacement: (regex::match) -> string) -> string

Every engine · copy, callback

regex.replace_first(text: string, replacement: string) -> string

Every engine · copy

The first match only.

regex.search(text: string) -> regex::match

Every engine · observe

The leftmost match, or null.

regex.search(text: string, start: int) -> regex::match

Every engine · observe

From a position (bytes, or characters on a utf8_string); the text before it is the assertions' context.

regex.split(text: string) -> array<string>

Every engine · copy

ECMAScript's split; each split's groups follow its piece.

jaiscript
print(to_json(regex(R"(\s*,\s*)").split("a , b,c")));
output
["a","b","c"]

regex.split(text: string, max_splits: int) -> array<string>

Every engine · copy

The rest stays in the last piece; a negative count is no limit.

regex::match

regex::match[group: int | string] -> string

Every engine · observe

A group by number or name; null when it took no part.

regex::match.end(group: int | string = 0) -> int

Every engine · observe

-1 for a group that took no part.

regex::match.size() -> int

Every engine · observe

The whole match and every group.

regex::match.start(group: int | string = 0) -> int

Every engine · observe

-1 for a group that took no part.

regex::match.text() -> string

Every engine · observe

The whole match (as m[0]).

shared_ptr<T>

shared_ptr<T>.cpp_ref_count() -> int

Every engine · observe

shared_ptr<T>.reset() -> void

Every engine · mutate

Empties the handle its receiver names (a variable, field, element or map entry), as C++ p.reset() does; the object stays with its other owners, and a call result is a temporary it leaves alone.

shared_ptr<T>.reset(shared_ptr<T> h) -> void

Every engine · mutate

Points the handle its receiver names at h's object, as C++ p.reset(new T()) does: the object it held stays with its other owners, nothing writes through it and no operator= runs. h is a handle (new T(), make_shared<T>() or a shared_ptr; a null one empties the receiver) of a class the receiver admits as a shared_ptr<T> assignment does; a value or a primitive raises.

shared_ptr<T>.same_as(other: var) -> bool

Every engine · observe

True when both handles share one object. same_object(x, y) asks the same question of any two values.

shared_ptr<T>.unique() -> bool

Every engine · observe

shared_ptr<T>.use_count() -> int

Every engine · observe

spider

spider::Response(status: int = 200, body: string = "") -> spider::Response

register_spider() + a host transport + the network permission · construct

A new response, as a server handler builds one.

spider::catch(url: string, options: map = {}) -> spider::Response

register_spider() + a host transport + the network permission · network

A GET (options.method overrides) through the host's transport; options method, headers, timeout (30 s), type, redirects (5). Errors name the call, the URL and the reason.

spider::get(url: string, options: map = {}) -> spider::Response

register_spider() + a host transport + the network permission · network

The plain name of spider::catch.

spider::post(url: string, content: var, options: map = {}) -> spider::Response

register_spider() + a host transport + the network permission · network

The plain name of spider::sling, URL first.

spider::sling(content: var, url: string, options: map = {}) -> spider::Response

register_spider() + a host transport + the network permission · network

A POST carrying content: text as text/plain, anything else as JSON, a map as a form with type "form".

spider::Response

spider::Response.clear_cookie(name: string, options: map = {}) -> void

register_spider() · mutate

Adds a Set-Cookie line with Max-Age=0.

spider::Response.header(name: string) -> string

register_spider() · observe

The header in any spelling of its name; "" when absent.

spider::Response.header(name: string, value: string) -> spider::Response&

register_spider() · mutate

Sets a header, replacing one of the same name in any spelling; chains.

spider::Response.json() -> var

register_spider() · deserialize

from_json of the body.

spider::Response.ok() -> bool

register_spider() · observe

True for a 2xx status.

spider::Response.set_cookie(name: string, value: string, options: map = {}) -> void

register_spider() · mutate

Adds a Set-Cookie line, the value percent-encoded; options max_age, expires, path, domain, secure, http_only (true), same_site ("Lax").

string

string::append(value: text, part: text, parts: text...) -> Self

register_all() or area registration · copy

Returns new text; preserves first input text kind. Inputs do not mutate.

string::from_code(codepoint: int) -> string

register_all() or area registration · copy

UTF-8 encoding of a Unicode scalar value.

string::is_valid_utf8(value: text) -> bool

register_all() or area registration · observe

string::join(values: array, separator: text = "") -> string

register_all() or area registration · copy

jaiscript
print(string::join(["a", "b", "c"], "/"));
output
a/b/c

string::pad_left(value: text, width: int, fill: char or text = ' ') -> same_text_kind

register_all() or area registration · copy

string::pad_right(value: text, width: int, fill: char or text = ' ') -> same_text_kind

register_all() or area registration · copy

string::repeat(value: text, count: int) -> same_text_kind

register_all() or area registration · copy

string::replace(value: text, from: text, to: text) -> same_text_kind

register_all() or area registration · copy

Replaces every occurrence of from, left to right and without overlap.

string::to_lower(value: text) -> same_text_kind

register_all() or area registration · copy

Namespace transform leaves input unchanged.

string::to_upper(value: text) -> same_text_kind

register_all() or area registration · copy

string::trim(value: text) -> same_text_kind

register_all() or area registration · copy

Returns a copy without the whitespace class (space, tab, LF, VT, FF, CR) at both ends; a utf8_string argument returns a utf8_string. The method form takes a character set.

string.append(part: text, parts: text...) -> Self

Every engine · mutate

Appends text in place and returns the receiver; retains receiver text kind.

string.at(index: int) -> char

Every engine · observe

Returns an inline byte char like []; no temporary string allocation. Negative indices count from end; out-of-range raises.

jaiscript
string s = "abc";
print(s.at(1), " ", s[2], " ", type_of(s.at(0)));
output
b c char

string.back() -> char

Every engine · observe

Returns an inline byte char like []; no temporary string allocation. Empty text raises.

string.byte_size() -> int

Every engine · observe

Raw byte count on both text types.

string.code() -> int

Every engine · observe

Requires exactly one valid UTF-8 character; otherwise raises.

string.compare(other: text) -> int

Every engine · observe

Negative, zero or positive lexical comparison.

string.contains(needle: text) -> bool

Every engine · observe

jaiscript
print("hello".contains("ell"), " ", "hello".count("l"));
output
true 2

string.count(needle: text) -> int

Every engine · observe

string.empty() -> bool

Every engine · observe

string.ends_with(suffix: text) -> bool

Every engine · observe

string.erase(position: int, count: int = remaining) -> Self

Every engine · mutate

string.explode(separator: text = whitespace, max_splits: int = -1) -> array<string>

Every engine · copy

Whitespace runs by default; empty separator splits characters. Negative limit is unlimited; last piece retains rest. UTF-8 receiver yields UTF-8 text values.

string.find(needle: text, start: int = 0) -> int

Every engine · observe

-1 if absent.

jaiscript
print("banana".find("an"), " ", "banana".find("an", 2), " ", "banana".find("x"));
output
1 3 -1

string.find_first_not_of(characters: text, start: int = 0) -> int

Every engine · observe

-1 if absent.

string.find_first_of(characters: text, start: int = 0) -> int

Every engine · observe

-1 if absent.

string.find_last_not_of(characters: text, start: int = end) -> int

Every engine · observe

-1 if absent.

string.find_last_of(characters: text, start: int = end) -> int

Every engine · observe

-1 if absent.

string.front() -> char

Every engine · observe

Returns an inline byte char like []; no temporary string allocation. Empty text raises.

string.insert(position: int, value: text) -> Self

Every engine · mutate

string.is_alnum() -> bool

Every engine · observe

string.is_alpha() -> bool

Every engine · observe

string.is_digit() -> bool

Every engine · observe

string.is_lower() -> bool

Every engine · observe

string.is_space() -> bool

Every engine · observe

string.is_upper() -> bool

Every engine · observe

string.is_valid_utf8() -> bool

Every engine · observe

string.length() -> int

Every engine · observe

Alias of size.

string.lines() -> array<Self>

Every engine · copy

Splits line endings.

jaiscript
print(to_json("one\ntwo".lines()));
output
["one","two"]

string.pad_center(width: int, fill: char or text = ' ') -> Self

Every engine · mutate

string.pad_left(width: int, fill: char or text = ' ') -> Self

Every engine · mutate

jaiscript
print("[", "7".pad_left(3, '0'), "] [", "ab".pad_right(4), "]");
output
[007] [ab  ]

string.pad_right(width: int, fill: char or text = ' ') -> Self

Every engine · mutate

string.partition(separator: text) -> array<Self>

Every engine · copy

Three parts: before, separator, after; absent separator gives text and two empty strings.

jaiscript
print(to_json("key=value=more".partition("=")));
output
["key","=","value=more"]

string.reader() -> binary::reader

Every engine · copy

Creates an independent reader cursor over these bytes.

string.remove_prefix(count: int) -> Self

Every engine · mutate

string.remove_suffix(count: int) -> Self

Every engine · mutate

string.repeat(count: int) -> Self

Every engine · mutate

Repeats receiver and returns text for chaining.

jaiscript
print("ab".repeat(3));
output
ababab

string.replace(from: text, to: text) -> Self

Every engine · mutate

Replaces every occurrence of from, left to right and without overlap.

jaiscript
string s = "a-b-c";
s.replace("-", "+");
print(s);
output
a+b+c

string.replace_first(from: text, to: text) -> Self

Every engine · mutate

string.replace_last(from: text, to: text) -> Self

Every engine · mutate

string.reverse() -> Self

Every engine · mutate

string.rfind(needle: text, start: int = end) -> int

Every engine · observe

-1 if absent.

string.size() -> int

Every engine · observe

Bytes on string; characters on utf8_string.

string.split(separator: text = whitespace, max_splits: int = -1) -> array<string>

Every engine · copy

Whitespace runs by default; empty separator splits characters. Negative limit is unlimited; last piece retains rest. UTF-8 receiver yields UTF-8 text values.

jaiscript
print(to_json("a  b\tc".split()));
print(to_json("a,,b".split(",")));
print(to_json("k=v=w".split("=", 1)));
output
["a","b","c"]
["a","","b"]
["k","v=w"]

string.starts_with(prefix: text) -> bool

Every engine · observe

jaiscript
print("player_1".starts_with("player"), " ", "a.jai".ends_with(".jai"));
output
true true

string.substr(start: int, count: int = remaining) -> Self

Every engine · copy

Second argument is count, not end index.

jaiscript
print("dungeon".substr(3), " ", "dungeon".substr(0, 3));
output
geon dun

string.to_bytes(offset: int = 0, count: int = remaining) -> array<uint8>

Every engine · copy

Offsets/counts are raw bytes even for utf8_string.

jaiscript
print(to_json("AB".to_bytes()), " ", string::from_bytes([72, 105]));
output
[65,66] Hi

string.to_float(fallback: var = null) -> float or fallback

Every engine · observe

Whole trimmed parse; parse failure returns fallback.

string.to_int(fallback: var = null, base: int = 10) -> int or fallback

Every engine · observe

Whole trimmed parse; base is 0 or 2..36; parse failure returns fallback.

jaiscript
print("42".to_int(), " ", "ff".to_int(0, 16), " ", "x".to_int(-1), " ", "2.5".to_float());
output
42 255 -1 2.5

string.to_lower() -> Self

Every engine · mutate

ASCII case conversion; returns text for chaining.

string.to_upper() -> Self

Every engine · mutate

ASCII case conversion; returns text for chaining.

jaiscript
string s = "loud";
string t = s.to_upper();     // changes s and returns it
print(s, " ", t, " ", string::to_lower(t));
output
LOUD LOUD loud

string.to_utf8() -> utf8_string

Every engine · copy

Same bytes with character indexing.

string.trim(characters: text = string::whitespace) -> Self

Every engine · mutate

Mutates using the shared whitespace set by default: space, tab, LF, VT, FF and CR. Returns the receiver.

jaiscript
string s = "  hi  ";
s.trim();                        // in place
string t = "--x--";
t.trim("-");                     // a chosen character set
print("[", s, "] [", t, "] [", string::trim("  copy  "), "]");
output
[hi] [x] [copy]

string.trim_left(characters: text = string::whitespace) -> Self

Every engine · mutate

Mutates using the shared whitespace set by default: space, tab, LF, VT, FF and CR. Returns the receiver.

string.trim_right(characters: text = string::whitespace) -> Self

Every engine · mutate

Mutates using the shared whitespace set by default: space, tab, LF, VT, FF and CR. Returns the receiver.

string.utf8_chars() -> array<string>

Every engine · copy

string.utf8_length() -> int

Every engine · observe

Counts decoded UTF-8 characters.

string::from_bytes(bytes: array<uint8> or array<int8> or array<int> or array<char> or array<var>) -> string

Every engine · copy

Byte values must fit the accepted byte boundary.

time

time::date_from_unix(seconds: number, utc: bool = false) -> time::date

register_all() or area registration · construct

time::date_now(template: string) -> string

register_all() or area registration · observe

Formatted local calendar time.

time::engine_elapsed() -> float

register_all() or area registration · observe

time::execute_elapsed() -> float

register_all() or area registration · observe

Seconds elapsed in the current execute.

time::local_date(year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, millisecond: int = 0) -> time::date

register_all() or area registration · construct

time::local_now() -> time::date

register_all() or area registration · construct

time::now() -> float

register_all() or area registration · observe

Engine elapsed seconds, monotonic.

time::stopwatch() -> time::stopwatch

register_all() or area registration · construct

time::unix_ms() -> int

register_all() or area registration · observe

Wall-clock Unix milliseconds.

time::unix_time() -> float

register_all() or area registration · observe

Wall-clock Unix seconds.

time::utc_date(year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, millisecond: int = 0) -> time::date

register_all() or area registration · construct

time::utc_now() -> time::date

register_all() or area registration · construct

time::date

time::date.add_days(days: number) -> time::date

register_all() or area registration · copy

Whole days required.

time::date.add_hours(hours: number) -> time::date

register_all() or area registration · copy

time::date.add_minutes(minutes: number) -> time::date

register_all() or area registration · copy

time::date.add_months(months: number) -> time::date

register_all() or area registration · copy

Whole months required.

time::date.add_seconds(seconds: number) -> time::date

register_all() or area registration · copy

time::date.add_years(years: number) -> time::date

register_all() or area registration · copy

Whole years required.

time::date.between(start: time::date, end: time::date) -> bool

register_all() or area registration · observe

Inclusive membership; reversed endpoints accepted.

time::date.format(template: string) -> string

register_all() or area registration · observe

time::date.to_local() -> time::date

register_all() or area registration · copy

time::date.to_string() -> string

register_all() or area registration · observe

time::date.to_utc() -> time::date

register_all() or area registration · copy

time::date.unix() -> float

register_all() or area registration · observe

time::date.unix_ms() -> int

register_all() or area registration · observe

time::stopwatch

time::stopwatch.delta() -> float

register_all() or area registration · mutate

Seconds since last delta.

time::stopwatch.elapsed() -> float

register_all() or area registration · observe

time::stopwatch.is_paused() -> bool

register_all() or area registration · observe

time::stopwatch.is_running() -> bool

register_all() or area registration · observe

time::stopwatch.pause() -> float

register_all() or area registration · mutate

time::stopwatch.resume() -> float

register_all() or area registration · mutate

Returns accumulated elapsed seconds.

time::stopwatch.start() -> void

register_all() or area registration · mutate

time::stopwatch.stop() -> float

register_all() or area registration · mutate

Elapsed seconds.

utf8_string

utf8_string.append(part: text, parts: text...) -> Self

Every engine · mutate

Appends text in place and returns the receiver; retains receiver text kind.

utf8_string.at(index: int) -> Self

Every engine · observe

One byte of string text or one UTF-8 character; operator [] on string returns char instead.

utf8_string.back() -> Self

Every engine · observe

One byte of string text or one UTF-8 character; operator [] on string returns char instead.

utf8_string.byte_size() -> int

Every engine · observe

Raw byte count on both text types.

utf8_string.code() -> int

Every engine · observe

Requires exactly one valid UTF-8 character; otherwise raises.

utf8_string.compare(other: text) -> int

Every engine · observe

Negative, zero or positive lexical comparison.

utf8_string.contains(needle: text) -> bool

Every engine · observe

utf8_string.count(needle: text) -> int

Every engine · observe

utf8_string.empty() -> bool

Every engine · observe

utf8_string.ends_with(suffix: text) -> bool

Every engine · observe

utf8_string.erase(position: int, count: int = remaining) -> Self

Every engine · mutate

utf8_string.explode(separator: text = whitespace, max_splits: int = -1) -> array<var>

Every engine · copy

Whitespace runs by default; empty separator splits characters. Negative limit is unlimited; last piece retains rest. UTF-8 receiver yields UTF-8 text values.

utf8_string.find(needle: text, start: int = 0) -> int

Every engine · observe

-1 if absent.

utf8_string.find_first_not_of(characters: text, start: int = 0) -> int

Every engine · observe

-1 if absent.

utf8_string.find_first_of(characters: text, start: int = 0) -> int

Every engine · observe

-1 if absent.

utf8_string.find_last_not_of(characters: text, start: int = end) -> int

Every engine · observe

-1 if absent.

utf8_string.find_last_of(characters: text, start: int = end) -> int

Every engine · observe

-1 if absent.

utf8_string.front() -> Self

Every engine · observe

One byte of string text or one UTF-8 character; operator [] on string returns char instead.

utf8_string.insert(position: int, value: text) -> Self

Every engine · mutate

utf8_string.is_alnum() -> bool

Every engine · observe

utf8_string.is_alpha() -> bool

Every engine · observe

utf8_string.is_digit() -> bool

Every engine · observe

utf8_string.is_lower() -> bool

Every engine · observe

utf8_string.is_space() -> bool

Every engine · observe

utf8_string.is_upper() -> bool

Every engine · observe

utf8_string.is_valid_utf8() -> bool

Every engine · observe

utf8_string.length() -> int

Every engine · observe

Alias of size.

utf8_string.lines() -> array<var>

Every engine · copy

Splits line endings. Returned text values are utf8_string; array storage remains dynamic.

utf8_string.pad_center(width: int, fill: char or text = ' ') -> Self

Every engine · mutate

utf8_string.pad_left(width: int, fill: char or text = ' ') -> Self

Every engine · mutate

utf8_string.pad_right(width: int, fill: char or text = ' ') -> Self

Every engine · mutate

utf8_string.partition(separator: text) -> array<var>

Every engine · copy

Three parts: before, separator, after; absent separator gives text and two empty strings. Returned text values are utf8_string; array storage remains dynamic.

utf8_string.reader() -> binary::reader

Every engine · copy

Creates an independent reader cursor over these bytes.

utf8_string.remove_prefix(count: int) -> Self

Every engine · mutate

utf8_string.remove_suffix(count: int) -> Self

Every engine · mutate

utf8_string.repeat(count: int) -> Self

Every engine · mutate

Repeats receiver and returns text for chaining.

utf8_string.replace(from: text, to: text) -> Self

Every engine · mutate

Replaces every occurrence of from, left to right and without overlap.

utf8_string.replace_first(from: text, to: text) -> Self

Every engine · mutate

utf8_string.replace_last(from: text, to: text) -> Self

Every engine · mutate

utf8_string.reverse() -> Self

Every engine · mutate

utf8_string.rfind(needle: text, start: int = end) -> int

Every engine · observe

-1 if absent.

utf8_string.size() -> int

Every engine · observe

Bytes on string; characters on utf8_string.

utf8_string.split(separator: text = whitespace, max_splits: int = -1) -> array<var>

Every engine · copy

Whitespace runs by default; empty separator splits characters. Negative limit is unlimited; last piece retains rest. UTF-8 receiver yields UTF-8 text values.

utf8_string.starts_with(prefix: text) -> bool

Every engine · observe

utf8_string.substr(start: int, count: int = remaining) -> Self

Every engine · copy

Second argument is count, not end index.

utf8_string.to_bytes(offset: int = 0, count: int = remaining) -> array<uint8>

Every engine · copy

Offsets/counts are raw bytes even for utf8_string.

utf8_string.to_float(fallback: var = null) -> float or fallback

Every engine · observe

Whole trimmed parse; parse failure returns fallback.

utf8_string.to_int(fallback: var = null, base: int = 10) -> int or fallback

Every engine · observe

Whole trimmed parse; base is 0 or 2..36; parse failure returns fallback.

utf8_string.to_lower() -> Self

Every engine · mutate

ASCII case conversion; returns text for chaining.

utf8_string.to_upper() -> Self

Every engine · mutate

ASCII case conversion; returns text for chaining.

utf8_string.trim(characters: text = string::whitespace) -> Self

Every engine · mutate

Mutates using the shared whitespace set by default: space, tab, LF, VT, FF and CR. Returns the receiver.

utf8_string.trim_left(characters: text = string::whitespace) -> Self

Every engine · mutate

Mutates using the shared whitespace set by default: space, tab, LF, VT, FF and CR. Returns the receiver.

utf8_string.trim_right(characters: text = string::whitespace) -> Self

Every engine · mutate

Mutates using the shared whitespace set by default: space, tab, LF, VT, FF and CR. Returns the receiver.

utf8_string.utf8_chars() -> array<var>

Every engine · copy

Returned text values are utf8_string; array storage remains dynamic.

utf8_string.utf8_length() -> int

Every engine · observe

Counts decoded UTF-8 characters.

weak_ptr<T>

weak_ptr<T>.expired() -> bool

Every engine · observe

weak_ptr<T>.lock() -> shared_ptr<T> or null

Every engine · observe

Pins a surviving target.

weak_ptr<T>.reset() -> void

Every engine · mutate

Empties the weak handle its receiver names, as C++ w.reset() does; the object is untouched.

weak_ptr<T>.same_as(other: var) -> bool

Every engine · observe

web

web::build_query(fields: map) -> string

register_web() · copy

Keys and values form-encoded in the map's key order; a number or bool as to_string writes it, an array repeats its key, a null value is left out; anything else raises.

jaiscript
print(web::build_query({"q": "jai script", "page": 2, "tags": ["a", "b c"], "skip": null}));
output
page=2&q=jai+script&tags=a&tags=b+c

web::form_decode(text: text) -> string

register_web() · copy

url_decode that also reads + as a space.

jaiscript
print(web::form_decode("two+words+%26+more"));
output
two words & more

web::form_encode(text: text) -> string

register_web() · copy

application/x-www-form-urlencoded (urlencode): A-Z a-z 0-9 * - . _ stay, a space is +, every other byte is %XX.

jaiscript
print(web::form_encode("two words & more"));
output
two+words+%26+more

web::html_escape(value: text) -> same_text_kind

register_web() · copy

Writes & < > " ' as &amp; &lt; &gt; &quot; &#39; (htmlspecialchars with ENT_QUOTES); every other byte, UTF-8 included, is kept.

jaiscript
print(web::html_escape("<a title=\"Tom & Jerry's\">"));
output
&lt;a title=&quot;Tom &amp; Jerry&#39;s&quot;&gt;

web::html_unescape(value: text) -> same_text_kind

register_web() · copy

Reads the HTML5 named references (legacy names without the ;, longest match) and numeric ones as a browser does in text; 0, surrogates and values past U+10FFFF become U+FFFD; anything else is kept.

jaiscript
print(web::html_unescape("&lt;b&gt; &copy &#x41;&#66; &bogus;"));
output
<b> © AB &bogus;

web::parse_query(query: text) -> map<string, string>

register_web() · copy

Pairs split on &, form-decoded; a leading ? is skipped, a key without = is empty, an empty key is dropped, a repeated key keeps its last value.

jaiscript
print(to_json(web::parse_query("?page=2&tag=a+b&tag=c&empty")));
output
{"empty":"","page":"2","tag":"c"}

web::parse_query_all(query: text) -> map<string, var>

register_web() · copy

parse_query keeping every value of a key, an array<string> in arrival order.

jaiscript
print(to_json(web::parse_query_all("tag=a+b&tag=c")));
output
{"tag":["a b","c"]}

web::parse_url(url: text) -> web::url

register_web() · copy

An RFC 3986 URI reference split as written: scheme, user, password, host, port (0 for none), path, query, fragment; a malformed host or port raises.

jaiscript
web::url u = web::parse_url("https://snapjaw.example:8443/posts/7?sort=new#comments");
print(u.host, " ", u.port, " ", u.path, " ", u.query);
output
snapjaw.example 8443 /posts/7 sort=new

web::url_decode(text: text) -> string

register_web() · copy

Each %XX becomes its byte; a % without two hex digits stays as written; + stays a +.

jaiscript
print(web::url_decode("Snap%20Jaw%2FSocial%3F"));
output
Snap Jaw/Social?

web::url_encode(text: text) -> string

register_web() · copy

RFC 3986 percent-encoding (rawurlencode): A-Z a-z 0-9 - . _ ~ stay, every other byte is %XX in upper-case hex.

jaiscript
print(web::url_encode("Snap Jaw/Social? & more"));
output
Snap%20Jaw%2FSocial%3F%20%26%20more

web::url

web::url.to_string() -> string

register_web() · observe

The URL the fields spell: // and the authority when there is a host, a user or a port; ? and # before a non-empty query and fragment.

jaiscript
web::url u = web::parse_url("http://a.example/x?y=1");
u.path = "/z";
print(u.to_string());
output
http://a.example/z?y=1

Fields, constants, and tokens

NameTypeAccess / providerContract
NetChannel.on_connectSignalreceiver view / runnerPackets carry bytes; disconnect carries reason; connect has no payload.
NetChannel.on_disconnectSignalreceiver view / runnerPackets carry bytes; disconnect carries reason; connect has no payload.
NetChannel.on_packetSignalreceiver view / runnerPackets carry bytes; disconnect carries reason; connect has no payload.
NetServer.on_client_connectSignalreceiver view / runnerPayload starts with client id, then bytes or reason where applicable.
NetServer.on_client_disconnectSignalreceiver view / runnerPayload starts with client id, then bytes or reason where applicable.
NetServer.on_client_packetSignalreceiver view / runnerPayload starts with client id, then bytes or reason where applicable.
binary::float32binary::widthconstant / core
binary::float64binary::widthconstant / core
binary::int16binary::widthconstant / core
binary::int32binary::widthconstant / core
binary::int64binary::widthconstant / core
binary::int8binary::widthconstant / core
binary::uint16binary::widthconstant / core
binary::uint32binary::widthconstant / core
binary::uint8binary::widthconstant / core
caught error.columnintread-only / coreAvailable on the caught error value, not ordinary text.
caught error.filestringread-only / coreAvailable on the caught error value, not ordinary text.
caught error.lineintread-only / coreAvailable on the caught error value, not ordinary text.
caught error.messagestringread-only / coreAvailable on the caught error value, not ordinary text.
caught error.stackarray<string>read-only / coreAvailable on the caught error value, not ordinary text.
caught error.valuevarread-only / coreAvailable on the caught error value, not ordinary text.
ARGSarray<string>read/write / runnerArguments following --, not the executable flags.
skip_flushprint tokenconstant / stdlib
skip_newlineprint tokenconstant / stdlib
jai::filesystemint privilege flagconstant / core
jai::forceimport directiveconstant / coreTrailing argument to import(paths, jai::force).
math::Efloatconstant / coreEngine-core math constant; use math::E.
math::PIfloatconstant / coreEngine-core math constant; use math::PI.
math::color.afloatread/write / corefloat32 component.
math::color.bfloatread/write / corefloat32 component.
math::color.gfloatread/write / corefloat32 component.
math::color.rfloatread/write / corefloat32 component.
math::ivec2.heightintread/write / coreAlias of corresponding component.
math::ivec2.widthintread/write / coreAlias of corresponding component.
math::ivec2.xintread/write / coreComponent narrows to int32 or float32.
math::ivec2.yintread/write / coreComponent narrows to int32 or float32.
math::ivec3.depthintread/write / coreAlias of corresponding component.
math::ivec3.heightintread/write / coreAlias of corresponding component.
math::ivec3.widthintread/write / coreAlias of corresponding component.
math::ivec3.xintread/write / coreComponent narrows to int32 or float32.
math::ivec3.yintread/write / coreComponent narrows to int32 or float32.
math::ivec3.zintread/write / coreComponent narrows to int32 or float32.
math::vec2.heightfloatread/write / coreAlias of corresponding component.
math::vec2.widthfloatread/write / coreAlias of corresponding component.
math::vec2.xfloatread/write / coreComponent narrows to int32 or float32.
math::vec2.yfloatread/write / coreComponent narrows to int32 or float32.
math::vec3.depthfloatread/write / coreAlias of corresponding component.
math::vec3.heightfloatread/write / coreAlias of corresponding component.
math::vec3.widthfloatread/write / coreAlias of corresponding component.
math::vec3.xfloatread/write / coreComponent narrows to int32 or float32.
math::vec3.yfloatread/write / coreComponent narrows to int32 or float32.
math::vec3.zfloatread/write / coreComponent narrows to int32 or float32.
math::vec4.depthfloatread/write / coreAlias of corresponding component.
math::vec4.heightfloatread/write / coreAlias of corresponding component.
math::vec4.wfloatread/write / coreComponent narrows to int32 or float32.
math::vec4.widthfloatread/write / coreAlias of corresponding component.
math::vec4.xfloatread/write / coreComponent narrows to int32 or float32.
math::vec4.yfloatread/write / coreComponent narrows to int32 or float32.
math::vec4.zfloatread/write / coreComponent narrows to int32 or float32.
pair.firstvarread/write / stdlibMap iteration keys remain protected from mutation.
pair.secondvarread/write / stdlibMap iteration keys remain protected from mutation.
random.statestringread/write / stdlibThe generator's state as 64 hex digits; storing it resumes the stream exactly.
regex.flagsstringread-only / core
regex.patternstringread-only / coreSaved by to_json and from_json.
spider::Response.bodystringread/write / stdlib
spider::Response.cookiesarray<string>read/write / stdlibThe Set-Cookie lines, one per cookie.
spider::Response.headersmap<string, string>read/write / stdlibA received answer's names lowercased, repeats joined with ", ".
spider::Response.statusintread/write / stdlibThe status code.
spider::Response.urlstringread/write / stdlibThe URL that answered, after redirects.
string::whitespacestringconstant / stdlibSpace, tab, LF, VT, FF, CR; split() whitespace sentinel.
time::date.dayintread/write / stdlibValidated calendar field.
time::date.hourintread/write / stdlibValidated calendar field.
time::date.millisecondintread/write / stdlibValidated calendar field.
time::date.minuteintread/write / stdlibValidated calendar field.
time::date.monthintread/write / stdlibValidated calendar field.
time::date.secondintread/write / stdlibValidated calendar field.
time::date.utcboolread-only / stdlib
time::date.weekdayintread-only / stdlib
time::date.yearintread/write / stdlibValidated calendar field.
time::date.yeardayintread-only / stdlib
web::url.fragmentstringread/write / stdlibweb::parse_url's part, as written
web::url.hoststringread/write / stdlibweb::parse_url's part, as written
web::url.passwordstringread/write / stdlibweb::parse_url's part, as written
web::url.pathstringread/write / stdlibweb::parse_url's part, as written
web::url.portintread/write / stdlib0 when the URL names no port
web::url.querystringread/write / stdlibweb::parse_url's part, as written
web::url.schemestringread/write / stdlibweb::parse_url's part, as written
web::url.userstringread/write / stdlibweb::parse_url's part, as written