rust-inventory-processor
v0.1.1
Published
Rust/WASM inventory history processor for TypeScript
Downloads
47
Readme
rust-inventory-processor
Rust/WASM implementation of inventory history processor for TypeScript. Processes inventory history data and returns merged entries with storage duration.
Build
# Prerequisites
rustup default stable
rustup target add wasm32-unknown-unknown
cargo install wasm-pack # or: cargo install wasm-pack --version 0.12.1
# Build WASM (Node.js backend)
wasm-pack build --target nodejs --features wasmOutput: pkg/ with rust_inventory_processor.js, rust_inventory_processor_bg.wasm, rust_inventory_processor.d.ts
Test
# Rust test (native, no WASM runtime)
cargo test --features wasm wasm_process -- --nocapture
# Node test with sample data
node scripts/test-wasm.mjs
node scripts/test-wasm.mjs tests/data/sample-input.jsonUse in TypeScript
# Add to package.json
"rust-inventory-processor": "file:../rust-implement/pkg"
# Or after publish to npm
npm install rust-inventory-processorimport { loadRustInventoryProcessor } from './processor/inventory-history-processor.wasm-loader'
// On app bootstrap
await loadRustInventoryProcessor()Publish to npm
wasm-pack build --target nodejs --features wasm
wasm-pack publish --access publicProject structure
rust-implement/
├── Cargo.toml
├── src/
│ ├── lib.rs # Entry, re-exports
│ ├── wasm.rs # WASM bindings, JSON conversion
│ └── process_inventory_list.rs # Core logic
├── tests/
│ ├── wasm_test.rs # Rust test
│ └── data/
│ ├── sample-input.json
│ └── sample-input-snake.json
├── scripts/
│ └── test-wasm.mjs # Node test script
├── pkg/ # Output (after wasm-pack build)
└── WASM_BUILD_GUIDE.md # Detailed guideLicense
MIT
