{"name":"@webassemblyjs/wasm-edit","version":"1.14.1","description":"> Rewrite a WASM binary","main":"lib/index.js","module":"esm/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/xtuc/webassemblyjs.git"},"publishConfig":{"access":"public"},"author":{"name":"Sven Sauleau"},"license":"MIT","dependencies":{"@webassemblyjs/ast":"1.14.1","@webassemblyjs/helper-buffer":"1.14.1","@webassemblyjs/helper-wasm-bytecode":"1.13.2","@webassemblyjs/helper-wasm-section":"1.14.1","@webassemblyjs/wasm-gen":"1.14.1","@webassemblyjs/wasm-opt":"1.14.1","@webassemblyjs/wasm-parser":"1.14.1","@webassemblyjs/wast-printer":"1.14.1"},"devDependencies":{"@webassemblyjs/helper-test-framework":"1.14.1"},"gitHead":"25d52b1296e151ac56244a7c3886661e6b4a69ea","bugs":{"url":"https://github.com/xtuc/webassemblyjs/issues"},"homepage":"https://github.com/xtuc/webassemblyjs#readme","_id":"@webassemblyjs/wasm-edit@1.14.1","_nodeVersion":"21.7.1","_npmVersion":"lerna/5.1.6/node@v21.7.1+x64 (linux)","dist":{"integrity":"sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==","shasum":"ac6689f502219b59198ddec42dcd496b1004d597","tarball":"http://registry-npm.ywwl.com/@webassemblyjs/wasm-edit/download/@webassemblyjs/wasm-edit-1.14.1.tgz","fileCount":7,"unpackedSize":34634,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICe8RADGPIzio8npNhhDkBdtRHoN8WVazhadOK4BLVtTAiAPydJER4FOuSGuzSFT1QpmN6X2WIkNLN/hjABF9VXJVg=="}],"size":6638,"noattachment":false,"key":"/@webassemblyjs/wasm-edit/-/@webassemblyjs/wasm-edit-1.14.1.tgz"},"_npmUser":{"name":"xtuc","email":"npm@sauleau.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wasm-edit_1.14.1_1730930022713_0.2449484169132572"},"_hasShrinkwrap":false,"readme":"# @webassemblyjs/wasm-edit\n\n> Rewrite a WASM binary\n\nReplace in-place an AST node in the binary.\n\n## Installation\n\n```sh\nyarn add @webassemblyjs/wasm-edit\n```\n\n## Usage\n\nUpdate:\n\n```js\nimport { edit } from \"@webassemblyjs/wasm-edit\";\n\nconst binary = [/*...*/];\n\nconst visitors = {\n  ModuleImport({ node }) {\n    node.module = \"foo\";\n    node.name = \"bar\";\n  }\n};\n\nconst newBinary = edit(binary, visitors);\n```\n\nReplace:\n\n```js\nimport { edit } from \"@webassemblyjs/wasm-edit\";\n\nconst binary = [/*...*/];\n\nconst visitors = {\n  Instr(path) {\n    const newNode = t.callInstruction(t.indexLiteral(0));\n    path.replaceWith(newNode);\n  }\n};\n\nconst newBinary = edit(binary, visitors);\n```\n\nRemove:\n\n```js\nimport { edit } from \"@webassemblyjs/wasm-edit\";\n\nconst binary = [/*...*/];\n\nconst visitors = {\n  ModuleExport({ node }) {\n    path.remove()\n  }\n};\n\nconst newBinary = edit(binary, visitors);\n```\n\nInsert:\n\n```js\nimport { add } from \"@webassemblyjs/wasm-edit\";\n\nconst binary = [/*...*/];\n\nconst newBinary = add(actualBinary, [\n  t.moduleImport(\"env\", \"mem\", t.memory(t.limit(1)))\n]);\n```\n\n## Providing the AST\n\nProviding an AST allows you to handle the decoding yourself, here is the API:\n\n```js\naddWithAST(Program, ArrayBuffer, Array<Node>): ArrayBuffer;\neditWithAST(Program, ArrayBuffer, visitors): ArrayBuffer;\n```\n\nNote that the AST will be updated in-place.\n","publish_time":1730930022909,"maintainers":[{"name":"xtuc","email":"npm@sauleau.com"}],"_cnpm_publish_time":1730930022909,"dist-tags":{"latest":"1.14.1"}}