{"id":18656123,"url":"https://github.com/geometryzen/js-to-mathscript","last_synced_at":"2025-11-05T20:30:32.972Z","repository":{"id":57162890,"uuid":"458394024","full_name":"geometryzen/js-to-mathscript","owner":"geometryzen","description":"A transpiler from JavaScript to some syntax.","archived":false,"fork":false,"pushed_at":"2023-01-05T20:43:39.000Z","size":673,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-24T19:33:29.488Z","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/geometryzen.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}},"created_at":"2022-02-12T01:53:51.000Z","updated_at":"2022-02-12T22:45:31.000Z","dependencies_parsed_at":"2023-02-04T15:47:40.563Z","dependency_job_id":null,"html_url":"https://github.com/geometryzen/js-to-mathscript","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/geometryzen%2Fjs-to-mathscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometryzen%2Fjs-to-mathscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometryzen%2Fjs-to-mathscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geometryzen%2Fjs-to-mathscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geometryzen","download_url":"https://codeload.github.com/geometryzen/js-to-mathscript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239470999,"owners_count":19644231,"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-11-07T07:22:01.239Z","updated_at":"2025-11-05T20:30:32.915Z","avatar_url":"https://github.com/geometryzen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-to-mathscript\nA transpiler and validator from JavaScript syntax to some similar syntax.\n\nExample of replacing the name of a Binary operator:\n\n```typescript\n    it('Exponentiation', function () {\n      const src = 'x**2';\n      const { code } = jsToMathScript(src,\n        {\n          namespace: '',\n          binOp: {\n            '**': { kind: 'rename', value: '^' }\n          },\n          unaryOp: {}\n        },\n        {\n          format: {\n            semicolons: false\n          }\n        }\n      );\n      assert.strictEqual(code, 'x ^ 2');\n    });\n```\n\nExample of converting a Binary operator to a function call:\n\n```typescript\nit('Bitwise XOR (^) should be turned into a function.', function () {\n    const src = 'x ^ y';\n    const { code } = jsToMathScript(src, {\n            namespace: 'MathScript',\n            binOp: {\n                '**': { kind: 'rename', value: '^' },\n                '^': { kind: 'function', value: 'wedge' }\n            },\n            unaryOp: {}\n        },\n        {\n        format: {\n            semicolons: false\n        }\n    });\n    assert.strictEqual(code, 'MathScript.wedge(x, y)');\n});\n```\n\nExample of rejecting a Unary operator:\n\n```typescript\nit(\"error\", function () {\n    try {\n        const src = \"const a = +b\";\n        jsToMathScript(src, {\n            unaryOp: {\n                '+': { kind: 'error', value: \"Unexpected unary plus (+)\" }\n            }\n        });\n        assert.fail();\n    } catch (e) {\n        if (e instanceof Error) {\n            assert.strictEqual(e.name, \"Error\");\n            assert.strictEqual(e.message, \"Unexpected unary plus (+)\");\n        } else {\n            assert.fail();\n        }\n    }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeometryzen%2Fjs-to-mathscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeometryzen%2Fjs-to-mathscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeometryzen%2Fjs-to-mathscript/lists"}