diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml
index 6c6eeda..6f88893 100644
--- a/.github/workflows/gh-pages.yml
+++ b/.github/workflows/gh-pages.yml
@@ -1,4 +1,5 @@
name: Build and deploy Github pages
+
on:
push:
branches:
@@ -14,18 +15,53 @@ jobs:
build:
name: Build mdBook
runs-on: ubuntu-latest
- steps:
- # Checkout
- - uses: actions/checkout@master
- # Build & deploy
- - name: build mdBook page
+ steps:
+ # Checkout code
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ # Cache Rust toolchain
+ - name: Cache Rust toolchain
+ uses: actions/cache@v2
+ with:
+ path: ~/.cargo
+ key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-rust-
+
+ # Install Rust
+ - name: Install Rust
+ run: |
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+ source $HOME/.cargo/env
+
+ # Cache Cargo registry and git directory
+ - name: Cache Cargo registry and git
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-cargo-
+
+ # Generate module docs
+ - name: Generate module docs
+ run: cargo run --release -p generate-rhai-docs
+
+ # Build mdBook
+ - name: Build mdBook page
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: "0.4.52"
- - run: mdbook build docs
- - name: Deploy
+ - name: Run mdBook build
+ run: mdbook build docs
+
+ # Deploy to GitHub Pages
+ - name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/docs/src/modules/apilib.md b/docs/src/modules/apilib.md
index f0e02fd..1595b41 100644
--- a/docs/src/modules/apilib.md
+++ b/docs/src/modules/apilib.md
@@ -1,471 +1 @@
-# wifi
-
-```Namespace: global/api/wifi```
-
-
-
fn connect
-
-```rust,ignore
-fn connect(ssid: String, password: String)
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Connects to a Wi-Fi network with the specified SSID and password.
-
-
-
-* `ssid` - The SSID of the Wi-Fi network.
-* `password` - The password of the Wi-Fi network (optional for open networks).
-
-
-
-Returns nothing if the connection is successful, or an error message if it fails.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-wifi::connect("MySecretNetwork", "password123");
-```
-
-
-
-
-
-
-
fn connect_without_password
-
-```rust,ignore
-fn connect_without_password(ssid: String)
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Connects to a Wi-Fi network with the specified SSID using saved profile (no password required).
-
-
-
-* `ssid` - The SSID of the Wi-Fi network.
-
-
-
-Returns nothing if the connection is successful, or an error message if it fails.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-wifi::connect_without_password("MySecretNetwork", "password123");
-```
-
-
-
-
-
-
-
fn current_connection
-
-```rust,ignore
-fn current_connection() -> Map
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Retrieves the current active Wi-Fi connection's details (SSID, signal, and security).
-
-
-
-This function does not require any arguments.
-
-
-
-A `Map` containing the current connection's SSID, signal strength, and security type.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-let connection = wifi::current_connection();
-```
-
-
-
-
-
-
-
fn disable_adapter
-
-```rust,ignore
-fn disable_adapter()
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Disables the Wi-Fi adapter.
-
-
-
-This function does not require any arguments.
-
-
-
-Returns nothing if the connection is successful, or an error message if it fails.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-wifi::disable_adapter();
-```
-
-
-
-
-
-
-
fn disconnect
-
-```rust,ignore
-fn disconnect()
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Disconnects from the current Wi-Fi network.
-
-
-
-This function does not require any arguments.
-
-
-
-Returns nothing if the connection is successful, or an error message if it fails.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-wifi::disconnect();
-```
-
-
-
-
-
-
-
fn enable_adapter
-
-```rust,ignore
-fn enable_adapter()
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Enables the Wi-Fi adapter.
-
-
-
-This function does not require any arguments.
-
-
-
-Returns nothing if the connection is successful, or an error message if it fails.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-wifi::enable_adapter();
-```
-
-
-
-
-
-
-
fn get_adapter_connectivity
-
-```rust,ignore
-fn get_adapter_connectivity() -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the currenet state of adapter.
-
-
-
-This function does not require any arguments.
-
-
-
-Returns the state of the adapter as a `string` and returns an error if getting the state failed.
-
-**Possible returns in Linux:**
-
-- `"full"` (internet available)
-- `"limited"` (network only, no internet)
-- `"portal"` (captive portal)
-- `"none"` (no connectivity)
-
-**Possible returns in macOS:**
-
-- `"full"` (connected to a Wi-Fi network)
-- `"none"` (not connected)
-
-
-
-```js
-import "api::wifi" as wifi;
-
-wifi::enable_adapter();
-```
-
-
-
-
-
-
-
fn scan
-
-```rust,ignore
-fn scan() -> Array
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Scans for all available Wi-Fi connections, platform-dependent (Linux or macOS).
-
-
-
-This function does not require any arguments.
-
-
-
-An `Array` containing information about each Wi-Fi connection, where each entry is a `Map`
-with keys "ssid", "signal", and "security" representing the Wi-Fi network's SSID, signal strength,
-and security type.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-let networks = wifi::scan();
-```
-
-
-
-
-
-
-
fn scan_linux
-
-```rust,ignore
-fn scan_linux() -> Array
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Scans for all available Wi-Fi connections on Linux.
-
-
-
-This function does not require any arguments.
-
-
-
-An `Array` containing information about each Wi-Fi connection, where each entry is a `Map`
-with keys "ssid", "signal", and "security" representing the Wi-Fi network's SSID, signal strength,
-and security type.
-
-
-
-```js
-import "api::wifi" as wifi;
-
-let networks = wifi::scan();
-```
-
-
-
-
-
+# API Library
diff --git a/docs/src/modules/global.md b/docs/src/modules/global.md
index ecb5bdf..6bb60d1 100644
--- a/docs/src/modules/global.md
+++ b/docs/src/modules/global.md
@@ -1,6682 +1 @@
-# global
-
-```Namespace: global```
-
-
-
op !=
-
-```rust,ignore
-op Map != Map -> bool
-op i32 != i32 -> bool
-op u8 != u8 -> bool
-op u128 != u128 -> bool
-op i128 != i128 -> bool
-op u64 != u64 -> bool
-op Instant != Instant -> bool
-op Array != Array -> bool
-op int != f32 -> bool
-op i8 != i8 -> bool
-op u16 != u16 -> bool
-op u32 != u32 -> bool
-op f32 != f32 -> bool
-op f32 != int -> bool
-op i16 != i16 -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if two object maps are not equal (i.e. at least one property value is not equal).
-
-The operator `==` is used to compare property values and must be defined,
-otherwise `false` is assumed.
-
-
-
-```rhai
-let m1 = #{a:1, b:2, c:3};
-let m2 = #{a:1, b:2, c:3};
-let m3 = #{a:1, c:3};
-
-print(m1 != m2); // prints false
-
-print(m1 != m3); // prints true
-```
-
-
-
-
-
-
-
fn +
-
-```rust,ignore
-fn +(x: f32) -> f32
-fn +(x: float) -> float
-fn +(x: i16) -> i16
-fn +(x: int) -> int
-fn +(x: i8) -> i8
-fn +(x: i128) -> i128
-fn +(x: i32) -> i32
-fn +(x: i16, y: i16) -> i16
-fn +(x: f32, y: f32) -> f32
-fn +(x: f32, y: int) -> f32
-fn +(timestamp: Instant, seconds: int) -> Instant
-fn +(x: u32, y: u32) -> u32
-fn +(item: ?, string: String) -> String
-fn +(character: char, string: String) -> String
-fn +(x: u16, y: u16) -> u16
-fn +(string: String, character: char) -> String
-fn +(utf8: Blob, string: String) -> String
-fn +(timestamp: Instant, seconds: float) -> Instant
-fn +(x: i8, y: i8) -> i8
-fn +(array1: Array, array2: Array) -> Array
-fn +(x: int, y: f32) -> f32
-fn +(item: ?, string: String) -> String
-fn +(x: u64, y: u64) -> u64
-fn +(string: String, item: ?) -> String
-fn +(string: String, mut item: ?) -> String
-fn +(x: u128, y: u128) -> u128
-fn +(x: i128, y: i128) -> i128
-fn +(x: u8, y: u8) -> u8
-fn +(map1: Map, map2: Map) -> Map
-fn +(x: i32, y: i32) -> i32
-fn +(string: String, utf8: Blob) -> String
-fn +(string1: String, string2: String) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Add the specified number of `seconds` to the timestamp and return it as a new timestamp.
-
-
-
-
-
-
-
fn +=
-
-```rust,ignore
-fn +=(map: Map, map2: Map)
-fn +=(string1: String, string2: String)
-fn +=(string: String, utf8: Blob)
-fn +=(string: String, item: ?)
-fn +=(string: String, mut item: ?)
-fn +=(string: String, character: char)
-fn +=(timestamp: Instant, seconds: float)
-fn +=(timestamp: Instant, seconds: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Add all property values of another object map into the object map.
-Existing property values of the same names are replaced.
-
-
-
-```rhai
-let m = #{a:1, b:2, c:3};
-let n = #{a: 42, d:0};
-
-m.mixin(n);
-
-print(m); // prints "#{a:42, b:2, c:3, d:0}"
-```
-
-
-
-
-
-
-
fn -
-
-```rust,ignore
-fn -(x: i16) -> i16
-fn -(x: float) -> float
-fn -(x: f32) -> f32
-fn -(x: i32) -> i32
-fn -(x: i128) -> i128
-fn -(x: i8) -> i8
-fn -(x: int) -> int
-fn -(x: u32, y: u32) -> u32
-fn -(x: u16, y: u16) -> u16
-fn -(timestamp: Instant, seconds: float) -> Instant
-fn -(x: i8, y: i8) -> i8
-fn -(x: i16, y: i16) -> i16
-fn -(timestamp: Instant, seconds: int) -> Instant
-fn -(x: f32, y: f32) -> f32
-fn -(x: f32, y: int) -> f32
-fn -(x: i128, y: i128) -> i128
-fn -(x: u128, y: u128) -> u128
-fn -(x: u8, y: u8) -> u8
-fn -(x: i32, y: i32) -> i32
-fn -(x: int, y: f32) -> f32
-fn -(timestamp1: Instant, timestamp2: Instant) -> ?
-fn -(x: u64, y: u64) -> u64
-```
-
-
-
-
-Description
-
-
-
-
-Subtract the specified number of `seconds` from the timestamp and return it as a new timestamp.
-
-
-
-
-
-
-
fn -=
-
-```rust,ignore
-fn -=(timestamp: Instant, seconds: int)
-fn -=(timestamp: Instant, seconds: float)
-```
-
-
-
-
-Description
-
-
-
-
-Subtract the specified number of `seconds` from the timestamp.
-
-
-
-
-
-
-
op <
-
-```rust,ignore
-op u128 < u128 -> bool
-op i128 < i128 -> bool
-op u8 < u8 -> bool
-op i32 < i32 -> bool
-op int < f32 -> bool
-op Instant < Instant -> bool
-op u64 < u64 -> bool
-op u32 < u32 -> bool
-op u16 < u16 -> bool
-op i8 < i8 -> bool
-op i16 < i16 -> bool
-op f32 < f32 -> bool
-op f32 < int -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the first timestamp is earlier than the second.
-
-
-
-
-
-
-
op <=
-
-```rust,ignore
-op u16 <= u16 -> bool
-op i8 <= i8 -> bool
-op u32 <= u32 -> bool
-op f32 <= int -> bool
-op f32 <= f32 -> bool
-op i16 <= i16 -> bool
-op i32 <= i32 -> bool
-op u128 <= u128 -> bool
-op i128 <= i128 -> bool
-op u8 <= u8 -> bool
-op u64 <= u64 -> bool
-op int <= f32 -> bool
-op Instant <= Instant -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the first timestamp is earlier than or equals to the second.
-
-
-
-
-
-
-
op ==
-
-```rust,ignore
-op i128 == i128 -> bool
-op u128 == u128 -> bool
-op u8 == u8 -> bool
-op i32 == i32 -> bool
-op Map == Map -> bool
-op int == f32 -> bool
-op Array == Array -> bool
-op Instant == Instant -> bool
-op u64 == u64 -> bool
-op u32 == u32 -> bool
-op u16 == u16 -> bool
-op i8 == i8 -> bool
-op i16 == i16 -> bool
-op f32 == int -> bool
-op f32 == f32 -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if two object maps are equal (i.e. all property values are equal).
-
-The operator `==` is used to compare property values and must be defined,
-otherwise `false` is assumed.
-
-
-
-```rhai
-let m1 = #{a:1, b:2, c:3};
-let m2 = #{a:1, b:2, c:3};
-let m3 = #{a:1, c:3};
-
-print(m1 == m2); // prints true
-
-print(m1 == m3); // prints false
-```
-
-
-
-
-
-
-
op >
-
-```rust,ignore
-op i128 > i128 -> bool
-op u128 > u128 -> bool
-op u8 > u8 -> bool
-op i32 > i32 -> bool
-op int > f32 -> bool
-op Instant > Instant -> bool
-op u64 > u64 -> bool
-op u32 > u32 -> bool
-op u16 > u16 -> bool
-op i8 > i8 -> bool
-op i16 > i16 -> bool
-op f32 > int -> bool
-op f32 > f32 -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the first timestamp is later than the second.
-
-
-
-
-
-
-
op >=
-
-```rust,ignore
-op f32 >= int -> bool
-op f32 >= f32 -> bool
-op i16 >= i16 -> bool
-op u16 >= u16 -> bool
-op i8 >= i8 -> bool
-op u32 >= u32 -> bool
-op u64 >= u64 -> bool
-op int >= f32 -> bool
-op Instant >= Instant -> bool
-op i32 >= i32 -> bool
-op u128 >= u128 -> bool
-op i128 >= i128 -> bool
-op u8 >= u8 -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the first timestamp is later than or equals to the second.
-
-
-
-
-
-
-
get/set ?.tag
-
-```rust,ignore
-get ?.tag -> int
-set ?.tag = int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the _tag_ of a `Dynamic` value.
-
-
-
-```rhai
-let x = "hello, world!";
-
-x.tag = 42;
-
-print(x.tag); // prints 42
-```
-
-
-
-
-
-
-
get/set Array.is_empty
-
-```rust,ignore
-get Array.is_empty -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the array is empty.
-
-
-
-
-
-
-
get/set Array.len
-
-```rust,ignore
-get Array.len -> int
-```
-
-
-
-
-Description
-
-
-
-
-Number of elements in the array.
-
-
-
-
-
-
-
get/set Blob.is_empty
-
-```rust,ignore
-get Blob.is_empty -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the BLOB is empty.
-
-
-
-
-
-
-
get/set Blob.len
-
-```rust,ignore
-get Blob.len -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the length of the BLOB.
-
-
-
-```rhai
-let b = blob(10, 0x42);
-
-print(b); // prints "[4242424242424242 4242]"
-
-print(b.len()); // prints 10
-```
-
-
-
-
-
-
-
fn E
-
-```rust,ignore
-fn E() -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the natural number _e_.
-
-
-
-
-
-
-
get/set FnPtr.is_anonymous
-
-```rust,ignore
-get FnPtr.is_anonymous -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if the function is an anonymous function.
-
-
-
-```rhai
-let f = |x| x * 2;
-
-print(f.is_anonymous); // prints true
-```
-
-
-
-
-
-
-
get/set FnPtr.name
-
-```rust,ignore
-get FnPtr.name -> String
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the name of the function.
-
-
-
-```rhai
-fn double(x) { x * 2 }
-
-let f = Fn("double");
-
-print(f.name); // prints "double"
-```
-
-
-
-
-
-
-
get/set Instant.elapsed
-
-```rust,ignore
-get Instant.elapsed -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the number of seconds between the current system time and the timestamp.
-
-
-
-```rhai
-let now = timestamp();
-
-sleep(10.0); // sleep for 10 seconds
-
-print(now.elapsed); // prints 10.???
-```
-
-
-
-
-
-
-
fn PI
-
-```rust,ignore
-fn PI() -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the number π.
-
-
-
-
-
-
-
get/set Range<int>.end
-
-```rust,ignore
-get Range
.end -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the end of the exclusive range.
-
-
-
-
-
-
-
get/set Range<int>.is_empty
-
-```rust,ignore
-get Range
.is_empty -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the range contains no items.
-
-
-
-
-
-
-
get/set Range<int>.is_exclusive
-
-```rust,ignore
-get Range
.is_exclusive -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the range is exclusive.
-
-
-
-
-
-
-
get/set Range<int>.is_inclusive
-
-```rust,ignore
-get Range
.is_inclusive -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the range is inclusive.
-
-
-
-
-
-
-
get/set Range<int>.start
-
-```rust,ignore
-get Range
.start -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the start of the exclusive range.
-
-
-
-
-
-
-
get/set RangeInclusive<int>.end
-
-```rust,ignore
-get RangeInclusive
.end -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the end of the inclusive range.
-
-
-
-
-
-
-
get/set RangeInclusive<int>.is_empty
-
-```rust,ignore
-get RangeInclusive
.is_empty -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the range contains no items.
-
-
-
-
-
-
-
get/set RangeInclusive<int>.is_exclusive
-
-```rust,ignore
-get RangeInclusive
.is_exclusive -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the range is exclusive.
-
-
-
-
-
-
-
get/set RangeInclusive<int>.is_inclusive
-
-```rust,ignore
-get RangeInclusive
.is_inclusive -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the range is inclusive.
-
-
-
-
-
-
-
get/set RangeInclusive<int>.start
-
-```rust,ignore
-get RangeInclusive
.start -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the start of the inclusive range.
-
-
-
-
-
-
-
get/set String.bytes
-
-```rust,ignore
-get String.bytes -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the length of the string, in number of bytes used to store it in UTF-8 encoding.
-
-
-
-```rhai
-let text = "朝には紅顔ありて夕べには白骨となる";
-
-print(text.bytes); // prints 51
-```
-
-
-
-
-
-
-
get/set String.chars
-
-```rust,ignore
-get String.chars -> CharsStream
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an iterator over all the characters in the string.
-
-
-
-```rhai
-for ch in "hello, world!".chars {"
- print(ch);
-}
-```
-
-
-
-
-
-
-
get/set String.is_empty
-
-```rust,ignore
-get String.is_empty -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the string is empty.
-
-
-
-
-
-
-
get/set String.len
-
-```rust,ignore
-get String.len -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the length of the string, in number of characters.
-
-
-
-```rhai
-let text = "朝には紅顔ありて夕べには白骨となる";
-
-print(text.len); // prints 17
-```
-
-
-
-
-
-
-
fn abs
-
-```rust,ignore
-fn abs(x: f32) -> f32
-fn abs(x: i16) -> i16
-fn abs(x: float) -> float
-fn abs(x: i128) -> i128
-fn abs(x: i32) -> i32
-fn abs(x: int) -> int
-fn abs(x: i8) -> i8
-```
-
-
-
-
-Description
-
-
-
-
-Return the absolute value of the floating-point number.
-
-
-
-
-
-
-
fn acos
-
-```rust,ignore
-fn acos(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the arc-cosine of the floating-point number, in radians.
-
-
-
-
-
-
-
fn acosh
-
-```rust,ignore
-fn acosh(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the arc-hyperbolic-cosine of the floating-point number, in radians.
-
-
-
-
-
-
-
fn all
-
-```rust,ignore
-fn all(array: Array, filter: String) -> bool
-fn all(array: Array, filter: FnPtr) -> bool
-```
-
-
-
-
-Description
-
-
-Deprecated API
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Return `true` if all elements in the array return `true` when applied a function named by `filter`.
-
-
-
-This method is deprecated and will be removed from the next major version.
-Use `array.all(Fn("fn_name"))` instead.
-
-
-
-A function with the same name as the value of `filter` must exist taking these parameters:
-
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5];
-
-print(x.all(|v| v > 3)); // prints false
-
-print(x.all(|v| v > 1)); // prints true
-
-print(x.all(|v, i| i > v)); // prints false
-```
-
-
-
-
-
-
-
fn append
-
-```rust,ignore
-fn append(blob1: Blob, blob2: Blob)
-fn append(string: String, utf8: Blob)
-fn append(array: Array, new_array: Array)
-fn append(string: String, mut item: ?)
-fn append(blob: Blob, value: int)
-fn append(blob: Blob, string: String)
-fn append(blob: Blob, character: char)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Add another BLOB to the end of the BLOB.
-
-
-
-```rhai
-let b1 = blob(5, 0x42);
-let b2 = blob(3, 0x11);
-
-b1.push(b2);
-
-print(b1); // prints "[4242424242111111]"
-```
-
-
-
-
-
-
-
fn as_string
-
-```rust,ignore
-fn as_string(blob: Blob) -> String
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the BLOB into a string.
-
-The byte stream must be valid UTF-8, otherwise an error is raised.
-
-
-
-```rhai
-let b = blob(5, 0x42);
-
-let x = b.as_string();
-
-print(x); // prints "FFFFF"
-```
-
-
-
-
-
-
-
fn asin
-
-```rust,ignore
-fn asin(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the arc-sine of the floating-point number, in radians.
-
-
-
-
-
-
-
fn asinh
-
-```rust,ignore
-fn asinh(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the arc-hyperbolic-sine of the floating-point number, in radians.
-
-
-
-
-
-
-
fn atan
-
-```rust,ignore
-fn atan(x: float) -> float
-fn atan(x: float, y: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the arc-tangent of the floating-point number, in radians.
-
-
-
-
-
-
-
fn atanh
-
-```rust,ignore
-fn atanh(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the arc-hyperbolic-tangent of the floating-point number, in radians.
-
-
-
-
-
-
-
fn bits
-
-```rust,ignore
-fn bits(value: int) -> BitRange
-fn bits(value: int, range: Range
) -> BitRange
-fn bits(value: int, from: int) -> BitRange
-fn bits(value: int, range: RangeInclusive) -> BitRange
-fn bits(value: int, from: int, len: int) -> BitRange
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an iterator over all the bits in the number.
-
-
-
-```rhai
-let x = 123456;
-
-for bit in x.bits() {
- print(bit);
-}
-```
-
-
-
-
-
-
-
fn blob
-
-```rust,ignore
-fn blob() -> Blob
-fn blob(len: int) -> Blob
-fn blob(len: int, value: int) -> Blob
-```
-
-
-
-
-Description
-
-
-
-
-Return a new, empty BLOB.
-
-
-
-
-
-
-
fn bytes
-
-```rust,ignore
-fn bytes(string: String) -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the length of the string, in number of bytes used to store it in UTF-8 encoding.
-
-
-
-```rhai
-let text = "朝には紅顔ありて夕べには白骨となる";
-
-print(text.bytes); // prints 51
-```
-
-
-
-
-
-
-
fn ceiling
-
-```rust,ignore
-fn ceiling(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the smallest whole number larger than or equals to the floating-point number.
-
-
-
-
-
-
-
fn chars
-
-```rust,ignore
-fn chars(string: String) -> CharsStream
-fn chars(string: String, start: int) -> CharsStream
-fn chars(string: String, range: RangeInclusive
) -> CharsStream
-fn chars(string: String, range: Range) -> CharsStream
-fn chars(string: String, start: int, len: int) -> CharsStream
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an iterator over the characters in the string.
-
-
-
-```rhai
-for ch in "hello, world!".chars() {
- print(ch);
-}
-```
-
-
-
-
-
-
-
fn chop
-
-```rust,ignore
-fn chop(array: Array, len: int)
-fn chop(blob: Blob, len: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Cut off the head of the array, leaving a tail of the specified length.
-
-* If `len` ≤ 0, the array is cleared.
-* If `len` ≥ length of array, the array is not modified.
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-
-x.chop(3);
-
-print(x); // prints "[3, 4, 5]"
-
-x.chop(10);
-
-print(x); // prints "[3, 4, 5]"
-```
-
-
-
-
-
-
-
fn clear
-
-```rust,ignore
-fn clear(map: Map)
-fn clear(array: Array)
-fn clear(blob: Blob)
-fn clear(string: String)
-```
-
-
-
-
-Description
-
-
-
-
-Clear the object map.
-
-
-
-
-
-
-
fn contains
-
-```rust,ignore
-fn contains(blob: Blob, value: int) -> bool
-fn contains(range: Range
, value: int) -> bool
-fn contains(string: String, character: char) -> bool
-fn contains(array: Array, value: ?) -> bool
-fn contains(range: RangeInclusive, value: int) -> bool
-fn contains(string: String, match_string: String) -> bool
-fn contains(map: Map, property: String) -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if the BLOB contains a specified byte value.
-
-
-
-```rhai
-let text = "hello, world!";
-
-print(text.contains('h')); // prints true
-
-print(text.contains('x')); // prints false
-```
-
-
-
-
-
-
-
fn cos
-
-```rust,ignore
-fn cos(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the cosine of the floating-point number in radians.
-
-
-
-
-
-
-
fn cosh
-
-```rust,ignore
-fn cosh(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the hyperbolic cosine of the floating-point number in radians.
-
-
-
-
-
-
-
fn crop
-
-```rust,ignore
-fn crop(string: String, start: int)
-fn crop(string: String, range: RangeInclusive
)
-fn crop(string: String, range: Range)
-fn crop(string: String, start: int, len: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove all characters from the string up to the `start` position.
-
-* If `start` < 0, position counts from the end of the string (`-1` is the last character).
-* If `start` < -length of string, the string is not modified.
-* If `start` ≥ length of string, the entire string is cleared.
-
-
-
-```rhai
-let text = "hello, world!";
-
-text.crop(5);
-
-print(text); // prints ", world!"
-
-text.crop(-3);
-
-print(text); // prints "ld!"
-```
-
-
-
-
-
-
-
fn debug
-
-```rust,ignore
-fn debug() -> String
-fn debug(value: bool) -> String
-fn debug(f: FnPtr) -> String
-fn debug(character: char) -> String
-fn debug(array: Array) -> String
-fn debug(unit: ?) -> String
-fn debug(string: String) -> String
-fn debug(item: ?) -> String
-fn debug(map: Map) -> String
-fn debug(number: f32) -> String
-fn debug(number: float) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Return the empty string.
-
-
-
-
-
-
-
fn dedup
-
-```rust,ignore
-fn dedup(array: Array)
-fn dedup(array: Array, comparer: String)
-fn dedup(array: Array, comparer: FnPtr)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove duplicated _consecutive_ elements from the array.
-
-The operator `==` is used to compare elements and must be defined,
-otherwise `false` is assumed.
-
-
-
-```rhai
-let x = [1, 2, 2, 2, 3, 4, 3, 3, 2, 1];
-
-x.dedup();
-
-print(x); // prints "[1, 2, 3, 4, 3, 2, 1]"
-```
-
-
-
-
-
-
-
fn drain
-
-```rust,ignore
-fn drain(array: Array, range: Range
) -> Array
-fn drain(blob: Blob, range: RangeInclusive) -> Blob
-fn drain(array: Array, filter: FnPtr) -> Array
-fn drain(blob: Blob, range: Range) -> Blob
-fn drain(array: Array, range: RangeInclusive) -> Array
-fn drain(map: Map, filter: FnPtr) -> Map
-fn drain(array: Array, filter: String) -> Array
-fn drain(array: Array, start: int, len: int) -> Array
-fn drain(blob: Blob, start: int, len: int) -> Blob
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove all elements in the array within an exclusive `range` and return them as a new array.
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-
-let y = x.drain(1..3);
-
-print(x); // prints "[1, 4, 5]"
-
-print(y); // prints "[2, 3]"
-
-let z = x.drain(2..3);
-
-print(x); // prints "[1, 4]"
-
-print(z); // prints "[5]"
-```
-
-
-
-
-
-
-
fn elapsed
-
-```rust,ignore
-fn elapsed(timestamp: Instant) -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the number of seconds between the current system time and the timestamp.
-
-
-
-```rhai
-let now = timestamp();
-
-sleep(10.0); // sleep for 10 seconds
-
-print(now.elapsed); // prints 10.???
-```
-
-
-
-
-
-
-
fn end
-
-```rust,ignore
-fn end(range: RangeInclusive
) -> int
-fn end(range: Range) -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the end of the inclusive range.
-
-
-
-
-
-
-
fn ends_with
-
-```rust,ignore
-fn ends_with(string: String, match_string: String) -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if the string ends with a specified string.
-
-
-
-```rhai
-let text = "hello, world!";
-
-print(text.ends_with("world!")); // prints true
-
-print(text.ends_with("hello")); // prints false
-```
-
-
-
-
-
-
-
fn exit
-
-```rust,ignore
-fn exit() -> ?
-fn exit(value: ?) -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Exit the script evaluation immediately with `()` as exit value.
-
-
-```rhai
-exit();
-```
-
-
-
-
-
-
-
fn exp
-
-```rust,ignore
-fn exp(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the exponential of the floating-point number.
-
-
-
-
-
-
-
fn extract
-
-```rust,ignore
-fn extract(array: Array, range: RangeInclusive
) -> Array
-fn extract(blob: Blob, range: Range) -> Blob
-fn extract(array: Array, range: Range) -> Array
-fn extract(array: Array, start: int) -> Array
-fn extract(blob: Blob, start: int) -> Blob
-fn extract(blob: Blob, range: RangeInclusive) -> Blob
-fn extract(array: Array, start: int, len: int) -> Array
-fn extract(blob: Blob, start: int, len: int) -> Blob
-```
-
-
-
-
-
-
get/set f32.is_zero
-
-```rust,ignore
-get f32.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the floating-point number is zero.
-
-
-
-
-
-
-
fn fill_with
-
-```rust,ignore
-fn fill_with(map: Map, map2: Map)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Add all property values of another object map into the object map.
-Only properties that do not originally exist in the object map are added.
-
-
-
-```rhai
-let m = #{a:1, b:2, c:3};
-let n = #{a: 42, d:0};
-
-m.fill_with(n);
-
-print(m); // prints "#{a:1, b:2, c:3, d:0}"
-```
-
-
-
-
-
-
-
fn filter
-
-```rust,ignore
-fn filter(array: Array, filter: FnPtr) -> Array
-fn filter(map: Map, filter: FnPtr) -> Map
-fn filter(array: Array, filter_func: String) -> Array
-```
-
-
-
-
-Description
-
-
-No Function Parameter
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Iterate through all the elements in the array, applying a `filter` function to each element
-in turn, and return a copy of all elements (in order) that return `true` as a new array.
-
-
-
-Array element (mutable) is bound to `this`.
-
-This method is marked _pure_; the `filter` function should not mutate array elements.
-
-
-
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-
-let y = x.filter(|v| v >= 3);
-
-print(y); // prints "[3, 4, 5]"
-
-let y = x.filter(|v, i| v * i >= 10);
-
-print(y); // prints "[12, 20]"
-```
-
-
-
-
-
-
-
fn find
-
-```rust,ignore
-fn find(array: Array, filter: FnPtr) -> ?
-fn find(array: Array, filter: FnPtr, start: int) -> ?
-```
-
-
-
-
-Description
-
-
-No Function Parameter
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Iterate through all the elements in the array, applying a `filter` function to each element
-in turn, and return a copy of the first element that returns `true`. If no element returns
-`true`, `()` is returned.
-
-
-
-Array element (mutable) is bound to `this`.
-
-
-
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [1, 2, 3, 5, 8, 13];
-
-print(x.find(|v| v > 3)); // prints 5: 5 > 3
-
-print(x.find(|v| v > 13) ?? "not found"); // prints "not found": nothing is > 13
-
-print(x.find(|v, i| v * i > 13)); // prints 5: 3 * 5 > 13
-```
-
-
-
-
-
-
-
fn find_map
-
-```rust,ignore
-fn find_map(array: Array, filter: FnPtr) -> ?
-fn find_map(array: Array, filter: FnPtr, start: int) -> ?
-```
-
-
-
-
-Description
-
-
-No Function Parameter
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Iterate through all the elements in the array, applying a `mapper` function to each element
-in turn, and return the first result that is not `()`. Otherwise, `()` is returned.
-
-
-
-Array element (mutable) is bound to `this`.
-
-This method is marked _pure_; the `mapper` function should not mutate array elements.
-
-
-
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [#{alice: 1}, #{bob: 2}, #{clara: 3}];
-
-print(x.find_map(|v| v.alice)); // prints 1
-
-print(x.find_map(|v| v.dave) ?? "not found"); // prints "not found"
-
-print(x.find_map(|| this.dave) ?? "not found"); // prints "not found"
-```
-
-
-
-
-
-
-
get/set float.ceiling
-
-```rust,ignore
-get float.ceiling -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the smallest whole number larger than or equals to the floating-point number.
-
-
-
-
-
-
-
get/set float.floor
-
-```rust,ignore
-get float.floor -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the largest whole number less than or equals to the floating-point number.
-
-
-
-
-
-
-
get/set float.fraction
-
-```rust,ignore
-get float.fraction -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the fractional part of the floating-point number.
-
-
-
-
-
-
-
get/set float.int
-
-```rust,ignore
-get float.int -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the integral part of the floating-point number.
-
-
-
-
-
-
-
get/set float.is_finite
-
-```rust,ignore
-get float.is_finite -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the floating-point number is finite.
-
-
-
-
-
-
-
get/set float.is_infinite
-
-```rust,ignore
-get float.is_infinite -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the floating-point number is infinite.
-
-
-
-
-
-
-
get/set float.is_nan
-
-```rust,ignore
-get float.is_nan -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the floating-point number is `NaN` (Not A Number).
-
-
-
-
-
-
-
get/set float.is_zero
-
-```rust,ignore
-get float.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the floating-point number is zero.
-
-
-
-
-
-
-
get/set float.round
-
-```rust,ignore
-get float.round -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the nearest whole number closest to the floating-point number.
-Rounds away from zero.
-
-
-
-
-
-
-
fn floor
-
-```rust,ignore
-fn floor(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the largest whole number less than or equals to the floating-point number.
-
-
-
-
-
-
-
fn for_each
-
-```rust,ignore
-fn for_each(array: Array, map: FnPtr)
-```
-
-
-
-
-Description
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Iterate through all the elements in the array, applying a `process` function to each element in turn.
-Each element is bound to `this` before calling the function.
-
-
-
-* `this`: bound to array element (mutable)
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-
-x.for_each(|| this *= this);
-
-print(x); // prints "[1, 4, 9, 16, 25]"
-
-x.for_each(|i| this *= i);
-
-print(x); // prints "[0, 2, 6, 12, 20]"
-```
-
-
-
-
-
-
-
fn fraction
-
-```rust,ignore
-fn fraction(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the fractional part of the floating-point number.
-
-
-
-
-
-
-
fn get
-
-```rust,ignore
-fn get(blob: Blob, index: int) -> int
-fn get(array: Array, index: int) -> ?
-fn get(string: String, index: int) -> ?
-fn get(map: Map, property: String) -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Get the byte value at the `index` position in the BLOB.
-
-* If `index` < 0, position counts from the end of the BLOB (`-1` is the last element).
-* If `index` < -length of BLOB, zero is returned.
-* If `index` ≥ length of BLOB, zero is returned.
-
-
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-print(b.get(0)); // prints 1
-
-print(b.get(-1)); // prints 5
-
-print(b.get(99)); // prints 0
-```
-
-
-
-
-
-
-
fn get_bit
-
-```rust,ignore
-fn get_bit(value: int, bit: int) -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if the specified `bit` in the number is set.
-
-If `bit` < 0, position counts from the MSB (Most Significant Bit).
-
-
-
-```rhai
-let x = 123456;
-
-print(x.get_bit(5)); // prints false
-
-print(x.get_bit(6)); // prints true
-
-print(x.get_bit(-48)); // prints true on 64-bit
-```
-
-
-
-
-
-
-
fn get_bits
-
-```rust,ignore
-fn get_bits(value: int, range: RangeInclusive
) -> int
-fn get_bits(value: int, range: Range) -> int
-fn get_bits(value: int, start: int, bits: int) -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an inclusive range of bits in the number as a new number.
-
-
-
-```rhai
-let x = 123456;
-
-print(x.get_bits(5..=9)); // print 18
-```
-
-
-
-
-
-
-
fn get_fn_metadata_list
-
-```rust,ignore
-fn get_fn_metadata_list() -> Array
-fn get_fn_metadata_list(name: String) -> Array
-fn get_fn_metadata_list(name: String, params: int) -> Array
-```
-
-
-
-
-Description
-
-
-
-
-Return an array of object maps containing metadata of all script-defined functions.
-
-
-
-
-
-
-
fn hypot
-
-```rust,ignore
-fn hypot(x: float, y: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the hypotenuse of a triangle with sides `x` and `y`.
-
-
-
-
-
-
-
get/set i128.is_even
-
-```rust,ignore
-get i128.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set i128.is_odd
-
-```rust,ignore
-get i128.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set i128.is_zero
-
-```rust,ignore
-get i128.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set i16.is_even
-
-```rust,ignore
-get i16.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set i16.is_odd
-
-```rust,ignore
-get i16.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set i16.is_zero
-
-```rust,ignore
-get i16.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set i32.is_even
-
-```rust,ignore
-get i32.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set i32.is_odd
-
-```rust,ignore
-get i32.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set i32.is_zero
-
-```rust,ignore
-get i32.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set i8.is_even
-
-```rust,ignore
-get i8.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set i8.is_odd
-
-```rust,ignore
-get i8.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set i8.is_zero
-
-```rust,ignore
-get i8.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
fn index_of
-
-```rust,ignore
-fn index_of(array: Array, value: ?) -> int
-fn index_of(string: String, character: char) -> int
-fn index_of(array: Array, filter: FnPtr) -> int
-fn index_of(string: String, find_string: String) -> int
-fn index_of(array: Array, filter: String) -> int
-fn index_of(array: Array, filter: String, start: int) -> int
-fn index_of(string: String, find_string: String, start: int) -> int
-fn index_of(string: String, character: char, start: int) -> int
-fn index_of(array: Array, value: ?, start: int) -> int
-fn index_of(array: Array, filter: FnPtr, start: int) -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Find the first element in the array that equals a particular `value` and return its index.
-If no element equals `value`, `-1` is returned.
-
-The operator `==` is used to compare elements with `value` and must be defined,
-otherwise `false` is assumed.
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5];
-
-print(x.index_of(4)); // prints 3 (first index)
-
-print(x.index_of(9)); // prints -1
-
-print(x.index_of("foo")); // prints -1: strings do not equal numbers
-```
-
-
-
-
-
-
-
fn insert
-
-```rust,ignore
-fn insert(array: Array, index: int, item: ?)
-fn insert(blob: Blob, index: int, value: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Add a new element into the array at a particular `index` position.
-
-* If `index` < 0, position counts from the end of the array (`-1` is the last element).
-* If `index` < -length of array, the element is added to the beginning of the array.
-* If `index` ≥ length of array, the element is appended to the end of the array.
-
-
-
-```rhai
-let x = [1, 2, 3];
-
-x.insert(0, "hello");
-
-x.insert(2, true);
-
-x.insert(-2, 42);
-
-print(x); // prints ["hello", 1, true, 2, 42, 3]
-```
-
-
-
-
-
-
-
fn int
-
-```rust,ignore
-fn int(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the integral part of the floating-point number.
-
-
-
-
-
-
-
get/set int.bits
-
-```rust,ignore
-get int.bits -> BitRange
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an iterator over all the bits in the number.
-
-
-
-```rhai
-let x = 123456;
-
-for bit in x.bits {
- print(bit);
-}
-```
-
-
-
-
-
-
-
get/set int.is_even
-
-```rust,ignore
-get int.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set int.is_odd
-
-```rust,ignore
-get int.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set int.is_zero
-
-```rust,ignore
-get int.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
fn is_anonymous
-
-```rust,ignore
-fn is_anonymous(fn_ptr: FnPtr) -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if the function is an anonymous function.
-
-
-
-```rhai
-let f = |x| x * 2;
-
-print(f.is_anonymous); // prints true
-```
-
-
-
-
-
-
-
fn is_empty
-
-```rust,ignore
-fn is_empty(map: Map) -> bool
-fn is_empty(range: Range
) -> bool
-fn is_empty(string: String) -> bool
-fn is_empty(blob: Blob) -> bool
-fn is_empty(array: Array) -> bool
-fn is_empty(range: RangeInclusive) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the map is empty.
-
-
-
-
-
-
-
fn is_even
-
-```rust,ignore
-fn is_even(x: i8) -> bool
-fn is_even(x: int) -> bool
-fn is_even(x: u8) -> bool
-fn is_even(x: u16) -> bool
-fn is_even(x: i32) -> bool
-fn is_even(x: i128) -> bool
-fn is_even(x: u64) -> bool
-fn is_even(x: u128) -> bool
-fn is_even(x: i16) -> bool
-fn is_even(x: u32) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
fn is_exclusive
-
-```rust,ignore
-fn is_exclusive(range: RangeInclusive
) -> bool
-fn is_exclusive(range: Range) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the range is exclusive.
-
-
-
-
-
-
-
fn is_finite
-
-```rust,ignore
-fn is_finite(x: float) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the floating-point number is finite.
-
-
-
-
-
-
-
fn is_inclusive
-
-```rust,ignore
-fn is_inclusive(range: Range
) -> bool
-fn is_inclusive(range: RangeInclusive) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the range is inclusive.
-
-
-
-
-
-
-
fn is_infinite
-
-```rust,ignore
-fn is_infinite(x: float) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the floating-point number is infinite.
-
-
-
-
-
-
-
fn is_nan
-
-```rust,ignore
-fn is_nan(x: float) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return `true` if the floating-point number is `NaN` (Not A Number).
-
-
-
-
-
-
-
fn is_odd
-
-```rust,ignore
-fn is_odd(x: int) -> bool
-fn is_odd(x: i8) -> bool
-fn is_odd(x: u64) -> bool
-fn is_odd(x: i128) -> bool
-fn is_odd(x: i32) -> bool
-fn is_odd(x: u8) -> bool
-fn is_odd(x: u16) -> bool
-fn is_odd(x: i16) -> bool
-fn is_odd(x: u128) -> bool
-fn is_odd(x: u32) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
fn is_zero
-
-```rust,ignore
-fn is_zero(x: i8) -> bool
-fn is_zero(x: int) -> bool
-fn is_zero(x: u8) -> bool
-fn is_zero(x: u16) -> bool
-fn is_zero(x: i32) -> bool
-fn is_zero(x: i128) -> bool
-fn is_zero(x: u64) -> bool
-fn is_zero(x: u128) -> bool
-fn is_zero(x: i16) -> bool
-fn is_zero(x: float) -> bool
-fn is_zero(x: f32) -> bool
-fn is_zero(x: u32) -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
fn keys
-
-```rust,ignore
-fn keys(map: Map) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an array with all the property names in the object map.
-
-
-
-```rhai
-let m = #{a:1, b:2, c:3};
-
-print(m.keys()); // prints ["a", "b", "c"]
-```
-
-
-
-
-
-
-
fn len
-
-```rust,ignore
-fn len(array: Array) -> int
-fn len(blob: Blob) -> int
-fn len(string: String) -> int
-fn len(map: Map) -> int
-```
-
-
-
-
-Description
-
-
-
-
-Number of elements in the array.
-
-
-
-
-
-
-
fn ln
-
-```rust,ignore
-fn ln(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the natural log of the floating-point number.
-
-
-
-
-
-
-
fn log
-
-```rust,ignore
-fn log(x: float) -> float
-fn log(x: float, base: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the log of the floating-point number with base 10.
-
-
-
-
-
-
-
fn make_lower
-
-```rust,ignore
-fn make_lower(string: String)
-fn make_lower(character: char)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the string to all lower-case.
-
-
-
-```rhai
-let text = "HELLO, WORLD!"
-
-text.make_lower();
-
-print(text); // prints "hello, world!";
-```
-
-
-
-
-
-
-
fn make_upper
-
-```rust,ignore
-fn make_upper(string: String)
-fn make_upper(character: char)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the string to all upper-case.
-
-
-
-```rhai
-let text = "hello, world!"
-
-text.make_upper();
-
-print(text); // prints "HELLO, WORLD!";
-```
-
-
-
-
-
-
-
fn map
-
-```rust,ignore
-fn map(array: Array, mapper: String) -> Array
-fn map(array: Array, map: FnPtr) -> Array
-```
-
-
-
-
-Description
-
-
-Deprecated API
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Iterate through all the elements in the array, applying a function named by `mapper` to each
-element in turn, and return the results as a new array.
-
-
-
-This method is deprecated and will be removed from the next major version.
-Use `array.map(Fn("fn_name"))` instead.
-
-
-
-A function with the same name as the value of `mapper` must exist taking these parameters:
-
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-fn square(x) { x * x }
-
-fn multiply(x, i) { x * i }
-
-let x = [1, 2, 3, 4, 5];
-
-let y = x.map("square");
-
-print(y); // prints "[1, 4, 9, 16, 25]"
-
-let y = x.map("multiply");
-
-print(y); // prints "[0, 2, 6, 12, 20]"
-```
-
-
-
-
-
-
-
fn max
-
-```rust,ignore
-fn max(x: u32, y: u32) -> u32
-fn max(x: int, y: int) -> int
-fn max(x: i8, y: i8) -> i8
-fn max(x: u16, y: u16) -> u16
-fn max(x: i16, y: i16) -> i16
-fn max(x: int, y: float) -> float
-fn max(x: float, y: int) -> float
-fn max(x: f32, y: float) -> float
-fn max(x: f32, y: f32) -> f32
-fn max(x: f32, y: int) -> f32
-fn max(x: u8, y: u8) -> u8
-fn max(x: i128, y: i128) -> i128
-fn max(x: float, y: f32) -> float
-fn max(x: u128, y: u128) -> u128
-fn max(string1: String, string2: String) -> String
-fn max(x: i32, y: i32) -> i32
-fn max(x: int, y: f32) -> f32
-fn max(x: float, y: float) -> float
-fn max(char1: char, char2: char) -> char
-fn max(x: u64, y: u64) -> u64
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the number that is larger than the other number.
-
-
-
-```rhai
-max(42, 123); // returns 132
-```
-
-
-
-
-
-
-
fn min
-
-```rust,ignore
-fn min(x: int, y: int) -> int
-fn min(x: u32, y: u32) -> u32
-fn min(x: u16, y: u16) -> u16
-fn min(x: i8, y: i8) -> i8
-fn min(x: float, y: int) -> float
-fn min(x: f32, y: float) -> float
-fn min(x: int, y: float) -> float
-fn min(x: i16, y: i16) -> i16
-fn min(x: f32, y: int) -> f32
-fn min(x: f32, y: f32) -> f32
-fn min(x: i128, y: i128) -> i128
-fn min(x: float, y: f32) -> float
-fn min(x: u128, y: u128) -> u128
-fn min(x: u8, y: u8) -> u8
-fn min(x: i32, y: i32) -> i32
-fn min(string1: String, string2: String) -> String
-fn min(x: int, y: f32) -> f32
-fn min(char1: char, char2: char) -> char
-fn min(x: u64, y: u64) -> u64
-fn min(x: float, y: float) -> float
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the number that is smaller than the other number.
-
-
-
-```rhai
-min(42, 123); // returns 42
-```
-
-
-
-
-
-
-
fn mixin
-
-```rust,ignore
-fn mixin(map: Map, map2: Map)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Add all property values of another object map into the object map.
-Existing property values of the same names are replaced.
-
-
-
-```rhai
-let m = #{a:1, b:2, c:3};
-let n = #{a: 42, d:0};
-
-m.mixin(n);
-
-print(m); // prints "#{a:42, b:2, c:3, d:0}"
-```
-
-
-
-
-
-
-
fn name
-
-```rust,ignore
-fn name(fn_ptr: FnPtr) -> String
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the name of the function.
-
-
-
-```rhai
-fn double(x) { x * 2 }
-
-let f = Fn("double");
-
-print(f.name); // prints "double"
-```
-
-
-
-
-
-
-
fn pad
-
-```rust,ignore
-fn pad(string: String, len: int, character: char)
-fn pad(array: Array, len: int, item: ?)
-fn pad(blob: Blob, len: int, value: int)
-fn pad(string: String, len: int, padding: String)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Pad the string to at least the specified number of characters with the specified `character`.
-
-If `len` ≤ length of string, no padding is done.
-
-
-
-```rhai
-let text = "hello";
-
-text.pad(8, '!');
-
-print(text); // prints "hello!!!"
-
-text.pad(5, '*');
-
-print(text); // prints "hello!!!"
-```
-
-
-
-
-
-
-
fn parse_be_float
-
-```rust,ignore
-fn parse_be_float(blob: Blob, range: Range
) -> float
-fn parse_be_float(blob: Blob, range: RangeInclusive) -> float
-fn parse_be_float(blob: Blob, start: int, len: int) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Parse the bytes within an exclusive `range` in the BLOB as a `FLOAT`
-in big-endian byte order.
-
-* If number of bytes in `range` < number of bytes for `FLOAT`, zeros are padded.
-* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes are ignored.
-
-
-
-
-
-
-
fn parse_be_int
-
-```rust,ignore
-fn parse_be_int(blob: Blob, range: RangeInclusive
) -> int
-fn parse_be_int(blob: Blob, range: Range) -> int
-fn parse_be_int(blob: Blob, start: int, len: int) -> int
-```
-
-
-
-
-Description
-
-
-
-
-Parse the bytes within an inclusive `range` in the BLOB as an `INT`
-in big-endian byte order.
-
-* If number of bytes in `range` < number of bytes for `INT`, zeros are padded.
-* If number of bytes in `range` > number of bytes for `INT`, extra bytes are ignored.
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-let x = b.parse_be_int(1..=3); // parse three bytes
-
-print(x.to_hex()); // prints "0203040000...00"
-```
-
-
-
-
-
-
-
fn parse_float
-
-```rust,ignore
-fn parse_float(string: String) -> float
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Parse a string into a floating-point number.
-
-
-
-```rhai
-let x = parse_int("123.456");
-
-print(x); // prints 123.456
-```
-
-
-
-
-
-
-
fn parse_int
-
-```rust,ignore
-fn parse_int(string: String) -> int
-fn parse_int(string: String, radix: int) -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Parse a string into an integer number.
-
-
-
-```rhai
-let x = parse_int("123");
-
-print(x); // prints 123
-```
-
-
-
-
-
-
-
fn parse_json
-
-```rust,ignore
-fn parse_json(json: String) -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Parse a JSON string into a value.
-
-
-
-```rhai
-let m = parse_json(`{"a":1, "b":2, "c":3}`);
-
-print(m); // prints #{"a":1, "b":2, "c":3}
-```
-
-
-
-
-
-
-
fn parse_le_float
-
-```rust,ignore
-fn parse_le_float(blob: Blob, range: Range
) -> float
-fn parse_le_float(blob: Blob, range: RangeInclusive) -> float
-fn parse_le_float(blob: Blob, start: int, len: int) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Parse the bytes within an exclusive `range` in the BLOB as a `FLOAT`
-in little-endian byte order.
-
-* If number of bytes in `range` < number of bytes for `FLOAT`, zeros are padded.
-* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes are ignored.
-
-
-
-
-
-
-
fn parse_le_int
-
-```rust,ignore
-fn parse_le_int(blob: Blob, range: RangeInclusive
) -> int
-fn parse_le_int(blob: Blob, range: Range) -> int
-fn parse_le_int(blob: Blob, start: int, len: int) -> int
-```
-
-
-
-
-Description
-
-
-
-
-Parse the bytes within an inclusive `range` in the BLOB as an `INT`
-in little-endian byte order.
-
-* If number of bytes in `range` < number of bytes for `INT`, zeros are padded.
-* If number of bytes in `range` > number of bytes for `INT`, extra bytes are ignored.
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-let x = b.parse_le_int(1..=3); // parse three bytes
-
-print(x.to_hex()); // prints "040302"
-```
-
-
-
-
-
-
-
fn pop
-
-```rust,ignore
-fn pop(array: Array) -> ?
-fn pop(blob: Blob) -> int
-fn pop(string: String) -> ?
-fn pop(string: String, len: int) -> String
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove the last element from the array and return it.
-
-If the array is empty, `()` is returned.
-
-
-
-```rhai
-let x = [1, 2, 3];
-
-print(x.pop()); // prints 3
-
-print(x); // prints "[1, 2]"
-```
-
-
-
-
-
-
-
fn print
-
-```rust,ignore
-fn print() -> String
-fn print(array: Array) -> String
-fn print(character: char) -> String
-fn print(value: bool) -> String
-fn print(string: String) -> String
-fn print(unit: ?) -> String
-fn print(map: Map) -> String
-fn print(number: f32) -> String
-fn print(number: float) -> String
-fn print(item: ?) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Return the empty string.
-
-
-
-
-
-
-
fn push
-
-```rust,ignore
-fn push(array: Array, item: ?)
-fn push(blob: Blob, value: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Add a new element, which is not another array, to the end of the array.
-
-If `item` is `Array`, then `append` is more specific and will be called instead.
-
-
-
-```rhai
-let x = [1, 2, 3];
-
-x.push("hello");
-
-print(x); // prints [1, 2, 3, "hello"]
-```
-
-
-
-
-
-
-
fn range
-
-```rust,ignore
-fn range(range: Range
, step: float) -> StepRange
-fn range(from: u64, to: u64) -> Range
-fn range(range: Range, step: u8) -> StepRange
-fn range(range: Range, step: u128) -> StepRange
-fn range(from: u8, to: u8) -> Range
-fn range(from: i128, to: i128) -> Range
-fn range(from: u128, to: u128) -> Range
-fn range(from: i32, to: i32) -> Range
-fn range(range: Range, step: i128) -> StepRange
-fn range(from: i16, to: i16) -> Range
-fn range(range: Range, step: i32) -> StepRange
-fn range(range: Range, step: i16) -> StepRange
-fn range(range: Range, step: u64) -> StepRange
-fn range(from: u32, to: u32) -> Range
-fn range(from: int, to: int) -> Range
-fn range(range: Range, step: i8) -> StepRange
-fn range(from: i8, to: i8) -> Range
-fn range(from: u16, to: u16) -> Range
-fn range(range: Range, step: u32) -> StepRange
-fn range(range: Range, step: u16) -> StepRange
-fn range(range: Range, step: int) -> StepRange
-fn range(from: u32, to: u32, step: u32) -> StepRange
-fn range(from: u64, to: u64, step: u64) -> StepRange
-fn range(from: i8, to: i8, step: i8) -> StepRange
-fn range(from: u16, to: u16, step: u16) -> StepRange
-fn range(from: u8, to: u8, step: u8) -> StepRange
-fn range(from: u128, to: u128, step: u128) -> StepRange
-fn range(from: float, to: float, step: float) -> StepRange
-fn range(from: i32, to: i32, step: i32) -> StepRange
-fn range(from: int, to: int, step: int) -> StepRange
-fn range(from: i16, to: i16, step: i16) -> StepRange
-fn range(from: i128, to: i128, step: i128) -> StepRange
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an iterator over an exclusive range, each iteration increasing by `step`.
-
-If `range` is reversed and `step` < 0, iteration goes backwards.
-
-Otherwise, if `range` is empty, an empty iterator is returned.
-
-
-
-```rhai
-// prints all values from 8 to 17 in steps of 3
-for n in range(8..18, 3) {
- print(n);
-}
-
-// prints all values down from 18 to 9 in steps of -3
-for n in range(18..8, -3) {
- print(n);
-}
-```
-
-
-
-
-
-
-
fn reduce
-
-```rust,ignore
-fn reduce(array: Array, reducer: String) -> ?
-fn reduce(array: Array, reducer: FnPtr) -> ?
-fn reduce(array: Array, reducer: FnPtr, initial: ?) -> ?
-fn reduce(array: Array, reducer: String, initial: ?) -> ?
-```
-
-
-
-
-Description
-
-
-Deprecated API
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Reduce an array by iterating through all elements while applying a function named by `reducer`.
-
-
-
-This method is deprecated and will be removed from the next major version.
-Use `array.reduce(Fn("fn_name"))` instead.
-
-
-
-A function with the same name as the value of `reducer` must exist taking these parameters:
-
-* `result`: accumulated result, initially `()`
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-fn process(r, x) {
- x + (r ?? 0)
-}
-fn process_extra(r, x, i) {
- x + i + (r ?? 0)
-}
-
-let x = [1, 2, 3, 4, 5];
-
-let y = x.reduce("process");
-
-print(y); // prints 15
-
-let y = x.reduce("process_extra");
-
-print(y); // prints 25
-```
-
-
-
-
-
-
-
fn reduce_rev
-
-```rust,ignore
-fn reduce_rev(array: Array, reducer: String) -> ?
-fn reduce_rev(array: Array, reducer: FnPtr) -> ?
-fn reduce_rev(array: Array, reducer: FnPtr, initial: ?) -> ?
-fn reduce_rev(array: Array, reducer: String, initial: ?) -> ?
-```
-
-
-
-
-Description
-
-
-Deprecated API
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Reduce an array by iterating through all elements, in _reverse_ order,
-while applying a function named by `reducer`.
-
-
-
-This method is deprecated and will be removed from the next major version.
-Use `array.reduce_rev(Fn("fn_name"))` instead.
-
-
-
-A function with the same name as the value of `reducer` must exist taking these parameters:
-
-* `result`: accumulated result, initially `()`
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-fn process(r, x) {
- x + (r ?? 0)
-}
-fn process_extra(r, x, i) {
- x + i + (r ?? 0)
-}
-
-let x = [1, 2, 3, 4, 5];
-
-let y = x.reduce_rev("process");
-
-print(y); // prints 15
-
-let y = x.reduce_rev("process_extra");
-
-print(y); // prints 25
-```
-
-
-
-
-
-
-
fn remove
-
-```rust,ignore
-fn remove(blob: Blob, index: int) -> int
-fn remove(array: Array, index: int) -> ?
-fn remove(string: String, character: char)
-fn remove(map: Map, property: String) -> ?
-fn remove(string: String, sub_string: String)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove the byte at the specified `index` from the BLOB and return it.
-
-* If `index` < 0, position counts from the end of the BLOB (`-1` is the last byte).
-* If `index` < -length of BLOB, zero is returned.
-* If `index` ≥ length of BLOB, zero is returned.
-
-
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-print(x.remove(1)); // prints 2
-
-print(x); // prints "[01030405]"
-
-print(x.remove(-2)); // prints 4
-
-print(x); // prints "[010305]"
-```
-
-
-
-
-
-
-
fn replace
-
-```rust,ignore
-fn replace(string: String, find_character: char, substitute_character: char)
-fn replace(string: String, find_string: String, substitute_character: char)
-fn replace(string: String, find_character: char, substitute_string: String)
-fn replace(string: String, find_string: String, substitute_string: String)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Replace all occurrences of the specified character in the string with another character.
-
-
-
-```rhai
-let text = "hello, world! hello, foobar!";
-
-text.replace("l", '*');
-
-print(text); // prints "he**o, wor*d! he**o, foobar!"
-```
-
-
-
-
-
-
-
fn retain
-
-```rust,ignore
-fn retain(array: Array, range: Range
) -> Array
-fn retain(blob: Blob, range: RangeInclusive) -> Blob
-fn retain(array: Array, filter: FnPtr) -> Array
-fn retain(map: Map, filter: FnPtr) -> Map
-fn retain(blob: Blob, range: Range) -> Blob
-fn retain(array: Array, range: RangeInclusive) -> Array
-fn retain(array: Array, filter: String) -> Array
-fn retain(blob: Blob, start: int, len: int) -> Blob
-fn retain(array: Array, start: int, len: int) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove all elements in the array not within an exclusive `range` and return them as a new array.
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-
-let y = x.retain(1..4);
-
-print(x); // prints "[2, 3, 4]"
-
-print(y); // prints "[1, 5]"
-
-let z = x.retain(1..3);
-
-print(x); // prints "[3, 4]"
-
-print(z); // prints "[1]"
-```
-
-
-
-
-
-
-
fn reverse
-
-```rust,ignore
-fn reverse(blob: Blob)
-fn reverse(array: Array)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Reverse the BLOB.
-
-
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-print(b); // prints "[0102030405]"
-
-b.reverse();
-
-print(b); // prints "[0504030201]"
-```
-
-
-
-
-
-
-
fn round
-
-```rust,ignore
-fn round(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the nearest whole number closest to the floating-point number.
-Rounds away from zero.
-
-
-
-
-
-
-
fn set
-
-```rust,ignore
-fn set(blob: Blob, index: int, value: int)
-fn set(array: Array, index: int, value: ?)
-fn set(string: String, index: int, character: char)
-fn set(map: Map, property: String, value: ?)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Set the particular `index` position in the BLOB to a new byte `value`.
-
-* If `index` < 0, position counts from the end of the BLOB (`-1` is the last byte).
-* If `index` < -length of BLOB, the BLOB is not modified.
-* If `index` ≥ length of BLOB, the BLOB is not modified.
-
-
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-b.set(0, 0x42);
-
-print(b); // prints "[4202030405]"
-
-b.set(-3, 0);
-
-print(b); // prints "[4202000405]"
-
-b.set(99, 123);
-
-print(b); // prints "[4202000405]"
-```
-
-
-
-
-
-
-
fn set_bit
-
-```rust,ignore
-fn set_bit(value: int, bit: int, new_value: bool)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Set the specified `bit` in the number if the new value is `true`.
-Clear the `bit` if the new value is `false`.
-
-If `bit` < 0, position counts from the MSB (Most Significant Bit).
-
-
-
-```rhai
-let x = 123456;
-
-x.set_bit(5, true);
-
-print(x); // prints 123488
-
-x.set_bit(6, false);
-
-print(x); // prints 123424
-
-x.set_bit(-48, false);
-
-print(x); // prints 57888 on 64-bit
-```
-
-
-
-
-
-
-
fn set_bits
-
-```rust,ignore
-fn set_bits(value: int, range: Range
, new_value: int)
-fn set_bits(value: int, range: RangeInclusive, new_value: int)
-fn set_bits(value: int, bit: int, bits: int, new_value: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Replace an exclusive range of bits in the number with a new value.
-
-
-
-```rhai
-let x = 123456;
-
-x.set_bits(5..10, 42);
-
-print(x); // print 123200
-```
-
-
-
-
-
-
-
fn set_tag
-
-```rust,ignore
-fn set_tag(value: ?, tag: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Set the _tag_ of a `Dynamic` value.
-
-
-
-```rhai
-let x = "hello, world!";
-
-x.tag = 42;
-
-print(x.tag); // prints 42
-```
-
-
-
-
-
-
-
fn shift
-
-```rust,ignore
-fn shift(blob: Blob) -> int
-fn shift(array: Array) -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove the first byte from the BLOB and return it.
-
-If the BLOB is empty, zero is returned.
-
-
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-print(b.shift()); // prints 1
-
-print(b); // prints "[02030405]"
-```
-
-
-
-
-
-
-
fn sign
-
-```rust,ignore
-fn sign(x: f32) -> int
-fn sign(x: i16) -> int
-fn sign(x: float) -> int
-fn sign(x: i32) -> int
-fn sign(x: i128) -> int
-fn sign(x: i8) -> int
-fn sign(x: int) -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the sign (as an integer) of the floating-point number according to the following:
-
-* `0` if the number is zero
-* `1` if the number is positive
-* `-1` if the number is negative
-
-
-
-
-
-
-
fn sin
-
-```rust,ignore
-fn sin(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the sine of the floating-point number in radians.
-
-
-
-
-
-
-
fn sinh
-
-```rust,ignore
-fn sinh(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the hyperbolic sine of the floating-point number in radians.
-
-
-
-
-
-
-
fn sleep
-
-```rust,ignore
-fn sleep(seconds: int)
-fn sleep(seconds: float)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Block the current thread for a particular number of `seconds`.
-
-
-
-```rhai
-// Do nothing for 10 seconds!
-sleep(10);
-```
-
-
-
-
-
-
-
fn some
-
-```rust,ignore
-fn some(array: Array, filter: FnPtr) -> bool
-fn some(array: Array, filter: String) -> bool
-```
-
-
-
-
-Description
-
-
-No Function Parameter
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Return `true` if any element in the array that returns `true` when applied the `filter` function.
-
-
-
-Array element (mutable) is bound to `this`.
-
-This method is marked _pure_; the `filter` function should not mutate array elements.
-
-
-
-* `element`: copy of array element
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5];
-
-print(x.some(|v| v > 3)); // prints true
-
-print(x.some(|v| v > 10)); // prints false
-
-print(x.some(|v, i| i > v)); // prints true
-```
-
-
-
-
-
-
-
fn sort
-
-```rust,ignore
-fn sort(array: Array)
-fn sort(array: Array, comparer: FnPtr)
-fn sort(array: Array, comparer: String)
-```
-
-
-
-
-Description
-
-
-Supported Data Types
-
-
-Example
-
-
-
-
-Sort the array.
-
-All elements in the array must be of the same data type.
-
-
-
-* integer numbers
-* floating-point numbers
-* decimal numbers
-* characters
-* strings
-* booleans
-* `()`
-
-
-
-```rhai
-let x = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10];
-
-x.sort();
-
-print(x); // prints "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
-```
-
-
-
-
-
-
-
fn splice
-
-```rust,ignore
-fn splice(array: Array, range: RangeInclusive
, replace: Array)
-fn splice(blob: Blob, range: Range, replace: Blob)
-fn splice(array: Array, range: Range, replace: Array)
-fn splice(blob: Blob, range: RangeInclusive, replace: Blob)
-fn splice(blob: Blob, start: int, len: int, replace: Blob)
-fn splice(array: Array, start: int, len: int, replace: Array)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Replace an inclusive range of the array with another array.
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-let y = [7, 8, 9, 10];
-
-x.splice(1..=3, y);
-
-print(x); // prints "[1, 7, 8, 9, 10, 5]"
-```
-
-
-
-
-
-
-
fn split
-
-```rust,ignore
-fn split(string: String) -> Array
-fn split(string: String, delimiter: char) -> Array
-fn split(array: Array, index: int) -> Array
-fn split(blob: Blob, index: int) -> Blob
-fn split(string: String, index: int) -> Array
-fn split(string: String, delimiter: String) -> Array
-fn split(string: String, delimiter: String, segments: int) -> Array
-fn split(string: String, delimiter: char, segments: int) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Split the string into segments based on whitespaces, returning an array of the segments.
-
-
-
-```rhai
-let text = "hello, world! hello, foo!";
-
-print(text.split()); // prints ["hello,", "world!", "hello,", "foo!"]
-```
-
-
-
-
-
-
-
fn split_rev
-
-```rust,ignore
-fn split_rev(string: String, delimiter: String) -> Array
-fn split_rev(string: String, delimiter: char) -> Array
-fn split_rev(string: String, delimiter: String, segments: int) -> Array
-fn split_rev(string: String, delimiter: char, segments: int) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Split the string into segments based on a `delimiter` string, returning an array of the
-segments in _reverse_ order.
-
-
-
-```rhai
-let text = "hello, world! hello, foo!";
-
-print(text.split_rev("ll")); // prints ["o, foo!", "o, world! he", "he"]
-```
-
-
-
-
-
-
-
fn sqrt
-
-```rust,ignore
-fn sqrt(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the square root of the floating-point number.
-
-
-
-
-
-
-
fn start
-
-```rust,ignore
-fn start(range: RangeInclusive
) -> int
-fn start(range: Range) -> int
-```
-
-
-
-
-Description
-
-
-
-
-Return the start of the inclusive range.
-
-
-
-
-
-
-
fn starts_with
-
-```rust,ignore
-fn starts_with(string: String, match_string: String) -> bool
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return `true` if the string starts with a specified string.
-
-
-
-```rhai
-let text = "hello, world!";
-
-print(text.starts_with("hello")); // prints true
-
-print(text.starts_with("world")); // prints false
-```
-
-
-
-
-
-
-
fn sub_string
-
-```rust,ignore
-fn sub_string(string: String, range: Range
) -> String
-fn sub_string(string: String, range: RangeInclusive) -> String
-fn sub_string(string: String, start: int) -> String
-fn sub_string(string: String, start: int, len: int) -> String
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Copy an exclusive range of characters from the string and return it as a new string.
-
-
-
-```rhai
-let text = "hello, world!";
-
-print(text.sub_string(3..7)); // prints "lo, "
-```
-
-
-
-
-
-
-
fn tag
-
-```rust,ignore
-fn tag(value: ?) -> int
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return the _tag_ of a `Dynamic` value.
-
-
-
-```rhai
-let x = "hello, world!";
-
-x.tag = 42;
-
-print(x.tag); // prints 42
-```
-
-
-
-
-
-
-
fn take
-
-```rust,ignore
-fn take(value: ?) -> ?
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Take ownership of the data in a `Dynamic` value and return it.
-The data is _NOT_ cloned.
-
-The original value is replaced with `()`.
-
-
-
-```rhai
-let x = 42;
-
-print(take(x)); // prints 42
-
-print(x); // prints ()
-```
-
-
-
-
-
-
-
fn tan
-
-```rust,ignore
-fn tan(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the tangent of the floating-point number in radians.
-
-
-
-
-
-
-
fn tanh
-
-```rust,ignore
-fn tanh(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Return the hyperbolic tangent of the floating-point number in radians.
-
-
-
-
-
-
-
fn timestamp
-
-```rust,ignore
-fn timestamp() -> Instant
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Create a timestamp containing the current system time.
-
-
-
-```rhai
-let now = timestamp();
-
-sleep(10.0); // sleep for 10 seconds
-
-print(now.elapsed); // prints 10.???
-```
-
-
-
-
-
-
-
fn to_array
-
-```rust,ignore
-fn to_array(blob: Blob) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the BLOB into an array of integers.
-
-
-
-```rhai
-let b = blob(5, 0x42);
-
-let x = b.to_array();
-
-print(x); // prints "[66, 66, 66, 66, 66]"
-```
-
-
-
-
-
-
-
fn to_binary
-
-```rust,ignore
-fn to_binary(value: i8) -> String
-fn to_binary(value: int) -> String
-fn to_binary(value: u16) -> String
-fn to_binary(value: u8) -> String
-fn to_binary(value: i32) -> String
-fn to_binary(value: i128) -> String
-fn to_binary(value: u64) -> String
-fn to_binary(value: u128) -> String
-fn to_binary(value: i16) -> String
-fn to_binary(value: u32) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Convert the `value` into a string in binary format.
-
-
-
-
-
-
-
fn to_blob
-
-```rust,ignore
-fn to_blob(string: String) -> Blob
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the string into an UTF-8 encoded byte-stream as a BLOB.
-
-
-
-```rhai
-let text = "朝には紅顔ありて夕べには白骨となる";
-
-let bytes = text.to_blob();
-
-print(bytes.len()); // prints 51
-```
-
-
-
-
-
-
-
fn to_chars
-
-```rust,ignore
-fn to_chars(string: String) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an array containing all the characters of the string.
-
-
-
-```rhai
-let text = "hello";
-
-print(text.to_chars()); // prints "['h', 'e', 'l', 'l', 'o']"
-```
-
-
-
-
-
-
-
fn to_debug
-
-```rust,ignore
-fn to_debug(item: ?) -> String
-fn to_debug(number: float) -> String
-fn to_debug(number: f32) -> String
-fn to_debug(map: Map) -> String
-fn to_debug(unit: ?) -> String
-fn to_debug(string: String) -> String
-fn to_debug(character: char) -> String
-fn to_debug(f: FnPtr) -> String
-fn to_debug(value: bool) -> String
-fn to_debug(array: Array) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Convert the value of the `item` into a string in debug format.
-
-
-
-
-
-
-
fn to_degrees
-
-```rust,ignore
-fn to_degrees(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Convert radians to degrees.
-
-
-
-
-
-
-
fn to_float
-
-```rust,ignore
-fn to_float()
-fn to_float(x: f32) -> float
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-fn to_float()
-```
-
-
-
-
-Description
-
-
-
-
-Convert the 32-bit floating-point number to 64-bit.
-
-
-
-
-
-
-
fn to_hex
-
-```rust,ignore
-fn to_hex(value: i16) -> String
-fn to_hex(value: u128) -> String
-fn to_hex(value: u32) -> String
-fn to_hex(value: int) -> String
-fn to_hex(value: i8) -> String
-fn to_hex(value: i128) -> String
-fn to_hex(value: u64) -> String
-fn to_hex(value: u8) -> String
-fn to_hex(value: u16) -> String
-fn to_hex(value: i32) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Convert the `value` into a string in hex format.
-
-
-
-
-
-
-
fn to_int
-
-```rust,ignore
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int()
-fn to_int(x: float) -> int
-fn to_int(x: f32) -> int
-fn to_int()
-```
-
-
-
-
-Description
-
-
-
-
-Convert the floating-point number into an integer.
-
-
-
-
-
-
-
fn to_json
-
-```rust,ignore
-fn to_json(map: Map) -> String
-```
-
-
-
-
-Description
-
-
-Data types
-
-
-Errors
-
-
-Example
-
-
-
-
-Return the JSON representation of the object map.
-
-
-
-Only the following data types should be kept inside the object map:
-`INT`, `FLOAT`, `ImmutableString`, `char`, `bool`, `()`, `Array`, `Map`.
-
-
-
-Data types not supported by JSON serialize into formats that may
-invalidate the result.
-
-
-
-```rhai
-let m = #{a:1, b:2, c:3};
-
-print(m.to_json()); // prints {"a":1, "b":2, "c":3}
-```
-
-
-
-
-
-
-
fn to_lower
-
-```rust,ignore
-fn to_lower(string: String) -> String
-fn to_lower(character: char) -> char
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the string to all lower-case and return it as a new string.
-
-
-
-```rhai
-let text = "HELLO, WORLD!"
-
-print(text.to_lower()); // prints "hello, world!"
-
-print(text); // prints "HELLO, WORLD!"
-```
-
-
-
-
-
-
-
fn to_octal
-
-```rust,ignore
-fn to_octal(value: i16) -> String
-fn to_octal(value: u128) -> String
-fn to_octal(value: u32) -> String
-fn to_octal(value: int) -> String
-fn to_octal(value: i8) -> String
-fn to_octal(value: i128) -> String
-fn to_octal(value: u64) -> String
-fn to_octal(value: u16) -> String
-fn to_octal(value: u8) -> String
-fn to_octal(value: i32) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Convert the `value` into a string in octal format.
-
-
-
-
-
-
-
fn to_radians
-
-```rust,ignore
-fn to_radians(x: float) -> float
-```
-
-
-
-
-Description
-
-
-
-
-Convert degrees to radians.
-
-
-
-
-
-
-
fn to_string
-
-```rust,ignore
-fn to_string(unit: ?) -> String
-fn to_string(string: String) -> String
-fn to_string(value: bool) -> String
-fn to_string(character: char) -> String
-fn to_string(array: Array) -> String
-fn to_string(item: ?) -> String
-fn to_string(map: Map) -> String
-fn to_string(number: f32) -> String
-fn to_string(number: float) -> String
-```
-
-
-
-
-Description
-
-
-
-
-Return the empty string.
-
-
-
-
-
-
-
fn to_upper
-
-```rust,ignore
-fn to_upper(character: char) -> char
-fn to_upper(string: String) -> String
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Convert the character to upper-case and return it as a new character.
-
-
-
-```rhai
-let ch = 'a';
-
-print(ch.to_upper()); // prints 'A'
-
-print(ch); // prints 'a'
-```
-
-
-
-
-
-
-
fn trim
-
-```rust,ignore
-fn trim(string: String)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Remove whitespace characters from both ends of the string.
-
-
-
-```rhai
-let text = " hello ";
-
-text.trim();
-
-print(text); // prints "hello"
-```
-
-
-
-
-
-
-
fn truncate
-
-```rust,ignore
-fn truncate(blob: Blob, len: int)
-fn truncate(array: Array, len: int)
-fn truncate(string: String, len: int)
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Cut off the BLOB at the specified length.
-
-* If `len` ≤ 0, the BLOB is cleared.
-* If `len` ≥ length of BLOB, the BLOB is not truncated.
-
-
-
-```rhai
-let b = blob();
-
-b += 1; b += 2; b += 3; b += 4; b += 5;
-
-b.truncate(3);
-
-print(b); // prints "[010203]"
-
-b.truncate(10);
-
-print(b); // prints "[010203]"
-```
-
-
-
-
-
-
-
get/set u128.is_even
-
-```rust,ignore
-get u128.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set u128.is_odd
-
-```rust,ignore
-get u128.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set u128.is_zero
-
-```rust,ignore
-get u128.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set u16.is_even
-
-```rust,ignore
-get u16.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set u16.is_odd
-
-```rust,ignore
-get u16.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set u16.is_zero
-
-```rust,ignore
-get u16.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set u32.is_even
-
-```rust,ignore
-get u32.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set u32.is_odd
-
-```rust,ignore
-get u32.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set u32.is_zero
-
-```rust,ignore
-get u32.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set u64.is_even
-
-```rust,ignore
-get u64.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set u64.is_odd
-
-```rust,ignore
-get u64.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set u64.is_zero
-
-```rust,ignore
-get u64.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
get/set u8.is_even
-
-```rust,ignore
-get u8.is_even -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is even.
-
-
-
-
-
-
-
get/set u8.is_odd
-
-```rust,ignore
-get u8.is_odd -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is odd.
-
-
-
-
-
-
-
get/set u8.is_zero
-
-```rust,ignore
-get u8.is_zero -> bool
-```
-
-
-
-
-Description
-
-
-
-
-Return true if the number is zero.
-
-
-
-
-
-
-
fn values
-
-```rust,ignore
-fn values(map: Map) -> Array
-```
-
-
-
-
-Description
-
-
-Example
-
-
-
-
-Return an array with all the property values in the object map.
-
-
-
-```rhai
-let m = #{a:1, b:2, c:3};
-
-print(m.values()); // prints "[1, 2, 3]""
-```
-
-
-
-
-
-
-
fn write_ascii
-
-```rust,ignore
-fn write_ascii(blob: Blob, range: Range
, string: String)
-fn write_ascii(blob: Blob, range: RangeInclusive, string: String)
-fn write_ascii(blob: Blob, start: int, len: int, string: String)
-```
-
-
-
-
-Description
-
-
-
-
-Write an ASCII string to the bytes within an exclusive `range` in the BLOB.
-
-Each ASCII character encodes to one single byte in the BLOB.
-Non-ASCII characters are ignored.
-
-* If number of bytes in `range` < length of `string`, extra bytes in `string` are not written.
-* If number of bytes in `range` > length of `string`, extra bytes in `range` are not modified.
-
-```rhai
-let b = blob(8);
-
-b.write_ascii(1..5, "hello, world!");
-
-print(b); // prints "[0068656c6c000000]"
-```
-
-
-
-
-
-
-
fn write_be
-
-```rust,ignore
-fn write_be(blob: Blob, range: Range
, value: float)
-fn write_be(blob: Blob, range: RangeInclusive, value: int)
-fn write_be(blob: Blob, range: Range, value: int)
-fn write_be(blob: Blob, range: RangeInclusive, value: float)
-fn write_be(blob: Blob, start: int, len: int, value: float)
-fn write_be(blob: Blob, start: int, len: int, value: int)
-```
-
-
-
-
-Description
-
-
-
-
-Write a `FLOAT` value to the bytes within an exclusive `range` in the BLOB
-in big-endian byte order.
-
-* If number of bytes in `range` < number of bytes for `FLOAT`, extra bytes in `FLOAT` are not written.
-* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes in `range` are not modified.
-
-
-
-
-
-
-
fn write_le
-
-```rust,ignore
-fn write_le(blob: Blob, range: RangeInclusive
, value: int)
-fn write_le(blob: Blob, range: Range, value: float)
-fn write_le(blob: Blob, range: RangeInclusive, value: float)
-fn write_le(blob: Blob, range: Range, value: int)
-fn write_le(blob: Blob, start: int, len: int, value: int)
-fn write_le(blob: Blob, start: int, len: int, value: float)
-```
-
-
-
-
-Description
-
-
-
-
-Write an `INT` value to the bytes within an inclusive `range` in the BLOB
-in little-endian byte order.
-
-* If number of bytes in `range` < number of bytes for `INT`, extra bytes in `INT` are not written.
-* If number of bytes in `range` > number of bytes for `INT`, extra bytes in `range` are not modified.
-
-```rhai
-let b = blob(8);
-
-b.write_le_int(1..=3, 0x12345678);
-
-print(b); // prints "[0078563400000000]"
-```
-
-
-
-
-
-
-
fn write_utf8
-
-```rust,ignore
-fn write_utf8(blob: Blob, range: Range
, string: String)
-fn write_utf8(blob: Blob, range: RangeInclusive, string: String)
-fn write_utf8(blob: Blob, start: int, len: int, string: String)
-```
-
-
-
-
-Description
-
-
-
-
-Write a string to the bytes within an exclusive `range` in the BLOB in UTF-8 encoding.
-
-* If number of bytes in `range` < length of `string`, extra bytes in `string` are not written.
-* If number of bytes in `range` > length of `string`, extra bytes in `range` are not modified.
-
-```rhai
-let b = blob(8);
-
-b.write_utf8(1..5, "朝には紅顔ありて夕べには白骨となる");
-
-print(b); // prints "[00e69c9de3000000]"
-```
-
-
-
-
-
-
-
fn zip
-
-```rust,ignore
-fn zip(array1: Array, array2: Array, map: FnPtr) -> Array
-```
-
-
-
-
-Description
-
-
-Function Parameters
-
-
-Example
-
-
-
-
-Iterate through all elements in two arrays, applying a `mapper` function to them,
-and return a new array containing the results.
-
-
-
-* `array1`: First array
-* `array2`: Second array
-* `index` _(optional)_: current index in the array
-
-
-
-```rhai
-let x = [1, 2, 3, 4, 5];
-let y = [9, 8, 7, 6];
-
-let z = x.zip(y, |a, b| a + b);
-
-print(z); // prints [10, 10, 10, 10]
-
-let z = x.zip(y, |a, b, i| a + b + i);
-
-print(z); // prints [10, 11, 12, 13]
-```
-
-
-
-
-
+# Global Builtin Rhai Functions
diff --git a/docs/src/modules/stdlib.md b/docs/src/modules/stdlib.md
index 6f815cf..9d2703e 100644
--- a/docs/src/modules/stdlib.md
+++ b/docs/src/modules/stdlib.md
@@ -1,1039 +1 @@
-# monitor
-
-```Namespace: global/std/monitor```
-
-
-
fn all_resolutions
-
-```rust,ignore
-fn all_resolutions() -> Vec<[int;2]>
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the resolutions of all connected monitors.
-
-
-
-Returns an array of arrays, where each inner array contains the width and height of a monitor.
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let resolutions = monitor::all_resolutions();
-print(resolutions); // Output: [[width1, height1], [width2, height2], ...]
-```
-
-
-
-
-
-
-
fn all_resolutions_str
-
-```rust,ignore
-fn all_resolutions_str() -> String
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the resolutions of all connected monitors as a string.
-
-
-
-Returns a string where each monitor's resolution is formatted as "width x height", separated by commas.
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let resolutions_str = monitor::all_resolutions_str();
-print(resolutions_str); // Output: "1920x1080, 1280x720"
-```
-
-
-
-
-
-
-
fn count
-
-```rust,ignore
-fn count() -> int
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the number of connected monitors.
-
-
-
-Returns the total number of connected monitors as an `i64`.
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let count = monitor::count();
-print(count); // Output: Number of connected monitors
-```
-
-
-
-
-
-
-
fn dimensions
-
-```rust,ignore
-fn dimensions(index: int) -> [int;4]
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the dimensions (x, y, width, height) of a specific monitor.
-
-
-
-* `index` - The index of the monitor (0-based).
-
-
-
-Returns an array with the monitor's position (x, y) and size (width, height).
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let dimensions = monitor::dimensions(0);
-print(dimensions); // Output: [x, y, width, height]
-```
-
-
-
-
-
-
-
fn dimensions_str
-
-```rust,ignore
-fn dimensions_str(index: int) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the dimensions of a specific monitor as a string.
-
-
-
-* `index` - The index of the monitor (0-based).
-
-
-
-Returns the monitor's dimensions as a string in the format "x,y - width x height".
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let dimensions_str = monitor::dimensions_str(0);
-print(dimensions_str); // Output: "0,0 - 1920x1080"
-```
-
-
-
-
-
-
-
fn dpi
-
-```rust,ignore
-fn dpi(index: int) -> float
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the DPI (dots per inch) of a specific monitor.
-
-
-
-* `index` - The index of the monitor (0-based).
-
-
-
-Returns the DPI (scale factor * base DPI) of the monitor as a `f64`.
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let dpi = monitor::dpi(0);
-print(dpi); // Output: DPI of the monitor
-```
-
-
-
-
-
-
-
fn dpi_str
-
-```rust,ignore
-fn dpi_str(index: int) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the DPI of a specific monitor as a string.
-
-
-
-* `index` - The index of the monitor (0-based).
-
-
-
-Returns the DPI of the monitor as a string formatted to 1 decimal place.
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let dpi_str = monitor::dpi_str(0);
-print(dpi_str); // Output: "96.0"
-```
-
-
-
-
-
-
-
fn primary_resolution
-
-```rust,ignore
-fn primary_resolution() -> [int;2]
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the resolution of the primary monitor.
-
-
-
-Returns an array containing the width and height of the primary monitor as two `i64` values.
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let resolution = monitor::primary_resolution();
-print(resolution); // Output: [width, height]
-```
-
-
-
-
-
-
-
fn primary_resolution_str
-
-```rust,ignore
-fn primary_resolution_str() -> String
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the resolution of the primary monitor as a string.
-
-
-
-Returns the resolution of the primary monitor as a string in the format "width x height".
-
-
-
-```js
-import "std::monitor" as monitor;
-
-let resolution_str = monitor::primary_resolution_str();
-print(resolution_str); // Output: "1920x1080"
-```
-
-
-
-
-
-
-# text
-
-```Namespace: global/std/text```
-
-
-
fn to_camel_case
-
-```rust,ignore
-fn to_camel_case(text: String) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Converts a string to camel case.
-
-
-
-* `text` - A string to be converted to camel case.
-
-
-
-Returns the `text` in camel case format.
-
-
-
-```js
-import "std::text" as text;
-
-let result = text::to_camel_case("hello world example");
-print(result); // output: "helloWorldExample"
-```
-
-
-
-
-
-
-
fn to_lower
-
-```rust,ignore
-fn to_lower(s: String) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Converts a string to lowercase.
-
-
-
-* `s` - A string to be converted to lowercase.
-
-
-
-Returns the string in lowercase.
-
-
-
-```js
-import "std::text" as text;
-
-let result = text::to_lower("HELLO");
-print(result); // output: "hello"
-```
-
-
-
-
-
-
-
fn to_slug
-
-```rust,ignore
-fn to_slug(text: String) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Converts a string to a slug (lowercase words joined by hyphens).
-
-
-
-* `text` - A string to be converted to a slug.
-
-
-
-Returns the `text` as a slug.
-
-
-
-```js
-import "std::text" as text;
-
-let result = text::to_slug("Hello World!");
-print(result); // output: "hello-world"
-```
-
-
-
-
-
-
-
fn to_upper
-
-```rust,ignore
-fn to_upper(s: String) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Converts a string to uppercase.
-
-
-
-* `s` - A string to be converted to uppercase.
-
-
-
-Returns the string in uppercase.
-
-
-
-```js
-import "std::text" as text;
-
-let result = text::to_upper("hello");
-print(result); // output: "HELLO"
-```
-
-
-
-
-
-
-
fn truncate_chars
-
-```rust,ignore
-fn truncate_chars(text: String, max_chars: int) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Truncates a string to the specified number of characters.
-
-
-
-* `text` - A string to be truncated.
-* `max_chars` - The maximum number of characters to keep in the string.
-
-
-
-Returns a truncated string.
-
-
-
-```js
-import "std::text" as text;
-
-let result = text::truncate_chars("Hello World!", 5);
-print(result); // output: "Hello"
-```
-
-
-
-
-
-
-# command
-
-```Namespace: global/std/command```
-
-
-
fn run
-
-```rust,ignore
-fn run(cmd: String)
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Executes a shell command without capturing the output.
-
-
-
-* `cmd` - The shell command to execute as a string.
-
-
-
-This function returns nothing if the command executes successfully. If there is an error
-running the command, it returns the error.
-
-
-
-```js
-import "std::command" as cmd;
-
-// Run a shell command (e.g., list directory contents)
-cmd::run("ls -l");
-```
-
-
-
-
-
-
-
fn run_and_read
-
-```rust,ignore
-fn run_and_read(cmd: String) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Executes a shell command and captures its output.
-
-
-
-* `cmd` - The shell command to execute as a string.
-
-
-
-This function returns the standard output of the command as a `string`. If the command fails,
-it returns the error.
-
-
-
-```js
-import "std::command" as cmd;
-
-// Run a shell command and capture its output
-let output = cmd::run_and_read("echo 'Hello, world!'");
-print(output); // output: Hello, world!
-```
-
-
-
-
-
-
-# env
-
-```Namespace: global/std/env```
-
-
-
fn get_current_dir
-
-```rust,ignore
-fn get_current_dir() -> String
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the current working directory.
-
-
-
-This function returns the current working directory as a `String`. If there is an error
-(e.g., if the path cannot be retrieved), it returns a `Result::Err` with the error message.
-
-
-
-```js
-import "std::env" as env;
-
-// Get the current working directory
-let current_dir = env::get_current_dir();
-print(current_dir); // output: /home/username/project
-```
-
-
-
-
-
-
-
fn get_env
-
-```rust,ignore
-fn get_env(var: String) -> String
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the value of an environment variable.
-
-
-
-* `var` - The name of the environment variable to retrieve.
-
-
-
-This function returns the value of the environment variable as a `String`.
-If the variable is not found or there is an error, it returns a `Result::Err` with the error message.
-
-
-
-```js
-import "std::env" as env;
-
-// Get the value of the "HOME" environment variable
-let home_dir = env::get_env("HOME");
-print(home_dir); // output: /home/username
-```
-
-
-
-
-
-
-
fn get_home_dir
-
-```rust,ignore
-fn get_home_dir() -> String
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the path to the home directory.
-
-
-
-This function returns the value of the "HOME" environment variable as a `String`.
-If the variable is not found or there is an error, it returns a `Result::Err` with the error message.
-
-
-
-```js
-import "std::env" as env;
-
-// Get the home directory
-let home_dir = env::get_home_dir();
-print(home_dir); // output: /home/username
-```
-
-
-
-
-
-
-
fn get_username
-
-```rust,ignore
-fn get_username() -> String
-```
-
-
-
-
-Description
-
-
-Returns
-
-
-Example
-
-
-
-
-Get the current username.
-
-
-
-This function returns the value of the "USER" environment variable as a `String`.
-If the variable is not found or there is an error, it returns a `Result::Err` with the error message.
-
-
-
-```js
-import "std::env" as env;
-
-// Get the username of the current user
-let username = env::get_username();
-print(username); // output: username
-```
-
-
-
-
-
-
-
fn set_env
-
-```rust,ignore
-fn set_env(var: String, value: String)
-```
-
-
-
-
-Description
-
-
-Arguments
-
-
-Returns
-
-
-Example
-
-
-
-
-Set the value of an environment variable.
-
-
-
-* `var` - The name of the environment variable to set.
-* `value` - The value to assign to the environment variable.
-
-
-
-This function does not return a value.
-
-
-
-```js
-import "std::env" as env;
-
-// Set the value of the "MY_VAR" environment variable
-env::set_env("MY_VAR", "SomeValue");
-```
-
-
-
-
-
+# Std Library