{"id":17808275,"url":"https://github.com/loaderb0t/object-class-initializer","last_synced_at":"2025-08-23T01:12:41.438Z","repository":{"id":222814870,"uuid":"758068235","full_name":"LoaderB0T/object-class-initializer","owner":"LoaderB0T","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-01T01:02:08.000Z","size":734,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-04T04:51:59.049Z","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/LoaderB0T.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,"zenodo":null}},"created_at":"2024-02-15T15:05:49.000Z","updated_at":"2025-07-09T12:01:16.000Z","dependencies_parsed_at":"2024-02-19T14:03:42.620Z","dependency_job_id":"1b5d783c-73c3-4d73-95e1-5f17c8eee69d","html_url":"https://github.com/LoaderB0T/object-class-initializer","commit_stats":null,"previous_names":["loaderb0t/object-class-initializer"],"tags_count":0,"template":false,"template_full_name":"LoaderB0T/typescript-starter","purl":"pkg:github/LoaderB0T/object-class-initializer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fobject-class-initializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fobject-class-initializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fobject-class-initializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fobject-class-initializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LoaderB0T","download_url":"https://codeload.github.com/LoaderB0T/object-class-initializer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fobject-class-initializer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271727844,"owners_count":24810563,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-27T15:10:01.694Z","updated_at":"2025-08-23T01:12:41.398Z","avatar_url":"https://github.com/LoaderB0T.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/object-class-initializer?color=%2300d26a\u0026style=for-the-badge)](https://www.npmjs.com/package/object-class-initializer)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/LoaderB0T/object-class-initializer/build.yml?branch=main\u0026style=for-the-badge)](https://github.com/LoaderB0T/object-class-initializer/actions/workflows/build.yml)\n[![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/LoaderB0T_object-class-initializer?server=https%3A%2F%2Fsonarcloud.io\u0026style=for-the-badge)](https://sonarcloud.io/summary/new_code?id=LoaderB0T_object-class-initializer)\n[![bundle size](https://img.shields.io/bundlephobia/minzip/object-class-initializer?color=%23FF006F\u0026label=Bundle%20Size\u0026style=for-the-badge)](https://bundlephobia.com/package/object-class-initializer)\n\n# Object Class Initializer\n\nDemo repo for using an anonymous class as an object initializer in TypeScript.\n\n## Motivation 💥\n\nCreate an object using an anonymous class to access the 'object' during its initialization. It's 6 lines of code, you might want to just copy paste this instead of installing this package, but who am I to judge?\n\n## Read About This 📖\n\nI wrote a [medium post](https://loaderb0t.medium.com/you-cannot-access-a-javascript-object-during-its-initialization-or-can-you-513fa248cfb7) about the idea of this package. Please read the post to get all the details!\n\n## Features 🔥\n\n✅ Create an object instance using an anonymous class\n\n✅ Access the object during its initialization\n\n✅ Type the object using generics (type safety)\n\n✅ No dependencies\n\n## Built With 🔧\n\n- [TypeScript](https://www.typescriptlang.org/)\n\n## Installation 📦\n\n```console\npnpm i object-class-initializer\n// or\nyarn add object-class-initializer\n// or\nnpm i object-class-initializer\n```\n\n## Usage Example 🚀\n\n```typescript\nimport { createObject } from 'object-class-initializer';\n```\n\n```typescript\nconst obj = createObject(\n  class {\n    a = 'foo';\n    b = 'bar';\n    c = this.a + this.b; // foobar\n  }\n);\n// obj is now typed as { a: string, b: string, c: string }\n\n// OR typed\n\ntype FooBar = {\n  a: string;\n  b: string;\n  c: string;\n};\n\nconst obj = createObject\u003cFooBar\u003e(\n  class {\n    a = 'foo';\n    b = 'bar';\n    c = this.a + this.b; // foobar\n  }\n);\n// obj is now typed as FooBar\n```\n\n## Contributing 🧑🏻‍💻\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License 🔑\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n## Contact 📧\n\nJanik Schumacher - [@LoaderB0T](https://twitter.com/LoaderB0T) - [linkedin](https://www.linkedin.com/in/janikschumacher/)\n\nProject Link: [https://github.com/LoaderB0T/object-class-initializer](https://github.com/LoaderB0T/object-class-initializer)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floaderb0t%2Fobject-class-initializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floaderb0t%2Fobject-class-initializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floaderb0t%2Fobject-class-initializer/lists"}