moonbit-community/rabbita/js does not have a README file

    Cast

    pub(open) trait Cast {
    into(Value) -> Self?
    from(Self) -> Value
    }

    Performs a checked cast from a Value to a Self? type.

    This trait abstracts a function that ensures the cast is valid and returns null if the cast fails. It is useful for safely handling dynamic types in MoonBit.
    impl Cast for Bool
    impl Cast for Int
    impl Cast for Double
    impl Cast for String
    impl Cast for Array[A]

    Error_

    pub suberror Error_ {
    Error_(Value)
    }

    impl Show for Error_

    Error_::cause

    fn Error_::cause(self : Error_) -> Value?

    Error_::wrap

    fn[T] Error_::wrap(op : () -> Value, map_ok? : (Value) -> T) -> T raise Error_

    Nullable

    type Nullable[_]

    Nullable::from_option

    fn[T] Nullable::from_option(value : T?) -> Nullable[T]

    Nullable::get_exn

    #deprecated("get_exn does not check for null values. Use unwrap instead")
    fn[T] Nullable::get_exn(self : Nullable[T]) -> T

    Nullable::is_null

    fn[T] Nullable::is_null(self : Nullable[T]) -> Bool

    Nullable::null

    fn[T] Nullable::null() -> Nullable[T]

    Nullable::to_option

    fn[T] Nullable::to_option(self : Nullable[T]) -> T?

    Nullable::unwrap

    fn[T] Nullable::unwrap(self : Nullable[T]) -> T

    Unwraps the nullable value, panicking if it is null.

    Object

    pub struct Object(Value)

    Object::extend_iter

    fn[K, V] Object::extend_iter(self : Object, it : Iter[(K, V)]) -> Unit

    Object::extend_iter2

    fn[K, V] Object::extend_iter2(self : Object, it : Iter2[K, V]) -> Unit

    Object::extend_object

    fn Object::extend_object(self : Object, obj : Object) -> Object

    Object::from_iter

    fn[K, V] Object::from_iter(it : Iter[(K, V)]) -> Object

    Object::from_iter2

    fn[K, V] Object::from_iter2(it : Iter2[K, V]) -> Object

    Object::from_value

    fn Object::from_value(value : Value) -> Optional[Object]

    Object::from_value_unchecked

    fn Object::from_value_unchecked(value : Value) -> Object

    Object::new

    fn Object::new() -> Object

    Object::op_get

    fn[K, V] Object::op_get(self : Object, key : K) -> V

    Object::op_set

    fn[K, V] Object::op_set(self : Object, key : K, value : V) -> Unit

    Object::to_value

    fn Object::to_value(self : Object) -> Value

    Optional

    type Optional[_]

    Optional::from_option

    fn[T] Optional::from_option(value : T?) -> Optional[T]

    Optional::get_exn

    #deprecated("get_exn does not check for undefined values. Use unwrap instead")
    fn[T] Optional::get_exn(self : Optional[T]) -> T

    Optional::is_undefined

    fn[T] Optional::is_undefined(self : Optional[T]) -> Bool

    Optional::to_option

    fn[T] Optional::to_option(self : Optional[T]) -> T?

    Optional::undefined

    fn[T] Optional::undefined() -> Optional[T]

    Optional::unwrap

    fn[T] Optional::unwrap(self : Optional[T]) -> T

    Unwraps the optional value, panicking if it is undefined.

    Promise

    #external
    pub type Promise

    Safety

    You should always Promise::wait on any Promise you own to attach exception handlers, as long as you are responsible for the control flow (i.e. this Promise is not handled by an external JavaScript API). This makes sure that when the operation in the this Promise errs out, the error is caught by the MoonBit runtime.

    Promise::all

    fn Promise::all(promises : Array[Promise]) -> Promise

    Note

    The return type is guaranteed to be a Promise of an Array, but we omit that detail for simplicity.

    Promise::unsafe_new

    fn[T] Promise::unsafe_new(op : async () -> T) -> Promise

    Safety

    You should always Promise::wait on the result of this function to attach exception handlers, as long as you are responsible for the control flow (i.e. the resulting Promise is not handled by an external JavaScript API). This makes sure that when op errs out, the error is caught by the MoonBit runtime.

    If you don't care about the result of the operation, you can use spawn_detach instead.

    Promise::wait

    async fn Promise::wait(self : Promise) -> Value

    Symbol

    type Symbol

    Symbol::make

    fn Symbol::make() -> Symbol

    Symbol::make_with_number

    fn Symbol::make_with_number(num : Double) -> Symbol

    Symbol::make_with_string

    fn Symbol::make_with_string(value : String) -> Symbol

    Symbol::make_with_string_js

    fn Symbol::make_with_string_js(value : String) -> Symbol

    Union2

    type Union2[_, _]

    Union type A | B for JavaScript values.

    Union2::from0

    fn[A : Cast, B] Union2::from0(value : A) -> Union2[A, B]

    Union2::from1

    fn[A, B : Cast] Union2::from1(value : B) -> Union2[A, B]

    Union2::to0

    fn[A : Cast, B] Union2::to0(self : Union2[A, B]) -> A?

    Union2::to1

    fn[A, B : Cast] Union2::to1(self : Union2[A, B]) -> B?

    Union3

    type Union3[_, _, _]

    Union type A | B | C for JavaScript values.

    Union3::from0

    fn[A : Cast, B, C] Union3::from0(value : A) -> Union3[A, B, C]

    Union3::from1

    fn[A, B : Cast, C] Union3::from1(value : B) -> Union3[A, B, C]

    Union3::from2

    fn[A, B, C : Cast] Union3::from2(value : C) -> Union3[A, B, C]

    Union3::to0

    fn[A : Cast, B, C] Union3::to0(self : Union3[A, B, C]) -> A?

    Union3::to1

    fn[A, B : Cast, C] Union3::to1(self : Union3[A, B, C]) -> B?

    Union3::to2

    fn[A, B, C : Cast] Union3::to2(self : Union3[A, B, C]) -> C?

    Union4

    type Union4[_, _, _, _]

    Union type A | B | C | D for JavaScript values.

    Union4::from0

    fn[A : Cast, B, C, D] Union4::from0(value : A) -> Union4[A, B, C, D]

    Union4::from1

    fn[A, B : Cast, C, D] Union4::from1(value : B) -> Union4[A, B, C, D]

    Union4::from2

    fn[A, B, C : Cast, D] Union4::from2(value : C) -> Union4[A, B, C, D]

    Union4::from3

    fn[A, B, C, D : Cast] Union4::from3(value : D) -> Union4[A, B, C, D]

    Union4::to0

    fn[A : Cast, B, C, D] Union4::to0(self : Union4[A, B, C, D]) -> A?

    Union4::to1

    fn[A, B : Cast, C, D] Union4::to1(self : Union4[A, B, C, D]) -> B?

    Union4::to2

    fn[A, B, C : Cast, D] Union4::to2(self : Union4[A, B, C, D]) -> C?

    Union4::to3

    fn[A, B, C, D : Cast] Union4::to3(self : Union4[A, B, C, D]) -> D?

    Union5

    type Union5[_, _, _, _, _]

    Union type A | B | C | D | E for JavaScript values.

    Union5::from0

    fn[A : Cast, B, C, D, E] Union5::from0(value : A) -> Union5[A, B, C, D, E]

    Union5::from1

    fn[A, B : Cast, C, D, E] Union5::from1(value : B) -> Union5[A, B, C, D, E]

    Union5::from2

    fn[A, B, C : Cast, D, E] Union5::from2(value : C) -> Union5[A, B, C, D, E]

    Union5::from3

    fn[A, B, C, D : Cast, E] Union5::from3(value : D) -> Union5[A, B, C, D, E]

    Union5::from4

    fn[A, B, C, D, E : Cast] Union5::from4(value : E) -> Union5[A, B, C, D, E]

    Union5::to0

    fn[A : Cast, B, C, D, E] Union5::to0(self : Union5[A, B, C, D, E]) -> A?

    Union5::to1

    fn[A, B : Cast, C, D, E] Union5::to1(self : Union5[A, B, C, D, E]) -> B?

    Union5::to2

    fn[A, B, C : Cast, D, E] Union5::to2(self : Union5[A, B, C, D, E]) -> C?

    Union5::to3

    fn[A, B, C, D : Cast, E] Union5::to3(self : Union5[A, B, C, D, E]) -> D?

    Union5::to4

    fn[A, B, C, D, E : Cast] Union5::to4(self : Union5[A, B, C, D, E]) -> E?

    Union6

    type Union6[_, _, _, _, _, _]

    Union type A | B | C | D | E | F for JavaScript values.

    Union6::from0

    fn[A : Cast, B, C, D, E, F] Union6::from0(value : A) -> Union6[A, B, C, D, E, F]

    Union6::from1

    fn[A, B : Cast, C, D, E, F] Union6::from1(value : B) -> Union6[A, B, C, D, E, F]

    Union6::from2

    fn[A, B, C : Cast, D, E, F] Union6::from2(value : C) -> Union6[A, B, C, D, E, F]

    Union6::from3

    fn[A, B, C, D : Cast, E, F] Union6::from3(value : D) -> Union6[A, B, C, D, E, F]

    Union6::from4

    fn[A, B, C, D, E : Cast, F] Union6::from4(value : E) -> Union6[A, B, C, D, E, F]

    Union6::from5

    fn[A, B, C, D, E, F : Cast] Union6::from5(value : F) -> Union6[A, B, C, D, E, F]

    Union6::to0

    fn[A : Cast, B, C, D, E, F] Union6::to0(self : Union6[A, B, C, D, E, F]) -> A?

    Union6::to1

    fn[A, B : Cast, C, D, E, F] Union6::to1(self : Union6[A, B, C, D, E, F]) -> B?

    Union6::to2

    fn[A, B, C : Cast, D, E, F] Union6::to2(self : Union6[A, B, C, D, E, F]) -> C?

    Union6::to3

    fn[A, B, C, D : Cast, E, F] Union6::to3(self : Union6[A, B, C, D, E, F]) -> D?

    Union6::to4

    fn[A, B, C, D, E : Cast, F] Union6::to4(self : Union6[A, B, C, D, E, F]) -> E?

    Union6::to5

    fn[A, B, C, D, E, F : Cast] Union6::to5(self : Union6[A, B, C, D, E, F]) -> F?

    Union7

    type Union7[_, _, _, _, _, _, _]

    Union type A | B | C | D | E | F | G for JavaScript values.

    Union7::from0

    fn[A : Cast, B, C, D, E, F, G] Union7::from0(value : A) -> Union7[A, B, C, D, E, F, G]

    Union7::from1

    fn[A, B : Cast, C, D, E, F, G] Union7::from1(value : B) -> Union7[A, B, C, D, E, F, G]

    Union7::from2

    fn[A, B, C : Cast, D, E, F, G] Union7::from2(value : C) -> Union7[A, B, C, D, E, F, G]

    Union7::from3

    fn[A, B, C, D : Cast, E, F, G] Union7::from3(value : D) -> Union7[A, B, C, D, E, F, G]

    Union7::from4

    fn[A, B, C, D, E : Cast, F, G] Union7::from4(value : E) -> Union7[A, B, C, D, E, F, G]

    Union7::from5

    fn[A, B, C, D, E, F : Cast, G] Union7::from5(value : F) -> Union7[A, B, C, D, E, F, G]

    Union7::from6

    fn[A, B, C, D, E, F, G : Cast] Union7::from6(value : G) -> Union7[A, B, C, D, E, F, G]

    Union7::to0

    fn[A : Cast, B, C, D, E, F, G] Union7::to0(self : Union7[A, B, C, D, E, F, G]) -> A?

    Union7::to1

    fn[A, B : Cast, C, D, E, F, G] Union7::to1(self : Union7[A, B, C, D, E, F, G]) -> B?

    Union7::to2

    fn[A, B, C : Cast, D, E, F, G] Union7::to2(self : Union7[A, B, C, D, E, F, G]) -> C?

    Union7::to3

    fn[A, B, C, D : Cast, E, F, G] Union7::to3(self : Union7[A, B, C, D, E, F, G]) -> D?

    Union7::to4

    fn[A, B, C, D, E : Cast, F, G] Union7::to4(self : Union7[A, B, C, D, E, F, G]) -> E?

    Union7::to5

    fn[A, B, C, D, E, F : Cast, G] Union7::to5(self : Union7[A, B, C, D, E, F, G]) -> F?

    Union7::to6

    fn[A, B, C, D, E, F, G : Cast] Union7::to6(self : Union7[A, B, C, D, E, F, G]) -> G?

    Union8

    type Union8[_, _, _, _, _, _, _, _]

    Union type A | B | C | D | E | F | G | H for JavaScript values.

    Union8::from0

    fn[A : Cast, B, C, D, E, F, G, H] Union8::from0(value : A) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from1

    fn[A, B : Cast, C, D, E, F, G, H] Union8::from1(value : B) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from2

    fn[A, B, C : Cast, D, E, F, G, H] Union8::from2(value : C) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from3

    fn[A, B, C, D : Cast, E, F, G, H] Union8::from3(value : D) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from4

    fn[A, B, C, D, E : Cast, F, G, H] Union8::from4(value : E) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from5

    fn[A, B, C, D, E, F : Cast, G, H] Union8::from5(value : F) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from6

    fn[A, B, C, D, E, F, G : Cast, H] Union8::from6(value : G) -> Union8[A, B, C, D, E, F, G, H]

    Union8::from7

    fn[A, B, C, D, E, F, G, H : Cast] Union8::from7(value : H) -> Union8[A, B, C, D, E, F, G, H]

    Union8::to0

    fn[A : Cast, B, C, D, E, F, G, H] Union8::to0(self : Union8[A, B, C, D, E, F, G, H]) -> A?

    Union8::to1

    fn[A, B : Cast, C, D, E, F, G, H] Union8::to1(self : Union8[A, B, C, D, E, F, G, H]) -> B?

    Union8::to2

    fn[A, B, C : Cast, D, E, F, G, H] Union8::to2(self : Union8[A, B, C, D, E, F, G, H]) -> C?

    Union8::to3

    fn[A, B, C, D : Cast, E, F, G, H] Union8::to3(self : Union8[A, B, C, D, E, F, G, H]) -> D?

    Union8::to4

    fn[A, B, C, D, E : Cast, F, G, H] Union8::to4(self : Union8[A, B, C, D, E, F, G, H]) -> E?

    Union8::to5

    fn[A, B, C, D, E, F : Cast, G, H] Union8::to5(self : Union8[A, B, C, D, E, F, G, H]) -> F?

    Union8::to6

    fn[A, B, C, D, E, F, G : Cast, H] Union8::to6(self : Union8[A, B, C, D, E, F, G, H]) -> G?

    Union8::to7

    fn[A, B, C, D, E, F, G, H : Cast] Union8::to7(self : Union8[A, B, C, D, E, F, G, H]) -> H?

    Value

    #external
    pub type Value

    impl Show for Value

    Value::apply

    fn[Arg, Result] Value::apply(self : Value, args : Array[Arg]) -> Result

    self(...args)

    Value::apply_with_index

    fn[Arg, Result] Value::apply_with_index(self : Value, index : Int, args : Array[Arg]) -> Result

    self[index](...args)

    Value::apply_with_string

    fn[Arg, Result] Value::apply_with_string(self : Value, key : String, args : Array[Arg]) -> Result

    self[key](...args)

    Value::apply_with_symbol

    fn[Arg, Result] Value::apply_with_symbol(self : Value, key : Symbol, args : Array[Arg]) -> Result

    self[key](...args)

    Value::cast

    fn[T] Value::cast(self : Value) -> T

    Value::cast_from

    fn[T] Value::cast_from(value : T) -> Value

    Value::extends

    fn Value::extends(self : Value, parent_constructor : Value) -> Value

    @param self The constructor function that accepts this as the first argument

    Value::from_json

    fn Value::from_json(json : Json) -> Value raise

    Value::from_json_string

    fn Value::from_json_string(str : String) -> Value raise

    Value::get_with_index

    fn[T] Value::get_with_index(self : Value, index : Int) -> T

    Value::get_with_string

    fn[T] Value::get_with_string(self : Value, key : String) -> T

    Value::get_with_symbol

    fn[T] Value::get_with_symbol(self : Value, key : Symbol) -> T

    Value::is_bool

    fn Value::is_bool(self : Value) -> Bool

    Value::is_null

    fn Value::is_null(self : Value) -> Bool

    Value::is_number

    fn Value::is_number(self : Value) -> Bool

    Value::is_object

    fn Value::is_object(self : Value) -> Bool

    Value::is_string

    fn Value::is_string(self : Value) -> Bool

    Value::is_symbol

    fn Value::is_symbol(self : Value) -> Bool

    Value::is_undefined

    fn Value::is_undefined(self : Value) -> Bool

    Value::new

    fn[Arg, Result] Value::new(self : Value, args : Array[Arg]) -> Result

    new self(...args)

    Value::new_with_index

    fn[Arg, Result] Value::new_with_index(self : Value, index : Int, args : Array[Arg]) -> Result

    new self[index](...args)

    Value::new_with_string

    fn[Arg, Result] Value::new_with_string(self : Value, key : String, args : Array[Arg]) -> Result

    new self[key](...args)

    Value::new_with_symbol

    fn[Arg, Result] Value::new_with_symbol(self : Value, key : Symbol, args : Array[Arg]) -> Result

    new self[key](...args)

    Value::set_with_index

    fn[T] Value::set_with_index(self : Value, index : Int, value : T) -> Unit

    Value::set_with_string

    fn[T] Value::set_with_string(self : Value, key : String, value : T) -> Unit

    Value::set_with_symbol

    fn[T] Value::set_with_symbol(self : Value, key : Symbol, value : T) -> Unit

    Value::to_json

    fn Value::to_json(self : Value) -> Json raise

    Value::to_json_string

    fn Value::to_json_string(self : Value) -> String raise

    Value::to_string

    fn Value::to_string(self : Value) -> String

    async_all

    async fn[T] async_all(ops : Array[async () -> T]) -> Array[T]

    Wraps each given async fn in a Promise and waits for all of them to resolve.

    async_iterator

    let async_iterator : Symbol

    async_run

    fn async_run(f : async () -> Unit noraise) -> Unit

    async_test

    fn async_test(op : async () -> Unit) -> Unit

    globalThis

    let globalThis : Value

    iterator

    let iterator : Symbol

    require

    fn require(path : String, keys? : Array[String]) -> Value

    spawn_detach

    fn[T, E : Error] spawn_detach(op : async () -> T raise E) -> Unit

    suspend

    async fn[T, E : Error] suspend(f : ((T) -> Unit, (E) -> Unit) -> Unit) -> T raise E