use std::sync::Arc;

use crate::module::{FunctionModule, FunctionSpec, register_fn};

pub fn module() -> FunctionModule {
    FunctionModule::builder("strings")
        .doc("Basic string helpers.")
        .function(FunctionSpec::new(
            "strings",
            "uppercase",
            "Uppercase the provided string.",
            vec![String::from("value")],
            "String",
        ))
        .build(|runtime, _params| {
            register_fn(
                runtime,
                "strings_uppercase",
                "Uppercase the provided string.",
                &["value"],
                strings_uppercase,
            )
        })
}

fn strings_uppercase(value: Arc<str>) -> Arc<str> {
    value.to_uppercase().into()
}
