{"id":15651225,"url":"https://github.com/shigma/typed-eval","last_synced_at":"2025-04-30T17:42:48.811Z","repository":{"id":54999106,"uuid":"293579980","full_name":"shigma/typed-eval","owner":"shigma","description":"Type-based calculation does right with TypeScript","archived":false,"fork":false,"pushed_at":"2023-03-11T03:39:05.000Z","size":99,"stargazers_count":33,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T08:09:58.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/shigma.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":"2020-09-07T16:35:34.000Z","updated_at":"2025-03-19T20:51:21.000Z","dependencies_parsed_at":"2024-10-03T12:48:36.475Z","dependency_job_id":null,"html_url":"https://github.com/shigma/typed-eval","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":"0.14634146341463417","last_synced_commit":"80a2d1e15f2b83f1a047093f98cca0defe612a0a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Ftyped-eval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Ftyped-eval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Ftyped-eval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Ftyped-eval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shigma","download_url":"https://codeload.github.com/shigma/typed-eval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251753071,"owners_count":21638221,"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-03T12:37:31.498Z","updated_at":"2025-04-30T17:42:48.777Z","avatar_url":"https://github.com/shigma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typed-eval\n\nType-based high-precision computation does right.\n\n## Features\n\n- Data types: int32, int64, float (WIP), double (WIP)\n- Operators:\n  - Arithmetic: `+`, `-`, `*`, `%`, `//`, `/` (WIP), `**` (WIP)\n  - Comparison: `\u003e`, `\u003c`, `\u003e=`, `\u003c=`, `==`, `!=`\n  - Bitwise: `\u0026`, `|`, `^`, `~` (WIP), `\u003c\u003c`, `\u003e\u003e`, `\u003e\u003e\u003e`\n  - Logical: `\u0026\u0026` (WIP), `||` (WIP), `!` (WIP)\n  - Parentheses: `()`\n- Expression with operator precedence\n\n## Basic Usage\n\n```ts\nimport { add, sub, mul, divmod, calc } from 'typed-eval'\n\ntype P1 = add\u003c114514, 1919810\u003e\n//   ^? type P1 = 2034324\n\nconst P2 = add(114514, -1919810)\n//    ^? const P2 = -1805296\n\ntype S1 = sub\u003c-114514, 1919810\u003e\n//   ^? type S1 = -2034324\n\nconst S2 = sub(-114514, -1919810)\n//    ^? const S2 = 1805296\n\ntype M1 = mul\u003c114, 514\u003e\n//   ^? type M1 = 58596\n\nconst M2 = mul(2000, 5000)\n//    ^? type M2 = 10000000\n\ntype D1 = divmod\u003c10, 3\u003e\n//   ^? type D1 = [3, 1]\n\nconst D2 = divmod(-514, 114)\n//    ^? const D2 = [-4, -58]\n\ntype C1 = calc\u003c'114 + 514 + 1919 + 810'\u003e\n//   ^? type C1: 3357\n\nconst C2 = calc('100 - (2 - 3 * 4) * 5')\n//    ^? const C2: 150\n```\n\n## Advanced Usage\n\nComputations are performed under 32-bit (int32 and float) by default.\nYou can change the data type by importing the corresponding namespace.\n\n```ts\nimport { int32, int64 } from 'typed-eval'\n\n// compute under int32 (by default)\ntype M1 = int32.mul\u003c11111111, 11111111\u003e\n//   ^? type M1 = -2047269199 (overflow)\n\n// compute under int64\ntype M2 = int64.mul\u003c11111111, 11111111\u003e\n//   ^? type M2 = 123456787654321\n```\n\nNote that due to the stack depth limitation of TypeScript, computations under 64-bit types may fail.\n\n## License\n\nReleased under the [MIT](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshigma%2Ftyped-eval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshigma%2Ftyped-eval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshigma%2Ftyped-eval/lists"}