{"id":13740166,"url":"https://github.com/foxbenjaminfox/babel-plugin-overload","last_synced_at":"2025-10-29T00:35:20.189Z","repository":{"id":83664387,"uuid":"74126695","full_name":"foxbenjaminfox/babel-plugin-overload","owner":"foxbenjaminfox","description":"A highly experimental babel plugin for operator overloading in javascript","archived":false,"fork":false,"pushed_at":"2017-07-21T11:32:42.000Z","size":14,"stargazers_count":46,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-28T10:11:29.274Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foxbenjaminfox.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":"2016-11-18T12:10:31.000Z","updated_at":"2024-05-02T09:16:22.000Z","dependencies_parsed_at":"2023-05-04T00:43:00.512Z","dependency_job_id":null,"html_url":"https://github.com/foxbenjaminfox/babel-plugin-overload","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"7362bf1472446e12f1536fc96e91d9585048f4a4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/foxbenjaminfox/babel-plugin-overload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxbenjaminfox%2Fbabel-plugin-overload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxbenjaminfox%2Fbabel-plugin-overload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxbenjaminfox%2Fbabel-plugin-overload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxbenjaminfox%2Fbabel-plugin-overload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foxbenjaminfox","download_url":"https://codeload.github.com/foxbenjaminfox/babel-plugin-overload/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxbenjaminfox%2Fbabel-plugin-overload/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260079424,"owners_count":22955701,"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-08-03T04:00:43.795Z","updated_at":"2025-10-29T00:35:20.135Z","avatar_url":"https://github.com/foxbenjaminfox.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Alternative Programming Paradigms"],"readme":"# babel-plugin-overload\n\n  [![CircleCI](https://circleci.com/gh/foxbenjaminfox/babel-plugin-overload/tree/master.svg?style=shield)](https://circleci.com/gh/foxbenjaminfox/babel-plugin-overload/tree/master)\n\nThis is an experimental plugin that allows you to overload operators in your Javascript code.\n\nCompare with Python:\n\n````py\nclass Addable:\n  def __add__(self, other):\n    return # some computation which uses self and other\n````\n\nUsing this Babel plugin:\n````js\nclass Addable {\n  [Symbol.for('+')] (other) {\n    return // some computation which uses this and other\n  }\n}\n````\n\nThis plugin is still in beta and should be considered highly experimental. It should go without saying that you probably should not use this in production.\n\n## Example\n\n**In**\n\n````js\nx + y\n````\n\n**Out**\n\n````js\nfunction (_left, _right) {\n  if (_left !== null \u0026\u0026 _left !== undefined \u0026\u0026 _left[Symbol.for(\"+\")]) return _left[Symbol.for(\"+\")](_right);else return _left + _right;\n}(x, y);\n````\n\n## Supported Operators\nAt the moment, all binary operators are supported. Unary operators are coming soon.\n\nThe full supported list is:\n- The arithmetic operators: `+`, `-`, `/`, `*`, `%`, `**`\n- The bitwise operators: `\u0026`, `|`, `^`\n- The bitshift operators: `\u003e\u003e`, `\u003c\u003c`, `\u003e\u003e\u003e`, `\u003c\u003c\u003c`\n- The equality operators: `==`, `===`, `!=`, `!==`\n- The inequality operators: `\u003e`, `\u003c`, `\u003e=`, `\u003c=`\n- The remaining miscellaneous operators: `in` and `instanceof`\n\nTo overload any of them, define a method named with the Symbol you get with `Symbol.for` for the appropriate operator. For instance, use `Symbol.for('+')` to overload the `+` operator, and `Symbol.for('in')` to overload the `in` operator.\n\nYou can define the overloading method on the object itself or anywhere on the object's prototype chain.\n\nAt the moment, overloading is only supported for the left side value. Support for overloading on the right side value (the equivalent of Python's `__radd__` family of methods) is coming soon.\n\n## Installation\n\n````sh\n$ npm install babel-plugin-overload\n````\n\n## Usage\n\n### Via `.babelrc` (Recommended)\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [\"overload\"]\n}\n```\n\n### Via CLI\n\n```sh\n$ babel --plugins overload script.js\n```\n\n### Via Node API\n\n````javascript\nrequire(\"babel-core\").transform(\"code\", {\n  plugins: [\"overload\"]\n});\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxbenjaminfox%2Fbabel-plugin-overload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxbenjaminfox%2Fbabel-plugin-overload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxbenjaminfox%2Fbabel-plugin-overload/lists"}