mirror of
https://github.com/LukeHagar/wasm-overhead-research.git
synced 2025-12-06 04:22:06 +00:00
- 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
26 lines
732 B
JavaScript
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);
|