{"name":"@webassemblyjs/wasm-edit","version":"1.13.1","author":{"name":"Sven Sauleau"},"license":"MIT","_id":"@webassemblyjs/wasm-edit@1.13.1","homepage":"https://github.com/xtuc/webassemblyjs#readme","bugs":{"url":"https://github.com/xtuc/webassemblyjs/issues"},"dist":{"shasum":"84a7c07469bf03589c82afd23c0b26b75a3443c9","tarball":"http://registry-npm.ywwl.com/@webassemblyjs/wasm-edit/download/@webassemblyjs/wasm-edit-1.13.1.tgz","fileCount":7,"integrity":"sha512-YHnh/f4P4ggjPB+pcri8Pb2HHwCGK+B8qBE+NeEp/WTMQ7dAjgWTnLhXxUqb6WLOT25TK5m0VTCAKTYw8AKxcg==","signatures":[{"sig":"MEQCIBEuj6fEP2iNmMetfvgwp4FynBmrgHZ5KlDOWJs4Y5C/AiBcfQUv0KOOAQJGoDh3GpGwArsenEqMsBzwlAaHW5/64A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34634,"size":6640,"noattachment":false,"key":"/@webassemblyjs/wasm-edit/-/@webassemblyjs/wasm-edit-1.13.1.tgz"},"main":"lib/index.js","module":"esm/index.js","gitHead":"cfe35c57093d414839b9350398369b78d97815b4","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"xtuc","email":"npm@sauleau.com"},"repository":{"url":"git+https://github.com/xtuc/webassemblyjs.git","type":"git"},"_npmVersion":"lerna/5.1.6/node@v21.7.1+x64 (linux)","description":"> Rewrite a WASM binary","directories":{},"_nodeVersion":"21.7.1","dependencies":{"@webassemblyjs/ast":"1.13.1","@webassemblyjs/wasm-gen":"1.13.1","@webassemblyjs/wasm-opt":"1.13.1","@webassemblyjs/wasm-parser":"1.13.1","@webassemblyjs/wast-printer":"1.13.1","@webassemblyjs/helper-buffer":"1.13.1","@webassemblyjs/helper-wasm-section":"1.13.1","@webassemblyjs/helper-wasm-bytecode":"1.12.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@webassemblyjs/helper-test-framework":"1.13.1"},"_npmOperationalInternal":{"tmp":"tmp/wasm-edit_1.13.1_1730912134665_0.15054418505720513","host":"s3://npm-registry-packages"},"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":1730912134800,"maintainers":[{"name":"xtuc","email":"npm@sauleau.com"}],"_cnpm_publish_time":1730912134800,"dist-tags":{"latest":"1.14.1"}}