3 releases
0.1.3 | Mar 7, 2025 |
---|---|
0.1.2 | Mar 7, 2025 |
0.1.1 | Mar 7, 2025 |
0.1.0 |
|
#291 in WebAssembly
314 downloads per month
6KB
52 lines
NanoId for wasm
Usage
# Cargo.toml
[dependencies]
nanoid-wasm = { path="../../nanoid-wasm", features=["not-wasm"] }
// in_your_rust.rs
use nanoid_wasm::nanoid;
let size = 21;
let id: String = nanoid!(); // 21 characters
println!("{}", id); // some random id with 21 characters;
let id: String = nanoid!(8); // 8 characters
println!("{}", id);
let id = nanoid!(5, &['a', 'b', 'c', 'd']); // 5 characters among ['a', 'b', 'c', 'd']
println!("{}", id);
Features
There are only two features: wasm
and not-wasm
.
Default feature imports nothing. Must designate either of wasm
or not-wasm
.
Demo Page (with leptos)
https://acheul.github.io/nanoid-wasm/
Also Look
- crate nanoid
- crate uuid
- They supports
js
feature for wasm environment.
- They supports
Dependencies
~0–480KB