{"id":17726858,"url":"https://github.com/piterden/constructor-decorator","last_synced_at":"2025-03-31T14:47:41.785Z","repository":{"id":57206348,"uuid":"174272217","full_name":"Piterden/constructor-decorator","owner":"Piterden","description":"Constructor sugar with types checking","archived":false,"fork":false,"pushed_at":"2020-02-05T15:59:47.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-16T09:33:09.462Z","etag":null,"topics":["constructor","decorations","runtime-typechecking"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/constructor-decorator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Piterden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T04:35:40.000Z","updated_at":"2020-02-05T15:59:13.000Z","dependencies_parsed_at":"2022-09-11T05:20:12.608Z","dependency_job_id":null,"html_url":"https://github.com/Piterden/constructor-decorator","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piterden%2Fconstructor-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piterden%2Fconstructor-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piterden%2Fconstructor-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piterden%2Fconstructor-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Piterden","download_url":"https://codeload.github.com/Piterden/constructor-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246485402,"owners_count":20785312,"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":["constructor","decorations","runtime-typechecking"],"created_at":"2024-10-25T17:07:03.997Z","updated_at":"2025-03-31T14:47:41.758Z","avatar_url":"https://github.com/Piterden.png","language":"JavaScript","readme":"# Constructor Decorator\n\n![Travis (.com)](https://img.shields.io/travis/com/Piterden/constructor-decorator.svg?style=for-the-badge) ![npm](https://img.shields.io/npm/dt/constructor-decorator.svg?style=for-the-badge) ![NPM](https://img.shields.io/npm/l/constructor-decorator.svg?style=for-the-badge) ![npm](https://img.shields.io/npm/v/constructor-decorator.svg?style=for-the-badge)\n\nTypized and autoassigned arguments for JS class constructor.\n\n## Overview\n\nAre you not tired of constantly writing like:\n\n```js\nclass TypedEntity {\n  constructor (\n    foo,\n    bar,\n    baz,\n    bat,\n    fie,\n    bal,\n    fuu,\n    faa\n  ) {\n    this.baz = baz\n    this.bal = bal\n    this.foo = foo\n    this.fuu = fuu\n    this.bar = bar\n    this.bat = bat\n    this.fie = fie\n    this.faa = faa\n  }\n}\n\nmodule.exports = TypedEntity\n```\n\nNow you can avoid of it with the class extend:\n\n```js\nconst BaseClass = require('constructor-decorator')\n\nconst Foo = require('./Foo')\nconst Bar = require('./Bar')\nconst Baz = require('./Baz')\n\n\nclass TypedEntity extends BaseClass {\n  get args () {\n    return {\n      foo: [Foo, Baz],\n      bar: [Bar, String],\n      baz: String,\n      bat: Boolean,\n      fie: String,\n      bal: [String, Number],\n      fuu: Date,\n      faa: Number,\n    }\n  }\n\n  constructor () {\n    super(...arguments)\n  }\n}\n\nmodule.exports = TypedEntity\n```\n\nThe types compare is enabled with an array OR-operator syntax support.\n\n## Donate\n\n- **BTC** `3F275vPSCvYW19MHZqSjw79fEwwU4MbTgV`\n- **LTC** `MGMCQB3QAcrSBjU3eGJviqB2J2f5BNVRGr`\n- **DOGE** `D5m69FRDGEn3G3xuakvqTxUpGVt6NegKJp`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiterden%2Fconstructor-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiterden%2Fconstructor-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiterden%2Fconstructor-decorator/lists"}