{"id":15844172,"url":"https://github.com/xtuc/webassembly-types","last_synced_at":"2025-06-10T18:39:05.910Z","repository":{"id":57409278,"uuid":"178403356","full_name":"xtuc/webassembly-types","owner":"xtuc","description":"Better types for interacting with WebAssembly","archived":false,"fork":false,"pushed_at":"2019-03-29T12:44:18.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T11:52:47.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/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":"2019-03-29T12:41:49.000Z","updated_at":"2019-12-27T12:30:00.000Z","dependencies_parsed_at":"2022-09-14T05:10:33.120Z","dependency_job_id":null,"html_url":"https://github.com/xtuc/webassembly-types","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%2Fwebassembly-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fwebassembly-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fwebassembly-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fwebassembly-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtuc","download_url":"https://codeload.github.com/xtuc/webassembly-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246681505,"owners_count":20816908,"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-05T17:20:30.317Z","updated_at":"2025-04-01T17:39:32.896Z","avatar_url":"https://github.com/xtuc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webassembly-types\n\n\u003e Better types for interacting with WebAssembly\n\n## Install\n\nUsing npm:\n\n```sh\nnpm install --save webassembly-types\n```\n\nor using yarn:\n\n```sh\nyarn add webassembly-types\n```\n\n## Usage\n\nAPI:\n```js\nconst types = require(\"webassembly-types\");\n\ntypes.i32(12);\ntypes.i64(12);\nconst a = types.i64(12n);\n\n// call an export\ninstance.exports.fn(a);\n```\n\n## Why\n\n### stricter range checks\n\nTo be consistent with JavaScript, out-of-range numbers passed in WebAssembly do silently overflow.\nThis can be pretty error-prone, as shown by the following example:\n\n```wast\n(module\n  (memory 1)\n  (func (export \"load\") (param i32) (result i32)\n    (get_local 0)\n    (i32.load)\n  )\n)\n```\n\n```js\ninstance.exports.load(4294967296);\n```\n\nWill load at offset 0 because it overflowed at the Wasm boundary.\n\nUsing the i32 from this lib will make it throw instead.\n\n### simpler i64\n\nIn JavaScript BigInt are not convertible to Number, this can be annoying when trying to keep your JavaScript\u003c\u003eWasm code generic.\n\nFor instance, the previous example could be compiled for both 32-bit and 64-bit address space. In 64-bit mode is would look like the following:\n\n```wast\n(module\n  (memory 1)\n  (func (export \"load\") (param i64) (result i64)\n    (get_local 0)\n    (i64.load)\n  )\n)\n```\n\nThe call here, wouldn't work anymore (it will throw instead):\n```js\ninstance.exports.load(4294967296);\n```\n\nUsing the lib:\n```js\ninstance.exports.load(i64(4294967296));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtuc%2Fwebassembly-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtuc%2Fwebassembly-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtuc%2Fwebassembly-types/lists"}