// Access globalThis
let global = @global.globalThis()
// Get undefined
let undef = @global.undefined()// Check if value is NaN
let nan_val = @core.any(0.0 / 0.0)
@global.isNaN(nan_val) // true
// Check if value is finite
@global.isFinite(42.0) // true
@global.isFinite(1.0 / 0.0) // false (Infinity)// Parse integer with optional radix
@global.parseInt("42") // Some(42)
@global.parseInt("ff", radix=16) // Some(255)
@global.parseInt("invalid") // None
// Parse floating point
@global.parseFloat("3.14") // Some(3.14)
@global.parseFloat("1.5e2") // Some(150.0)
@global.parseFloat("invalid") // None// Encode to Base64
let encoded = @global.btoa("Hello World")
// "SGVsbG8gV29ybGQ="
// Decode from Base64
let decoded = @global.atob("SGVsbG8gV29ybGQ=")
// "Hello World"// Encode complete URI
let uri = @global.encodeURI("https://example.com/path?name=John Doe")
// "https://example.com/path?name=John%20Doe"
// Decode URI
let decoded = @global.decodeURI("https://example.com/path?name=John%20Doe")
// "https://example.com/path?name=John Doe"
// Encode URI component
let encoded = @global.encodeURIComponent("Hello World & Friends")
// "Hello%20World%20%26%20Friends"
// Decode URI component
let decoded = @global.decodeURIComponent("Hello%20World%20%26%20Friends")
// "Hello World & Friends"// Deep clone using structured clone algorithm
let obj = @core.new_object()
obj["name"] = @core.any("Alice")
obj["age"] = @core.any(30)
let cloned = @global.structuredClone(obj)
// Creates an independent deep copy// Set timeout
let timer = @global.setTimeout(fn() {
@console.log("Delayed!")
}, 1000)
// Clear timeout
@global.clearTimeout(timer)
// Set interval
let interval = @global.setInterval(fn() {
@console.log("Repeating!")
}, 1000)
// Clear interval
@global.clearInterval(interval)// Queue a microtask
@global.queueMicrotask(fn() {
@console.log("Microtask executed")
})// Dynamic import (returns Promise)
let module_promise = @global.dynamic_import("./module.js")// Functions that can raise errors
try {
let decoded = @global.atob("invalid base64!@#")
} catch {
err => @console.log("Decoding failed")
}pub type Timer // Represents a timer ID#external
pub type Timer#alias(docode_uri)
fn decodeURI(encoded_uri : String) -> String#alias(decode_uri_component)
fn decodeURIComponent(encoded_str : String) -> String#alias(encode_uri_component)
fn encodeURIComponent(str : String) -> String#alias(parse_float)
fn parseFloat(string : String) -> Double?#alias(parse_int)
fn parseInt(string : String, radix? : Int) -> Int?fn queueMicrotask(callback : () -> Unit) -> Unitjs bindings for builtins/web/node/deno/bun (browser APIs split to mizchi/js_browser)
Dependencies