Registry / serialization / mail-parser-wasm

mail-parser-wasm

JSON →
library0.2.2jsnpmunverified

mail-parser-wasm is a specialized WebAssembly module designed for efficiently parsing raw email messages into a structured format. Leveraging WASM, it aims to offer performance benefits over pure JavaScript parsing solutions, making it suitable for resource-sensitive environments like web browsers, Node.js servers, and serverless functions (e.g., Cloudflare Workers). The package is currently at version 0.2.2, indicating it's in an early development phase, suggesting a potentially agile release cadence with features and API changes expected. Its primary differentiator is the use of WebAssembly for core parsing logic, and it provides TypeScript types for enhanced developer experience and type safety.

npm install mail-parser-wasm
INSTALL
IMPORT
SIG · MAIL-PARSER-WASM
M
mail-parser-wasm
serializationjavascriptv0.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse_message
import { parse_message } from 'mail-parser-wasm';
const { parse_message } = require('mail-parser-wasm');
This library is designed as an ES module, leveraging WebAssembly. Direct CommonJS `require()` calls are not officially supported and may lead to issues or require specific bundler configurations for WASM module loading.
parse_message
import type { ParsedMail } from 'mail-parser-wasm';
The library ships with TypeScript types, enabling type-safe interaction with the parsed email structure, typically an object named 'ParsedMail' or similar.

Demonstrates importing and using `parse_message` to process a raw email string, logging key components like subject, sender, recipient, and body.

import { parse_message } from 'mail-parser-wasm'; // A raw email string in MIME format const rawEmailContent = `From: sender@example.com To: recipient@example.com Subject: Important Update Content-Type: text/plain; charset="UTF-8" Hello, This is a test email sent from the mail-parser-wasm quickstart example. Best regards, The Example Team `; try { const parsedEmail = parse_message(rawEmailContent); console.log('--- Parsed Email Details ---'); console.log('Subject:', parsedEmail.subject); console.log('From:', parsedEmail.from[0].address); console.log('To:', parsedEmail.to[0].address); console.log('Text Body:', parsedEmail.text); console.log('Headers:', parsedEmail.headers.map((h: any) => `${h.key}: ${h.value}`).join('\n')); } catch (error) { console.error('Error parsing email:', error); // Depending on the WASM module's error handling, the error might be a WebAssemblyRuntimeError }
Debug
Known issues
breakingAs a package in pre-1.0 development (version 0.2.2), breaking changes to the API surface, data structures, and module initialization are likely to occur between minor versions without prior deprecation cycles.
fix
Always pin exact versions in production environments. Consult the release notes and GitHub repository for changes when upgrading, and thorough testing is recommended.
affects: >=0.1.0
gotchaBeing a WebAssembly module, its loading and execution characteristics can differ from pure JavaScript. Environments (browsers, Node.js, workers) must properly support WASM, and web servers might need specific MIME types (`application/wasm`) for `.wasm` files.
fix
Ensure your environment and deployment infrastructure are configured for WebAssembly. For web servers, verify that `.wasm` files are served with the `Content-Type: application/wasm` header to prevent loading issues.
affects: >=0.1.0
gotchaThe documentation mentions `mail-parser-wasm-worker` as a separate, worker-specific package. While `mail-parser-wasm` might function in some worker contexts, `mail-parser-wasm-worker` is likely optimized for worker environments, handling nuances of WASM initialization and communication within workers.
fix
For applications heavily relying on Web Workers for email parsing, consider using `mail-parser-wasm-worker` for potentially better performance, easier integration, and specific worker optimizations, rather than directly using `mail-parser-wasm`.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: parse_message is not a function
Attempting to use `parse_message` as a CommonJS `require()` export in an environment expecting ES Modules, or an incorrect named import.
fix
Ensure you are using `import { parse_message } from 'mail-parser-wasm';` in an ES Module context. If in Node.js, verify your `package.json` `type` field is set to `module` or use `.mjs` file extensions.
Failed to instantiate WebAssembly module: CompileError: WebAssembly.instantiate(): LinkError: WebAssembly.instantiate(): Import #0 module="env" function="__wbindgen_string_new" error: global import must be a number or WebAssembly.Global object
This error often indicates an issue with the WebAssembly runtime environment not correctly providing the necessary imports that the Rust-generated WASM module expects (via `wasm-bindgen`).
fix
This can sometimes be resolved by ensuring a compatible version of Node.js or browser is used, or verifying the correct `wasm-pack` build target (`--target nodejs`, `--target web`) was used for the environment. Ensure bundlers (like Webpack or Rollup) are configured to handle WASM imports correctly.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
mail-parser-wasm — npm install mail-parser-wasm · libregistry