{"id":20311104,"url":"https://github.com/mcmath/define-static-method","last_synced_at":"2026-06-04T02:31:10.382Z","repository":{"id":143768685,"uuid":"61591291","full_name":"mcmath/define-static-method","owner":"mcmath","description":"Define an ES2015 class static method in ES5","archived":false,"fork":false,"pushed_at":"2016-06-21T02:57:30.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T01:39:25.390Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcmath.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-06-21T01:04:29.000Z","updated_at":"2016-06-21T01:30:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"75b7e997-6ca8-450a-b0de-9f7c007eb018","html_url":"https://github.com/mcmath/define-static-method","commit_stats":null,"previous_names":["akim-mcmath/define-static-method"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcmath%2Fdefine-static-method","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcmath%2Fdefine-static-method/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcmath%2Fdefine-static-method/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcmath%2Fdefine-static-method/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcmath","download_url":"https://codeload.github.com/mcmath/define-static-method/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241809614,"owners_count":20023787,"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-14T17:36:11.358Z","updated_at":"2026-06-04T02:31:10.368Z","avatar_url":"https://github.com/mcmath.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Define Static Method\n\n[![Version][version-badge]][npm]\n[![License][license-badge]][license]\n[![Build][build-badge]][travis]\n[![Coverage][coverage-badge]][coveralls]\n[![Dependencies][dependencies-badge]][gemnasium]\n\n**Define Static Method** is a simple utility for defining a static method in\nES5 with the same [property descriptor][descriptor] as an [ES2015 class][class]\nmethod.\n\n## Install\n\nInstall with [npm][npm]:\n\n```sh\nnpm install --save define-static-method\n```\n\n## Usage\n\nIn ES2015, we might do this:\n\n```js\nclass Squid {\n  constructor(name) {\n    this.name = name;\n  }\n  static createVladimir() {\n    return new Squid('Vladimir');\n  }\n}\n```\n\nIn ES5, we can do this:\n\n```js\nvar defineStatic = require('define-static-method');\n\nfunction Squid(name) {\n  this.name = name;\n}\n\ndefineStatic(Squid, 'createVladimir', function() {\n  return new Squid('Vladimir');\n});\n```\n\nAnd here is Vladimir:\n\n```js\nSquid.createVladimir().name; // -\u003e 'Vladimir'\n```\n\n## API\n\n#### `defineStaticMethod(constructor, prop, method)`\n\n| Param | Type | Description |\n| :---- | :--- | :---------- |\n| constructor | `function` | The constructor function the method will be added to |\n| prop | `string` | The property name of the method |\n| method | `function` | The static method to add |\n\n## License\n\nCopyright \u0026copy; 2016 Akim McMath. Licensed under the [MIT License][license].\n\n[version-badge]: https://img.shields.io/npm/v/define-static-method.svg?style=flat-square\n[license-badge]: https://img.shields.io/npm/l/define-static-method.svg?style=flat-square\n[build-badge]: https://img.shields.io/travis/akim-mcmath/define-static-method/master.svg?style=flat-square\n[coverage-badge]: https://img.shields.io/coveralls/akim-mcmath/define-static-method/master.svg?style=flat-square\u0026service=github\n[dependencies-badge]: https://img.shields.io/gemnasium/akim-mcmath/define-static-method.svg?style=flat-square\n[npm]: https://www.npmjs.com/package/define-static-method\n[license]: LICENSE\n[travis]: https://travis-ci.org/akim-mcmath/define-static-method\n[coveralls]: https://coveralls.io/github/akim-mcmath/define-static-method?branch=master\n[gemnasium]: https://gemnasium.com/akim-mcmath/define-static-method\n[descriptor]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty\n[class]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcmath%2Fdefine-static-method","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcmath%2Fdefine-static-method","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcmath%2Fdefine-static-method/lists"}