{"id":23749292,"url":"https://github.com/dy/jz","last_synced_at":"2025-04-12T10:36:23.756Z","repository":{"id":263296977,"uuid":"887923487","full_name":"dy/jz","owner":"dy","description":"Minimal JS subset compiling to WASM","archived":false,"fork":false,"pushed_at":"2025-02-28T01:14:39.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T00:32:54.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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":"LICENSE","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":"2024-11-13T14:13:53.000Z","updated_at":"2025-04-05T22:02:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"56e2443c-fdf9-4f9e-9689-635e408f2058","html_url":"https://github.com/dy/jz","commit_stats":null,"previous_names":["dy/jayscript","dy/jasm","dy/jz"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fjz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fjz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fjz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fjz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/jz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248554201,"owners_count":21123617,"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-12-31T15:14:59.967Z","updated_at":"2025-04-12T10:36:23.487Z","avatar_url":"https://github.com/dy.png","language":null,"funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# jz ![stability](https://img.shields.io/badge/stability-experimental-black) [![test](https://github.com/dy/piezo/actions/workflows/test.yml/badge.svg)](https://github.com/dy/piezo/actions/workflows/test.yml)\n\n_JZ_ is minimal modern functional JS subset that compiles to WebAssembly (WASM).\u003cbr\u003e\nThink of it as tiny _JavaScript to WASM compiler_.\n\u003c!-- By the time it takes new Function to parse, jz compiles WASM --\u003e\n\n## Reference\n\n* Numbers: `0.1`, `1.2e+3`, `0xabc`, `0b101`, `0o357`\n* Strings: `\"abc\"`, `'abc'`\n* Values: `true`, `false`, `null`, `NaN`, `Infinity`, ~~`undefined`~~\n* Access: `a.b`, `a[b]`, `a(b)`\n* Arithmetic:`+a`, `-a`, `a + b`, `a - b`, `a * b`, `a / b`, `a % b`, `a ** b`\n* Comparison: `a \u003c b`, `a \u003c= b`, `a \u003e b`, `a \u003e= b`, `a == b`, `a != b`, `a === b`, `a !== b`\n* Bitwise: `~a`, `a \u0026 b`, `a ^ b`, `a | b`, `a \u003c\u003c b`, `a \u003e\u003e b`, `a \u003e\u003e\u003e b`\n* Logic: `!a`, `a \u0026\u0026 b`, `a || b`, `a ? b : c`\n* Increments: `a++`, `a--`, `++a`, `--a`\n* Assignment: `a = b`, `a += b`, `a -= b`, `a *= b`, `a /= b`, `a %= b`, `a **= b`, `a \u003c\u003c= b`, `a \u003e\u003e= b`, `a \u003e\u003e\u003e= b`\n* Logical Assignment: `a ||= b`, `a \u0026\u0026= b`, `a ??= b`\n* Arrays: `[a, b]`, `...a` (no objects yet)\n* Declarations: `let a, b`, `const c` (no `var`)\n* Functions: `(a, b) =\u003e c` (no `function` keyword)\n* Comments: `// foo`, `/* bar */`\n* Control Flow: `if (a) {...} else if (b) {...} else {}`, `for (a;b;c) {...}`, `while (a) {...}`\n* Exceptions: `try {...} catch (e) {...}`\n* Modules: `import`, `export`\n\n## Usage\n\n```js\nimport jz from 'jz'\n\n// compile JS (function multiplying 2 numbers) - it returns WASM buffer\nconst buf = jz(`export x = (a, b) =\u003e a * b`)\n\n// compile WASM module and create an instance\nconst mod = new WebAssembly.Module(buf)\nconst { exports: { x } } = new WebAssembly.Instance(mod, { ...imports })\n\n// use exported WASM function\nx(2,3) === 6\n```\n\n_Coming soon:_ CLI with jz a.js → a.wasm and batch compilation.\n\n\u003c!--\n### CLI\n\n`npm i jz`\n\n`jz a.js` - produces `a.wasm`.\n`jz *.jz` - compiles all files in a folder into wasm.\n --\u003e\n\n## Examples\n\n_Coming soon_.\n\n\u003c!--\n* [ ] Microcontroller program\n* [ ] Floatbeat\n* [ ] Embed into website\n --\u003e\n\n## Why?\n\nJS has grown complex with legacy features (var, OOP) and niche additions (generators, async loops, etc).\u003cbr\u003e\nJZ is inspired by floatbeats/bytebeats, it focuses on a minimal, modern, essential subset that ties to WebAssembly features.\u003cbr\u003e\n\n* No classes/prototypes – use functions \u0026 closures.\n* No old syntax – use modern ES5+.\n* No [regrets](https://github.com/DavidBruant/ECMAScript-regrets) – drop `undefined`.\n* No computed props - objects are structs.\n* No autosemicolons - keep syntax ordered.\n* No async – keep code plain \u0026 simple.\n\n### Goals\n\n* _lightweight_ – embed anywhere, from websites to microcontrollers.\n* _fast_ – compiles to WASM faster than `eval` parses.\n* _tiny WASM output_ – no runtime, no heap, no wrappers.\n* _seamless JS integration_ – export / import, same func signatures.\n\n### Why not [porf](https://github.com/CanadaHonk/porffor)?\n\nPorffor is brilliant, but aligns to TC39 and hesitant on full WASM. JZ stays small and flexible.\n\n### Why not [assemblyscript](https://github.com/AssemblyScript/assemblyscript)?\n\nAssemblyScript is built on TypeScript, while JZ stays pure JS.\n\n### Why not [piezo](https://github.com/dy/piezo)?\n\nPiezo offers extra features like groups, pipes, units, ranges and extra operators.\nIt might become a solid niche language, but takes time for R\u0026D.\u003cbr\u003e\nJZ is possible first step for it.\n\n### Why _jz_?\n\nJZ stands for JavasSript Zero – a return to core, stripped to essentials. Also jazzy vibe.\n\n\u003c!--\n## Who's using jz?\n\n* [color-space](https://github.com/colorjs/color-space)\n* [web-audio-api](https://github.com/audiojs/web-audio-api) --\u003e\n\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%2Fjz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fjz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fjz/lists"}