glendix/js/object

Creates and manipulates typed JavaScript object handles.

Types

Represents a JavaScript boolean value.

pub type JsBoolean {
  TrueValue
  FalseValue
}

Constructors

  • TrueValue

    JavaScript true.

  • FalseValue

    JavaScript false.

Represents a JavaScript constructor handle.

pub type JsConstructor

Represents a JavaScript object handle.

pub type JsObject

Represents a JavaScript value whose runtime shape is intentionally opaque.

pub type JsValue

Values

pub fn bool(value value: JsBoolean) -> JsValue

Converts a typed JavaScript boolean into a JavaScript value.

pub fn call_method(
  on object: JsObject,
  named method: String,
  with arguments: List(JsValue),
) -> JsValue

Calls an object method with a list of arguments.

pub fn call_method_without_arguments(
  on object: JsObject,
  named method: String,
) -> JsValue

Calls an object method without arguments.

pub fn delete(from object: JsObject, key key: String) -> JsObject

Deletes an object property and returns the same object handle.

pub fn empty() -> JsObject

Creates an empty object.

pub fn float(value value: Float) -> JsValue

Converts a float into a JavaScript value.

pub fn from_entries(
  entries entries: List(#(String, JsValue)),
) -> JsObject

Creates an object from key-value entries.

pub fn from_object(object object: JsObject) -> JsValue

Converts an object handle into a JavaScript value.

pub fn get(from object: JsObject, key key: String) -> JsValue

Reads an object property.

pub fn has(in object: JsObject, key key: String) -> Bool

Reports whether an object has the given property.

pub fn int(value value: Int) -> JsValue

Converts an integer into a JavaScript value.

pub fn new_instance(
  using constructor: JsConstructor,
  with arguments: List(JsValue),
) -> JsObject

Creates an object with JavaScript’s new operator.

pub fn set(
  on object: JsObject,
  key key: String,
  to value: JsValue,
) -> JsObject

Mutates an object property and returns the same object handle.

pub fn string(value value: String) -> JsValue

Converts a string into a JavaScript value.

Search Document