{"id":15680997,"url":"https://github.com/xtuc/inline-wast","last_synced_at":"2025-05-07T11:42:01.671Z","repository":{"id":57274173,"uuid":"116499484","full_name":"xtuc/inline-wast","owner":"xtuc","description":"Inline WebAssembly in your JavaScript","archived":false,"fork":false,"pushed_at":"2018-01-16T13:58:53.000Z","size":329,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T12:25:25.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xtuc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-06T16:51:33.000Z","updated_at":"2022-10-07T01:17:04.000Z","dependencies_parsed_at":"2022-09-17T10:12:49.892Z","dependency_job_id":null,"html_url":"https://github.com/xtuc/inline-wast","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Finline-wast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Finline-wast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Finline-wast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Finline-wast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtuc","download_url":"https://codeload.github.com/xtuc/inline-wast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873287,"owners_count":21817704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T16:47:57.599Z","updated_at":"2025-05-07T11:42:01.649Z","avatar_url":"https://github.com/xtuc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# inline-wast\n\n\u003e Inline WebAssembly in your JavaScript\n\n## Motivations\n\nThe idea is (almost) the same than the built-in `asm` (or `__asm__`) function in C.\nExpress your computation using the WebAssembly backend or an [interpreter](https://github.com/xtuc/js-webassembly-interpreter).\n\nWAST is a superset of WATF (`.wat`) and is not part of the WebAssembly specification but we use it for convenience.\n\n## Example\n\n### Instructions\n\n```js\nconst {wastInstructions} = require('inline-wast/lib/interpreter');\n\nfunction add(a, b) {\n  const fn = wastInstructions`\n    (i32.const ${a})\n    (i32.const ${b})\n    (i32.add)\n  `;\n\n  return fn();\n}\n\nconsole.log(add(1, 1)); // 2\n```\n\n### Function declaration\n\n```js\nconst {wast} = require('inline-wast/lib/interpreter');\n\nfunction add(a, b) {\n  const exports = wast(`\n    (func (export \"add\") (param $l i32) (param $r i32) (result i32)\n      (get_local $l)\n      (get_local $r)\n      (i32.add)\n    )\n  `);\n\n  return exports.add(a, b);\n}\n\nconsole.log(add(1, 1)); // 2\n```\n\n### Native\n\nIf you want to use the native WebAssembly backend the usage remains the same, but you need to use:\n\n```js\nconst {wastInstructions, wast} = require('inline-wast/lib/native');\n```\n\nIt's not recommended for now, the WAST to WASM conversion needs to be refactored.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtuc%2Finline-wast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtuc%2Finline-wast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtuc%2Finline-wast/lists"}