Expand description
WebAssembly API for Batuta
Provides JavaScript-friendly interfaces for core Batuta functionality that operates on in-memory code without file system access.
§Features
- Language Detection: Analyze code snippets to detect languages
- Backend Selection: Recommend optimal compute backend (SIMD/GPU)
- NumPy Conversion: Convert NumPy operations to Trueno
- sklearn Conversion: Convert sklearn algorithms to Aprender
- PyTorch Conversion: Convert PyTorch operations to Realizar
- Code Analysis: PARF pattern detection and analysis
§Example (JavaScript)
import init, { analyze_code, convert_numpy, backend_recommend } from './batuta.js';
await init();
// Detect language
const analysis = analyze_code("import numpy as np\nx = np.array([1, 2, 3])");
console.log(analysis.language); // "Python"
// Convert NumPy to Trueno
const conversion = convert_numpy("np.add(a, b)");
console.log(conversion.rust_code);
// Get backend recommendation
const backend = backend_recommend("matmul", 1024);
console.log(backend); // "SIMD" or "GPU"Structs§
- Analysis
Result - Analysis result for code snippets
- Conversion
Result - Conversion result for code transformations
Functions§
- analyze_
code - Analyze code snippet and detect language and dependencies
- backend_
recommend - Get backend recommendation for an operation
- convert_
numpy - Convert NumPy operation to Trueno Rust code
- convert_
pytorch - Convert PyTorch operation to Realizar Rust code
- convert_
sklearn - Convert sklearn algorithm to Aprender Rust code
- version
- Get Batuta version
- wasm_
init - Initialize the WASM module (sets panic hook for better error messages)