Files
wasm-overhead-research/implementations/quickjs/transform.js
Tristan Cartledge 205a80e421 feat: optimize QuickJS implementation for minimal size
- Remove hardcoded JavaScript code and default transformation
- Make JavaScript code required as command-line argument
- Streamline dependencies (remove wasm-bindgen, serde, web-sys)
- Convert from library to binary target for cleaner WASI execution
- Update binary size: 718KB raw, 285KB gzipped
- Maintain full Wasmer compatibility and flexibility
- Update all documentation with correct sizes
- Uses QuickJS-NG (Next Generation) JavaScript engine
2025-08-18 15:18:43 +10:00

26 lines
732 B
JavaScript

// Sample JavaScript transformation function for QuickJS WASI
// This file can be executed with: wasmer run quickjs.wasm transform.js
// Parse the input data (available as global variable 'inputData')
const data = JSON.parse(inputData);
// Transform the data
const result = {
message: "Data has been processed by QuickJS WASI",
original: data,
timestamp: new Date().toISOString(),
transformed: true,
engine: "QuickJS-WASI-Dynamic",
};
// If there's a users array, increment ages
if (data.users && Array.isArray(data.users)) {
result.users = data.users.map((user) => ({
...user,
age: typeof user.age === "number" ? user.age + 1 : user.age,
}));
}
// Return the result as JSON string
JSON.stringify(result);