{"id":16125746,"url":"https://github.com/dy/watr","last_synced_at":"2025-03-17T15:13:28.689Z","repository":{"id":66081326,"uuid":"456235092","full_name":"dy/watr","owner":"dy","description":"Light \u0026 fast wasm text compiler","archived":false,"fork":false,"pushed_at":"2025-03-10T01:29:19.000Z","size":3929,"stargazers_count":35,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-10T02:46:37.978Z","etag":null,"topics":["minify","minify-wat","pretty-print","wabt","wasm","wasm-text","wasm2wat","wast","wat","wat2wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://dy.github.io/watr/docs/repl","language":"WebAssembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dy.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-06T18:23:46.000Z","updated_at":"2025-02-11T22:25:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"be137eac-cce8-460d-9b42-785c5160ae2d","html_url":"https://github.com/dy/watr","commit_stats":{"total_commits":278,"total_committers":2,"mean_commits":139.0,"dds":0.003597122302158251,"last_synced_commit":"41089a2db0ec49abab0aa1c0a3582eaeb97e6aa4"},"previous_names":["audio-lab/watr"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fwatr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fwatr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fwatr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fwatr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/watr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056424,"owners_count":20390719,"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":["minify","minify-wat","pretty-print","wabt","wasm","wasm-text","wasm2wat","wast","wat","wat2wasm","webassembly"],"created_at":"2024-10-09T21:31:25.873Z","updated_at":"2025-03-17T15:13:28.684Z","avatar_url":"https://github.com/dy.png","language":"WebAssembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# watr [![test](https://github.com/audio-lab/watr/actions/workflows/test.js.yml/badge.svg)](https://github.com/audio-lab/watr/actions/workflows/test.js.yml) [![npm bundle size](https://img.shields.io/bundlephobia/minzip/watr/latest?color=brightgreen\u0026label=gzip)](https://bundlephobia.com/package/watr) [![npm](https://img.shields.io/npm/v/watr?color=white)](https://npmjs.org/watr)\n\nLight \u0026 fast WAT compiler.\u003cbr/\u003e\nUseful for high-level languages or dynamic (in-browser) compilation.\u003cbr/\u003e\nSupports full [spec text syntax](https://webassembly.github.io/spec/core/text/index.html) and [official testsuite](https://github.com/WebAssembly/testsuite).\n\n**[REPL](https://dy.github.io/watr/docs/repl)**\n\n## Usage\n\n### Compile\n\nCompile wasm text or syntax tree into wasm binary.\n\n```js\nimport { compile } from 'watr'\n\nconst buffer = compile(`(func (export \"double\")\n  (param f64) (result f64)\n  (f64.mul (local.get 0) (f64.const 2))\n)`)\nconst module = new WebAssembly.Module(buffer)\nconst instance = new WebAssembly.Instance(module)\nconst {double} = instance.exports\n\ndouble(108) // 216\n```\n\n### Parse\n\nParse input wasm text into syntax tree.\n\n```js\nimport { parse } from 'watr'\n\nparse(`(func (export \"double\") (param f64) (result f64) (f64.mul (local.get 0) (f64.const 2)))`)\n// [\n//   'func', ['export', '\"double\"'], ['param', 'f64'], ['result', 'f64'],\n//   ['f64.mul', ['local.get', 0], ['f64.const', 2]]\n// ]\n```\n\n### Print\n\nFormat input wasm text or syntax tree into minified or pretty form.\n\n```js\nimport { print } from 'watr'\n\nconst src = `(func (export \"double\")\n  (param f64) (result f64)\n  (f64.mul (local.get 0) (f64.const 2))\n)`\n\n// pretty-print (default)\nprint(src, {\n  indent: '  ',\n  newline: '\\n',\n})\n// (func\n//   (export \"double\")\n//   (param f64)\n//   (result f64)\n//   (f64.mul (local.get 0) (f64.const 2))\n// )\n\n// minify\nprint(src, {\n  indent: false,\n  newline: false\n})\n// (func(export \"double\")(param f64)(result f64)(f64.mul(local.get 0)(f64.const 2)))\n```\n\n\u003c!-- See [REPL](https://audio-lab.github.io/watr/repl.html).--\u003e\n\n## Status\n\n* [x] core\n* [x] [mutable globals](https://github.com/WebAssembly/mutable-global), [extended const](https://github.com/WebAssembly/extended-const/blob/main/proposals/extended-const/Overview.md), [nontrapping float to int](https://github.com/WebAssembly/nontrapping-float-to-int-conversions), [sign extension](https://github.com/WebAssembly/sign-extension-ops)\n* [x] [multi-value](https://github.com/WebAssembly/spec/blob/master/proposals/multi-value/Overview.md), [bulk memory ops](https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md)\n* [x] [simd](https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md), [relaxed simd](https://github.com/WebAssembly/relaxed-simd), [fixed-width simd](https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md)\n* [x] [tail_call](https://github.com/WebAssembly/tail-call)\n* [x] [ref types](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md), [func refs](https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md), [gc](https://github.com/WebAssembly/gc)\n* [ ] [exceptions](https://github.com/WebAssembly/exception-handling), [annotations](https://github.com/WebAssembly/annotations), [code_metadata](https://github.com/WebAssembly/tool-conventions/blob/main/CodeMetadata.md)\n* [ ] [multiple memories](https://github.com/WebAssembly/multi-memory/blob/master/proposals/multi-memory/Overview.md), [memory64](https://github.com/WebAssembly/memory64)\n* [ ] [js strings](https://github.com/WebAssembly/js-string-builtins/blob/main/proposals/js-string-builtins/Overview.md)\n* [ ] wide arithmetic, threads, custom page size,\n* [ ] wasm 3\n\n## Alternatives\n\n\u0026nbsp; | Size (gzipped) | Performance\n---|---|---\nwatr | 7.5 kb | 6.0 op/s\n[spec/wast.js](https://github.com/WebAssembly/spec/tree/main/interpreter#javascript-library) | 216 kb | 2.2 op/s\n[wabt](https://github.com/WebAssembly/wabt) | 282 kb | 1.2 op/s\n[wat-compiler](https://github.com/stagas/wat-compiler) | 7.7 kb | 0.7 op/s\n\n\u003c!--\n## Projects using watr\n\n* [piezo](https://github.com/audio-lab/piezo) – audio processing language\n--\u003e\n\n\u003c!--\n## Useful links\n\n* [watlings](https://github.com/EmNudge/watlings) – learn Wasm text by examples.\n* [MDN: control flow](https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Control_flow)\n* [WASM reference manual](https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#loop)\n* [WASM binary encoding](https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md)\n--\u003e\n\n\u003cp align=center\u003e\u003ca href=\"https://github.com/krsnzd/license/\"\u003e🕉\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fwatr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fwatr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fwatr/lists"}