czv/czv-wasm
2024-06-20 20:13:34 -04:00
..
examples docs: add WASM library demo using Vite & React 2024-06-20 20:13:34 -04:00
src docs: add WASM library demo using Vite & React 2024-06-20 20:13:34 -04:00
tests refactor: use options object for WASM function args, improve docs 2024-06-20 16:28:53 -04:00
Cargo.toml refactor: use options object for WASM function args, improve docs 2024-06-20 16:28:53 -04:00
README.md docs: add WASM library demo using Vite & React 2024-06-20 20:13:34 -04:00

czv-wasm

WebAssembly (JavaScript and TypeScript) library for czv. czv is a library of CSV-related operations for data engineering and analysis tasks.

Installation and example

bun install czv-wasm

Or use npm, pnpm, or yarn instead of bun.

The following example is written in TypeScript:

import init, * as czv from "czv-wasm";
// Must run `await init()` or `initSync()` first for web use
await init();

const data = `fruits,price
apple,2.50
banana,3.00
strawberry,1.50`;

const output: number = czv.rowCount({
    file_data: data,
    include_header_row: true,
});

console.log(output);

Development

You must have wasm-pack installed. If you have Cargo installed you may run:

cargo install wasm-pack

Build WASM for web

wasm-pack build --release --target web

Note: Currently you must modify the pkg/package.json by replacing the name from czv-wasm to czv.

Test WASM for browser

wasm-pack test --firefox --release

You may replace --firefox with another browser such as --chrome and --safari.

Publish package to npmjs.com

Getting a Package name too similar to existing package csv when trying to publish the package as czv so we publish the package as czv-wasm.

  1. Build the pkg folder with wasm-pack build --release --target web.
  2. Run cd pkg.
  1. Run npm pkg fix as suggested.
  2. Run npm publish.