diff --git a/.gitignore b/.gitignore
index 4fffb2f..5515872 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
+/pkg
/target
-/Cargo.lock
+/Cargo.lock
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 700716c..09639a9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "schmfy"
-version = "0.2.2"
+version = "0.3.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Schmfication library"
@@ -8,4 +8,8 @@ readme = "README.md"
repository = "https://git.flueren.eu/JonOfUs/Schmfy"
documentation = "https://docs.rs/schmfy"
+[lib]
+crate-type = ["cdylib"]
+
[dependencies]
+wasm-bindgen = "0.2"
diff --git a/README.md b/README.md
index ebf9274..4b45cdf 100644
--- a/README.md
+++ b/README.md
@@ -13,8 +13,10 @@ fn improve_text(text: &str) {
}
```
+The library can be compiled to WebAssembly. You will need wasm-pack (`cargo install wasm-pack`) and can then build the library with `wasm-pack build --target web`. This generates a `pkg` folder which can be used in web environments.
+
## Capabilities
The schmfication capabilities are able to preserve text case and any non-alphabetical characters.
If a non-alphabetical character is between two alphabetical strings, both of the alphabetical strings will be interpreted as completely separate words.
-For example, the HTML code `Entry
` will be converted into `Schmentry`.
\ No newline at end of file
+For example, the HTML code `Entry
` will be converted into `Schmentry`.
diff --git a/src/lib.rs b/src/lib.rs
index 6bab142..a2ff244 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,5 @@
//! schmfy - a library to schmfy everything
+use wasm_bindgen::prelude::*;
#[derive(PartialEq, Copy, Clone)]
enum CaseType {
@@ -63,6 +64,7 @@ fn restore_case(txt: String, case: CaseType) -> String {
}
/// Schmfies any str, preserving case and everything non-alphabetical
+#[wasm_bindgen]
pub fn schmfy(source: &str) -> String {
// instantly return if input is non-alphabetic single char
if source.len() == 1 && !source.chars().next().unwrap().is_alphabetic() {