{"id":26182502,"url":"https://github.com/Shopify/javy","last_synced_at":"2025-03-11T22:01:47.352Z","repository":{"id":38199572,"uuid":"360531511","full_name":"bytecodealliance/javy","owner":"bytecodealliance","description":"JS to WebAssembly toolchain","archived":false,"fork":false,"pushed_at":"2025-03-11T18:52:25.000Z","size":106293,"stargazers_count":2402,"open_issues_count":26,"forks_count":117,"subscribers_count":245,"default_branch":"main","last_synced_at":"2025-03-11T22:01:35.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytecodealliance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-04-22T13:36:40.000Z","updated_at":"2025-03-11T20:15:44.000Z","dependencies_parsed_at":"2023-10-30T16:32:47.364Z","dependency_job_id":"b96b696e-cc9e-4f16-988e-2d9be1beffd9","html_url":"https://github.com/bytecodealliance/javy","commit_stats":null,"previous_names":["shopify/javy"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fjavy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fjavy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fjavy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fjavy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytecodealliance","download_url":"https://codeload.github.com/bytecodealliance/javy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243119546,"owners_count":20239321,"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":"2025-03-11T22:01:42.637Z","updated_at":"2025-03-11T22:01:47.343Z","avatar_url":"https://github.com/bytecodealliance.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ccode\u003eJavy\u003c/code\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eA \u003ci\u003eJav\u003c/i\u003eaScript to Webassembl\u003ci\u003ey\u003c/i\u003e toolchain\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003cstrong\u003eA \u003ca href=\"https://bytecodealliance.org/\"\u003eBytecode Alliance\u003c/a\u003e project\u003c/strong\u003e\n\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/bytecodealliance/javy/actions/workflows/ci.yml\"\u003e\u003cimg alt=\"Build status\" src=\"https://github.com/bytecodealliance/javy/actions/workflows/ci.yml/badge.svg?branch=main\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://bytecodealliance.zulipchat.com/#narrow/stream/370816-javy\"\u003e\u003cimg src=\"https://img.shields.io/badge/zulip-join_chat-brightgreen.svg\" alt=\"zulip chat\" /\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## About this repo\n\n**Introduction**: Run your JavaScript on WebAssembly. Javy takes your JavaScript\ncode, and executes it in a WebAssembly embedded JavaScript runtime. Javy can\ncreate _very_ small Wasm modules in the 1 to 16 KB range with use of dynamic\nlinking. The default static linking produces modules that are at least 869 KB in\nsize.\n\n## Installation\n\nPre-compiled binaries of the Javy CLI can be found on [the releases\npage](https://github.com/bytecodealliance/javy/releases).\n\n## Example\n\nDefine your JavaScript like:\n\n```javascript\n// Read input from stdin\nconst input = readInput();\n// Call the function with the input\nconst result = foo(input);\n// Write the result to stdout\nwriteOutput(result);\n\n// The main function.\nfunction foo(input) {\n    return { foo: input.n + 1, newBar: input.bar + \"!\" };\n}\n\n// Read input from stdin\nfunction readInput() {\n    const chunkSize = 1024;\n    const inputChunks = [];\n    let totalBytes = 0;\n\n    // Read all the available bytes\n    while (1) {\n        const buffer = new Uint8Array(chunkSize);\n        // Stdin file descriptor\n        const fd = 0;\n        const bytesRead = Javy.IO.readSync(fd, buffer);\n\n        totalBytes += bytesRead;\n        if (bytesRead === 0) {\n            break;\n        }\n        inputChunks.push(buffer.subarray(0, bytesRead));\n    }\n\n    // Assemble input into a single Uint8Array\n    const { finalBuffer } = inputChunks.reduce((context, chunk) =\u003e {\n        context.finalBuffer.set(chunk, context.bufferOffset);\n        context.bufferOffset += chunk.length;\n        return context;\n    }, { bufferOffset: 0, finalBuffer: new Uint8Array(totalBytes) });\n\n    return JSON.parse(new TextDecoder().decode(finalBuffer));\n}\n\n// Write output to stdout\nfunction writeOutput(output) {\n    const encodedOutput = new TextEncoder().encode(JSON.stringify(output));\n    const buffer = new Uint8Array(encodedOutput);\n    // Stdout file descriptor\n    const fd = 1;\n    Javy.IO.writeSync(fd, buffer);\n}\n```\n\nCreate a WebAssembly binary from your JavaScript by:\n\n```bash\njavy build index.js -o destination/index.wasm\n```\n\nFor more information on the commands you can run `javy --help`\n\nYou can then execute your WebAssembly binary using a WebAssembly engine:\n\n```bash\n$ echo '{ \"n\": 2, \"bar\": \"baz\" }' | wasmtime index.wasm\n{\"foo\":3,\"newBar\":\"baz!\"}%   \n```\n\n## Documentation\n\nRead the documentation [here](./docs/index.md)\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShopify%2Fjavy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FShopify%2Fjavy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShopify%2Fjavy/lists"}