{"id":19589762,"url":"https://github.com/supercharge/method-missing","last_synced_at":"2025-02-26T13:40:16.104Z","repository":{"id":57163601,"uuid":"283989774","full_name":"supercharge/method-missing","owner":"supercharge","description":"Handle missing methods on your classes, like PHP’s __call method","archived":false,"fork":false,"pushed_at":"2021-07-09T07:59:56.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-10T23:30:16.529Z","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/supercharge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-07-31T08:58:53.000Z","updated_at":"2021-07-09T07:59:58.000Z","dependencies_parsed_at":"2022-09-01T03:12:43.828Z","dependency_job_id":null,"html_url":"https://github.com/supercharge/method-missing","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fmethod-missing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fmethod-missing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fmethod-missing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fmethod-missing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/supercharge","download_url":"https://codeload.github.com/supercharge/method-missing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240863605,"owners_count":19869838,"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-11T08:20:40.544Z","updated_at":"2025-02-26T13:40:16.040Z","avatar_url":"https://github.com/supercharge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\r\n  \u003ca href=\"https://superchargejs.com\"\u003e\r\n    \u003cimg width=\"471\" style=\"max-width:100%;\" src=\"https://superchargejs.com/images/supercharge-text.svg\" /\u003e\r\n  \u003c/a\u003e\r\n  \u003cbr/\u003e\r\n  \u003cbr/\u003e\r\n  \u003cp\u003e\r\n    \u003ch3\u003eMethod Missing\u003c/h3\u003e\r\n  \u003c/p\u003e\r\n  \u003cp\u003e\r\n    Handle missing methods on your classes, like \u003ca href=\"https://www.php.net/manual/en/language.oop5.overloading.php#object.call\"\u003ePHP’s __call\u003c/a\u003e.\r\n  \u003c/p\u003e\r\n  \u003cbr/\u003e\r\n  \u003cp\u003e\r\n    \u003ca href=\"#installation\"\u003e\u003cstrong\u003eInstallation\u003c/strong\u003e\u003c/a\u003e ·\r\n    \u003ca href=\"#Docs\"\u003e\u003cstrong\u003eDocs\u003c/strong\u003e\u003c/a\u003e ·\r\n    \u003ca href=\"#usage\"\u003e\u003cstrong\u003eUsage\u003c/strong\u003e\u003c/a\u003e\r\n  \u003c/p\u003e\r\n  \u003cbr/\u003e\r\n  \u003cbr/\u003e\r\n  \u003cp\u003e\r\n    \u003ca href=\"https://www.npmjs.com/package/@supercharge/method-missing\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@supercharge/method-missing.svg\" alt=\"Latest Version\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://www.npmjs.com/package/@supercharge/method-missing\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@supercharge/method-missing.svg\" alt=\"Monthly downloads\"\u003e\u003c/a\u003e\r\n  \u003c/p\u003e\r\n  \u003cp\u003e\r\n    \u003cem\u003eFollow \u003ca href=\"http://twitter.com/marcuspoehls\"\u003e@marcuspoehls\u003c/a\u003e and \u003ca href=\"http://twitter.com/superchargejs\"\u003e@superchargejs\u003c/a\u003e for updates!\u003c/em\u003e\r\n  \u003c/p\u003e\r\n\u003c/div\u003e\r\n\r\n---\r\n\r\n## Introduction\r\nThe `@supercharge/method-missing` package allows you to handle missing methods in your JavaScript classes. It calls the `__call(methodName, args)` method in your class when trying to invoke a missing method.\r\n\r\n\r\n## Installation\r\n\r\n```\r\nnpm i @supercharge/method-missing\r\n```\r\n\r\n\r\n## Docs\r\nFind all the [details for `@supercharge/method-missing` in the extensive Supercharge docs](https://superchargejs.com/docs/pipeline).\r\n\r\n\r\n## Usage\r\nUsing `@supercharge/method-missing` is pretty straightforward. The package exports a class that you must extend in your implemented class. Then, add a `__call(methodName, args)` method to your class. The `__call` method allows you to handle all calls for methods that are not existent in your class.\r\n\r\nI guess an example clears things up:\r\n\r\n```js\r\nconst MethodMissing = require('@supercharge/method-missing')\r\n\r\nclass QueryInterface extends MethodMissing {\r\n  /**\r\n   * Creates an instance wrapping the Sequelize `queryInterface` instance.\r\n   *\r\n   * @param {QueryInterface} queryInterface\r\n   */\r\n  constructor (queryInterface) {\r\n    super()\r\n\r\n    this.queryInterface = queryInterface\r\n  }\r\n\r\n  /**\r\n   * Determine whether the given `column` already exists in the given `table`.\r\n   *\r\n   * @param {String} table\r\n   * @param {String} column\r\n   *\r\n   * @returns {Boolean}\r\n   */\r\n  async hasColumn(tableName, columnName) {\r\n    const description = await this.queryInterface.describeTable(tableName)\r\n\r\n    return !!description[columnName]\r\n  }\r\n\r\n\r\n  /**\r\n   * Pass through all calls to the original query interface.\r\n   *\r\n   * @param {String} methodName\r\n   * @param {Array} args\r\n   *\r\n   * @returns {*}\r\n   */\r\n  __call(methodName, args) {\r\n    return this.queryInterface[methodName](...args)\r\n  }\r\n}\r\n```\r\n\r\n\r\n## Contributing\r\nDo you miss a function? We very much appreciate your contribution! Please send in a pull request 😊\r\n\r\n1.  Create a fork\r\n2.  Create your feature branch: `git checkout -b my-feature`\r\n3.  Commit your changes: `git commit -am 'Add some feature'`\r\n4.  Push to the branch: `git push origin my-new-feature`\r\n5.  Submit a pull request 🚀\r\n\r\n\r\n## License\r\nMIT © [Supercharge](https://superchargejs.com)\r\n\r\n---\r\n\r\n\u003e [superchargejs.com](https://superchargejs.com) \u0026nbsp;\u0026middot;\u0026nbsp;\r\n\u003e GitHub [@supercharge](https://github.com/supercharge) \u0026nbsp;\u0026middot;\u0026nbsp;\r\n\u003e Twitter [@superchargejs](https://twitter.com/superchargejs)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupercharge%2Fmethod-missing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsupercharge%2Fmethod-missing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupercharge%2Fmethod-missing/lists"}