WA
A modern Rust, WebAssembly, FFI utility library.
Inspired by JavaScript Lodash library.
No dependencies.
- Made for Rust
- Made for WebAssembly (check
wa-sm/wasmfolder) - Made for JavaScript and NodeJs (check
wa-smfolder) - Made for Foreign function interface
Installation
Add wa to your dependencies on Cargo.toml. You need to set the features that will be used as well:
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:
- Iterating arrays, objects, & strings
- Manipulating & testing values
- Creating composite functions
Features
string(Examples:cargo run --example strings)vector(Examples:cargo run --example vectors)array(Examples:cargo run --example arrays)util(Examples:cargo run --example utils)wasm(Examples:cargo run --example webassembly)
String
#[cfg(feature = "string")]
template_vec
(String) Creates a compiled template function that can interpolate data properties in "interpolate" delimiters using vector
Example
use template_vec;
let url_template = template_vec;
let url: String = url_template; // "https://api.com/85/products/23?by=85"
let url_2: String = url_template; // "https://api.com/23/products/85?by=23"
template
(String) Creates a compiled template function that can interpolate data properties in "interpolate" delimiters
Example:
use HashMap;
use template;
let url_template = template;
let url: String = url_template;
assert_eq!; // true
replace_extended_ascii
(String) replace extended ASCII codes to standards.
Example:
use replace_extended_ascii;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
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
use camel_case;
camel_case; // "sãoPaulo"
camel_case; // "rioDeJaneiro"
camel_case; // "rioDeJaneiro"
camel_case; // "stockHolm"
camel_case; // "stockHolm"
camel_case; // "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
use kebab_case;
kebab_case; // "são-paulo"
kebab_case; // "foo-bar"
kebab_case; // "foo-bar"
kebab_case; // "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:
use ends_with;
let is_ends_with = ends_with;
// true
let is_ends_with = ends_with;
// false
let is_ends_with = ends_with;
// false