-
-
Notifications
You must be signed in to change notification settings - Fork 47
Supports wasm and can be used in the browser or node #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I tried embedding mail-parser as a wasm module in a Vite React+TS project and it was frictionless and took very little time.
use mail_parser::MessageParser;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn from(raw_message: &str) -> Option<String> {
if let Some(message) = MessageParser::default().parse(raw_message) {
if let Some(from) = message.from() {
if let Some(first) = from.first() {
if let Some(addr) = &first.address {
return Some(addr.clone().into_owned());
}
}
};
}
return None;
}
import "./App.css";
import init, { from } from "./pkg/wasm";
init();
function App() {
return (
<>
<button
onClick={async () => {
const content = await fetch("email").then((res) => res.text());
alert(from(content));
}}
>
Parse
</button>
</>
);
} |
Is there a standalone npm wasm package available? |
I think it would be counter-intuitive, since the wasm embedding process is usually concerned with bundle size and I'm not sure if a wasm package would be tree-shakeable in terms of the compiled wasm code. |
I am a front-end developer, and there is a lack of high-performance mail-related parsers. A zero-dependency mail parser is just right! expect
The text was updated successfully, but these errors were encountered: