WA

A modern Rust, WebAssembly, FFI utility library.

Inspired by JavaScript Lodash library.

No dependencies.

Installation

Add wa to your dependencies on Cargo.toml. You need to set the features that will be used as well:

shell wa = { version = "0.2.0", features = ["string", "vector", "array"] }

Why?

Wa makes Rust easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. Wa’s modular methods are great for:

Features

String

#[cfg(feature = "string")]

template

(String) Creates a compiled template function that can interpolate data properties in "interpolate" delimiters

Example:

```rust use std::collections::HashMap; use wa::string::template;

let urltemplate = template("https://api.com/{ userid }/products/{ productid }".tostring()); let url: String = urltemplate(HashMap::from([ ("userid", "85"), ("product_id", "23"), ]));

assert_eq!(url, "https://api.com/85/products/23"); // true ```

replaceextendedascii

(String) replace extended ASCII codes to standards.

Example:

```rust use wa::string::replaceextendedascii;

asserteq!(replaceextendedascii("São Paulo".tostring()), "Sao Paulo"); asserteq!(replaceextendedascii("Água".tostring()), "Agua"); asserteq!(replaceextendedascii("Pão".tostring()), "Pao"); asserteq!(replaceextendedascii("Åke".tostring()), "Ake"); asserteq!(replaceextendedascii("Södermalm".tostring()), "Sodermalm"); asserteq!(replaceextendedascii("Rio de Janeiro".tostring()), "Rio de Janeiro"); ```

camel_case

(String) Converts the input string into Camel-Case format.

Note: All special characters will be removed and only valid letters remained.

To replace extended ASCII codes to standards, e.g: "ã" to "a". Check wa::string::replace_extended_ascii.

Example

```rust use wa::string::camel_case;

camelcase("São Paulo".tostring()); // "sãoPaulo" camelcase("Riode_JANEIRO".tostring()); // "rioDeJaneiro" camelcase("Rio de Janeiro".tostring()); // "rioDeJaneiro" camelcase("--stock-----holm--".tostring()); // "stockHolm" camelcase("--stock-----holm--".tostring()); // "stockHolm" camelcase("Rio2DE2janeiro".tostring()); // "rio2de2janeiro" ```

kebab_case

(String) Converts the input string into Kebab-Case format.

Note: All the special characters will be removed and only valid letters remained.

To replace extended ASCII codes to standards, e.g: "ã" to "a". Check wa::string::replace_extended_ascii.

Example

```rust use wa::string::kebab_case;

kebabcase("São Paulo".tostring()); // "são-paulo" kebabcase("Rio de Janeiro".tostring()); // "foo-bar" kebabcase("--rio--1--".tostring()); // "foo-bar" kebabcase("rIO-de-Janeiro".to_string()); // "f-oo-ba-r" ```

ends_with

(String) Checks if string ends with the given target string. Note: If position is not provided, it will search through the whole string by default.

Example:

rust use wa::string::ends_with; let is_ends_with = ends_with("abc".to_string(), "c".to_string(), None); // true let is_ends_with = ends_with("abc".to_string(), "b".to_string(), None); // false let is_ends_with = ends_with("abc".to_string(), "bc".to_string(), Some(2)); // false