This guide helps you choose between the two distribution entry points:
web-csv-toolbox (Main) — automatic WASM initialization with the WASM embedded in the bundleweb-csv-toolbox/slim (Slim) — manual WASM initialization with the WASM loaded as a separate assetImportant: There are no feature limitations in Slim. Both Main and Slim export the same full API and support the same functionality. The only differences are WASM initialization strategy and how the WASM binary is delivered/cached.
loadWASM() once at startup (optional but recommended).await loadWASM() before using WASM).| Aspect | Main | Slim |
|---|---|---|
| Initialization | Automatic (first-use) | Manual (await loadWASM()) |
| Bundle Size | Larger (WASM embedded) | Smaller (WASM external) |
| Caching | Together with JS | WASM separately cacheable |
| First Parse | Simple but may include auto-init cost | Preload WASM to avoid first-parse cost |
| Synchronous APIs | Available; first use may include auto‑init cost (preload recommended) | Available after loadWASM() |
| Worker + WASM | Supported | Supported |
| Typical Use | Dev/prototyping | Production / bundle optimization |
Notes:
" as quotation). The JavaScript parser supports broader options.Use the main entry (web-csv-toolbox) when:
loadWASM()Example (with optional preloading for faster first parse):
import { loadWASM, parseStringToArraySyncWASM } from 'web-csv-toolbox';
// Optional but recommended: preload at app startup to avoid first‑use init cost
await loadWASM();
const rows = parseStringToArraySyncWASM(csv);
Use the slim entry (web-csv-toolbox/slim) when:
Example (Node.js):
import { loadWASM, parseStringToArraySyncWASM } from 'web-csv-toolbox/slim';
await loadWASM();
const rows = parseStringToArraySyncWASM(csv);
Example (Vite):
import { loadWASM, parseString, EnginePresets } from 'web-csv-toolbox/slim';
import workerUrl from 'web-csv-toolbox/worker?url';
import wasmUrl from 'web-csv-toolbox/csv.wasm?url';
await loadWASM(wasmUrl);
for await (const r of parseString(csv, {
engine: EnginePresets.responsiveFast({ workerURL: workerUrl })
})) {
// ...
}
When using Workers and WASM together (e.g., EnginePresets.responsiveFast()):
workerURL to your bundler’s worker assetwasmUrl to loadWASM()await loadWASM() at startup reduces first‑parse latencyawait loadWASM() is required; on Node 20.6+ the loader resolves the WASM internally
loadWASM()EnginePresets for common execution modes (e.g., balanced(), responsiveFast())ReusableWorkerPool to bound concurrent workers; prefer using if your environment supports Explicit Resource Management, otherwise call pool.terminate()Main → Slim:
web-csv-toolbox/slimawait loadWASM() at app start (with bundlers, pass the emitted wasmUrl)workerURL to your bundler’s worker assetSlim → Main:
web-csv-toolboxloadWASM() (optional: keep it to reduce first-parse latency)?url with Vite, new URL() with Webpack)