{"id":19584789,"url":"https://github.com/flex-development/decorator-regex","last_synced_at":"2026-05-18T04:14:19.480Z","repository":{"id":65857932,"uuid":"601398005","full_name":"flex-development/decorator-regex","owner":"flex-development","description":"Decorator regex","archived":false,"fork":false,"pushed_at":"2024-01-15T03:29:43.000Z","size":1927,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T10:30:49.911Z","etag":null,"topics":["decorators","regex","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/flex-development/decorator-regex","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flex-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["flex-development"]}},"created_at":"2023-02-14T01:18:07.000Z","updated_at":"2023-10-18T03:52:56.000Z","dependencies_parsed_at":"2023-09-29T04:30:15.038Z","dependency_job_id":"754194e4-e528-463a-a5fe-0c737a7dbbf6","html_url":"https://github.com/flex-development/decorator-regex","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.31707317073170727","last_synced_commit":"4ea5111a0a2c12519765e568ae3805bc0c2a5867"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/flex-development/decorator-regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fdecorator-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fdecorator-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fdecorator-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fdecorator-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flex-development","download_url":"https://codeload.github.com/flex-development/decorator-regex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fdecorator-regex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33164680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"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":["decorators","regex","typescript"],"created_at":"2024-11-11T07:49:45.345Z","updated_at":"2026-05-18T04:14:19.446Z","avatar_url":"https://github.com/flex-development.png","language":"JavaScript","funding_links":["https://github.com/sponsors/flex-development"],"categories":[],"sub_categories":[],"readme":"# decorator-regex\n\n[![github release](https://img.shields.io/github/v/release/flex-development/decorator-regex.svg?include_prereleases\u0026sort=semver)](https://github.com/flex-development/decorator-regex/releases/latest)\n[![npm](https://img.shields.io/npm/v/@flex-development/decorator-regex.svg)](https://npmjs.com/package/@flex-development/decorator-regex)\n[![codecov](https://codecov.io/github/flex-development/decorator-regex/branch/main/graph/badge.svg?token=NO3rVfx9OF)](https://codecov.io/github/flex-development/decorator-regex)\n[![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![license](https://img.shields.io/github/license/flex-development/decorator-regex.svg)](LICENSE.md)\n[![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits\u0026logoColor=ffffff)](https://conventionalcommits.org/)\n[![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\u0026logoColor=ffffff)](https://typescriptlang.org/)\n[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat\u0026logo=vitest\u0026logoColor=ffffff)](https://vitest.dev/)\n[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\u0026logo=yarn\u0026logoColor=ffffff)](https://yarnpkg.com/)\n\n[Decorator][1] regex\n\n## Contents\n\n- [What is this?](#what-is-this)\n- [When should I use this?](#when-should-i-use-this)\n- [Install](#install)\n- [Use](#use)\n- [API](#api)\n  - [`DECORATOR_REGEX`](#decorator-regex)\n- [Types](#types)\n- [Related](#related)\n- [Contribute](#contribute)\n\n## What is this?\n\nThis package exports a regular expression for matching [decorators][1]. Decorators are functions called on classes,\nclass accessors, class fields, class methods, and/or class method parameters.\n\n## When should I use this?\n\nThe regular expression exported from this package can be used to match multi and single-line decorators in JavaScript\nand TypeScript source code.\n\nNote:\n\n- Decorators in comments (`/** */`, `/* */`, `//`) are ignored\n- Regular expression is ECMAScript-compatible. It has **not** been tested with other flavors (PCRE, PCRE2, etc)\n\n## Install\n\nThis package is [ESM only][2].\n\n```sh\nyarn add @flex-development/decorator-regex\n```\n\nFrom Git:\n\n```sh\nyarn add @flex-development/decorator-regex@flex-development/decorator-regex\n```\n\n\u003cblockquote\u003e\n  \u003csmall\u003e\n    See \u003ca href='https://yarnpkg.com/features/protocols#git'\u003eGit - Protocols | Yarn\u003c/a\u003e\n    \u0026nbsp;for details on requesting a specific branch, commit, or tag.\n  \u003c/small\u003e\n\u003c/blockquote\u003e\n\n## Use\n\nSuppose we have the following module:\n\n```typescript\nimport { DECORATOR_REGEX } from '@flex-development/decorator-regex'\nimport { omit } from '@flex-development/tutils'\nimport { dedent } from 'ts-dedent'\n\nconst code: string = dedent`\n  /**\n    * [Data access object][1] for the {@linkcode DatabaseTable.USERS} table.\n    *\n    * [1]: https://en.wikipedia.org/wiki/Data_access_object\n    *\n    * @extends {Entity\u003cIUserRaw,CreateUserDTO,IUser\u003e}\n    * @implements {IUser}\n    */\n   @Table\u003cUser\u003e({\n     defaultScope: {\n       attributes: ['created_at', 'email', 'id', 'provider'],\n       order: [['id', OrderDirection.ASC]],\n       raw: false\n     },\n     deletedAt: false,\n     hooks: {\n       /**\n        * Normalizes data before a user is persisted to the database.\n        *\n        * This includes:\n        *\n        * - Trimming and lowercasing string fields\n        *\n        * @param {User} instance - Current user instance\n        * @return {void} Nothing when complete\n        */\n       beforeSave(instance: User): void {\n         trimmedLowercasedFields(instance.dataValues)\n       }\n     },\n     omitNull: false,\n     paranoid: false,\n     tableName: DatabaseTable.USERS,\n     timestamps: true\n   })\n     class User\n       extends Entity\u003cIUserRaw, CreateUserDTO, IUser\u003e implements IUser {\n       @ApiProperty({ description: 'When user was created', type: Number })\n       @Column({\n         allowNull: false,\n         defaultValue: User.CURRENT_TIMESTAMP,\n         type: DataType.BIGINT,\n         validate: { isUnixTimestamp: User.isUnixTimestamp }\n       })\n       declare created_at: IUser['created_at']\n\n       @ApiProperty({\n         description: 'Email address',\n         maxLength: 254,\n         minLength: 3,\n         type: String\n       })\n       @Column({\n         allowNull: false,\n         type: DataType.STRING(254),\n         unique: true,\n         validate: { isEmail: true, len: [3, 254] }\n       })\n       declare email: IUser['email']\n\n       @ApiProperty({ description: 'Unique identifier', type: Number })\n       @Column({\n         allowNull: false,\n         autoIncrementIdentity: true,\n         defaultValue: Sequelize.fn('nextval', DatabaseSequence.USERS),\n         primaryKey: true,\n         type: 'NUMERIC',\n         unique: true,\n         validate: { notNull: true }\n       })\n       declare id: IUser['id']\n\n       @ApiProperty({\n         description: 'Authentication provider',\n         enum: OAuthProvider,\n         enumName: 'OAuthProvider',\n         nullable: true\n       })\n       @Column({\n         allowNull: true,\n         defaultValue: null,\n         type: DataType.ENUM(...User.AUTH_PROVIDERS)\n       })\n       declare provider: IUser['provider']\n\n       @HasMany(() =\u003e Token)\n       declare tokens: Token[]\n     }\n`\n\nconst print = (matches: IterableIterator\u003cRegExpMatchArray\u003e): void =\u003e {\n  console.debug([...matches].map(match =\u003e omit(match, ['input'])))\n}\n\nprint(code.matchAll(DECORATOR_REGEX))\n```\n\n...running that yields:\n\n```sh\n[\n  {\n    '0': '@Table\u003cUser\u003e({\\n' +\n      '   defaultScope: {\\n' +\n      \"     attributes: ['created_at', 'email', 'id', 'provider'],\\n\" +\n      \"     order: [['id', OrderDirection.ASC]],\\n\" +\n      '     raw: false\\n' +\n      '   },\\n' +\n      '   deletedAt: false,\\n' +\n      '   hooks: {\\n' +\n      '     /**\\n' +\n      '      * Normalizes data before a user is persisted to the database.\\n' +\n      '      *\\n' +\n      '      * This includes:\\n' +\n      '      *\\n' +\n      '      * - Trimming and lowercasing string fields\\n' +\n      '      *\\n' +\n      '      * @param {User} instance - Current user instance\\n' +\n      '      * @return {void} Nothing when complete\\n' +\n      '      */\\n' +\n      '     beforeSave(instance: User): void {\\n' +\n      '       trimmedLowercasedFields(instance.dataValues)\\n' +\n      '     }\\n' +\n      '   },\\n' +\n      '   omitNull: false,\\n' +\n      '   paranoid: false,\\n' +\n      '   tableName: DatabaseTable.USERS,\\n' +\n      '   timestamps: true\\n' +\n      ' })',\n    '1': 'Table',\n    '2': '({\\n' +\n      '   defaultScope: {\\n' +\n      \"     attributes: ['created_at', 'email', 'id', 'provider'],\\n\" +\n      \"     order: [['id', OrderDirection.ASC]],\\n\" +\n      '     raw: false\\n' +\n      '   },\\n' +\n      '   deletedAt: false,\\n' +\n      '   hooks: {\\n' +\n      '     /**\\n' +\n      '      * Normalizes data before a user is persisted to the database.\\n' +\n      '      *\\n' +\n      '      * This includes:\\n' +\n      '      *\\n' +\n      '      * - Trimming and lowercasing string fields\\n' +\n      '      *\\n' +\n      '      * @param {User} instance - Current user instance\\n' +\n      '      * @return {void} Nothing when complete\\n' +\n      '      */\\n' +\n      '     beforeSave(instance: User): void {\\n' +\n      '       trimmedLowercasedFields(instance.dataValues)\\n' +\n      '     }\\n' +\n      '   },\\n' +\n      '   omitNull: false,\\n' +\n      '   paranoid: false,\\n' +\n      '   tableName: DatabaseTable.USERS,\\n' +\n      '   timestamps: true\\n' +\n      ' })',\n    index: 227,\n    groups: [Object: null prototype] {\n      identifier: 'Table',\n      parameters: '({\\n' +\n        '   defaultScope: {\\n' +\n        \"     attributes: ['created_at', 'email', 'id', 'provider'],\\n\" +\n        \"     order: [['id', OrderDirection.ASC]],\\n\" +\n        '     raw: false\\n' +\n        '   },\\n' +\n        '   deletedAt: false,\\n' +\n        '   hooks: {\\n' +\n        '     /**\\n' +\n        '      * Normalizes data before a user is persisted to the database.\\n' +\n        '      *\\n' +\n        '      * This includes:\\n' +\n        '      *\\n' +\n        '      * - Trimming and lowercasing string fields\\n' +\n        '      *\\n' +\n        '      * @param {User} instance - Current user instance\\n' +\n        '      * @return {void} Nothing when complete\\n' +\n        '      */\\n' +\n        '     beforeSave(instance: User): void {\\n' +\n        '       trimmedLowercasedFields(instance.dataValues)\\n' +\n        '     }\\n' +\n        '   },\\n' +\n        '   omitNull: false,\\n' +\n        '   paranoid: false,\\n' +\n        '   tableName: DatabaseTable.USERS,\\n' +\n        '   timestamps: true\\n' +\n        ' })'\n    }\n  },\n  {\n    '0': \"@ApiProperty({ description: 'When user was created', type: Number })\",\n    '1': 'ApiProperty',\n    '2': \"({ description: 'When user was created', type: Number })\",\n    index: 994,\n    groups: [Object: null prototype] {\n      identifier: 'ApiProperty',\n      parameters: \"({ description: 'When user was created', type: Number })\"\n    }\n  },\n  {\n    '0': '@Column({\\n' +\n      '       allowNull: false,\\n' +\n      '       defaultValue: User.CURRENT_TIMESTAMP,\\n' +\n      '       type: DataType.BIGINT,\\n' +\n      '       validate: { isUnixTimestamp: User.isUnixTimestamp }\\n' +\n      '     })',\n    '1': 'Column',\n    '2': '({\\n' +\n      '       allowNull: false,\\n' +\n      '       defaultValue: User.CURRENT_TIMESTAMP,\\n' +\n      '       type: DataType.BIGINT,\\n' +\n      '       validate: { isUnixTimestamp: User.isUnixTimestamp }\\n' +\n      '     })',\n    index: 1068,\n    groups: [Object: null prototype] {\n      identifier: 'Column',\n      parameters: '({\\n' +\n        '       allowNull: false,\\n' +\n        '       defaultValue: User.CURRENT_TIMESTAMP,\\n' +\n        '       type: DataType.BIGINT,\\n' +\n        '       validate: { isUnixTimestamp: User.isUnixTimestamp }\\n' +\n        '     })'\n    }\n  },\n  {\n    '0': '@ApiProperty({\\n' +\n      \"       description: 'Email address',\\n\" +\n      '       maxLength: 254,\\n' +\n      '       minLength: 3,\\n' +\n      '       type: String\\n' +\n      '     })',\n    '1': 'ApiProperty',\n    '2': '({\\n' +\n      \"       description: 'Email address',\\n\" +\n      '       maxLength: 254,\\n' +\n      '       minLength: 3,\\n' +\n      '       type: String\\n' +\n      '     })',\n    index: 1296,\n    groups: [Object: null prototype] {\n      identifier: 'ApiProperty',\n      parameters: '({\\n' +\n        \"       description: 'Email address',\\n\" +\n        '       maxLength: 254,\\n' +\n        '       minLength: 3,\\n' +\n        '       type: String\\n' +\n        '     })'\n    }\n  },\n  {\n    '0': '@Column({\\n' +\n      '       allowNull: false,\\n' +\n      '       type: DataType.STRING(254),\\n' +\n      '       unique: true,\\n' +\n      '       validate: { isEmail: true, len: [3, 254] }\\n' +\n      '     })',\n    '1': 'Column',\n    '2': '({\\n' +\n      '       allowNull: false,\\n' +\n      '       type: DataType.STRING(254),\\n' +\n      '       unique: true,\\n' +\n      '       validate: { isEmail: true, len: [3, 254] }\\n' +\n      '     })',\n    index: 1425,\n    groups: [Object: null prototype] {\n      identifier: 'Column',\n      parameters: '({\\n' +\n        '       allowNull: false,\\n' +\n        '       type: DataType.STRING(254),\\n' +\n        '       unique: true,\\n' +\n        '       validate: { isEmail: true, len: [3, 254] }\\n' +\n        '     })'\n    }\n  },\n  {\n    '0': \"@ApiProperty({ description: 'Unique identifier', type: Number })\",\n    '1': 'ApiProperty',\n    '2': \"({ description: 'Unique identifier', type: Number })\",\n    index: 1615,\n    groups: [Object: null prototype] {\n      identifier: 'ApiProperty',\n      parameters: \"({ description: 'Unique identifier', type: Number })\"\n    }\n  },\n  {\n    '0': '@Column({\\n' +\n      '       allowNull: false,\\n' +\n      '       autoIncrementIdentity: true,\\n' +\n      \"       defaultValue: Sequelize.fn('nextval', DatabaseSequence.USERS),\\n\" +\n      '       primaryKey: true,\\n' +\n      \"       type: 'NUMERIC',\\n\" +\n      '       unique: true,\\n' +\n      '       validate: { notNull: true }\\n' +\n      '     })',\n    '1': 'Column',\n    '2': '({\\n' +\n      '       allowNull: false,\\n' +\n      '       autoIncrementIdentity: true,\\n' +\n      \"       defaultValue: Sequelize.fn('nextval', DatabaseSequence.USERS),\\n\" +\n      '       primaryKey: true,\\n' +\n      \"       type: 'NUMERIC',\\n\" +\n      '       unique: true,\\n' +\n      '       validate: { notNull: true }\\n' +\n      '     })',\n    index: 1685,\n    groups: [Object: null prototype] {\n      identifier: 'Column',\n      parameters: '({\\n' +\n        '       allowNull: false,\\n' +\n        '       autoIncrementIdentity: true,\\n' +\n        \"       defaultValue: Sequelize.fn('nextval', DatabaseSequence.USERS),\\n\" +\n        '       primaryKey: true,\\n' +\n        \"       type: 'NUMERIC',\\n\" +\n        '       unique: true,\\n' +\n        '       validate: { notNull: true }\\n' +\n        '     })'\n    }\n  },\n  {\n    '0': '@ApiProperty({\\n' +\n      \"       description: 'Authentication provider',\\n\" +\n      '       enum: OAuthProvider,\\n' +\n      \"       enumName: 'OAuthProvider',\\n\" +\n      '       nullable: true\\n' +\n      '     })',\n    '1': 'ApiProperty',\n    '2': '({\\n' +\n      \"       description: 'Authentication provider',\\n\" +\n      '       enum: OAuthProvider,\\n' +\n      \"       enumName: 'OAuthProvider',\\n\" +\n      '       nullable: true\\n' +\n      '     })',\n    index: 1974,\n    groups: [Object: null prototype] {\n      identifier: 'ApiProperty',\n      parameters: '({\\n' +\n        \"       description: 'Authentication provider',\\n\" +\n        '       enum: OAuthProvider,\\n' +\n        \"       enumName: 'OAuthProvider',\\n\" +\n        '       nullable: true\\n' +\n        '     })'\n    }\n  },\n  {\n    '0': '@Column({\\n' +\n      '       allowNull: true,\\n' +\n      '       defaultValue: null,\\n' +\n      '       type: DataType.ENUM(...User.AUTH_PROVIDERS)\\n' +\n      '     })',\n    '1': 'Column',\n    '2': '({\\n' +\n      '       allowNull: true,\\n' +\n      '       defaultValue: null,\\n' +\n      '       type: DataType.ENUM(...User.AUTH_PROVIDERS)\\n' +\n      '     })',\n    index: 2133,\n    groups: [Object: null prototype] {\n      identifier: 'Column',\n      parameters: '({\\n' +\n        '       allowNull: true,\\n' +\n        '       defaultValue: null,\\n' +\n        '       type: DataType.ENUM(...User.AUTH_PROVIDERS)\\n' +\n        '     })'\n    }\n  },\n  {\n    '0': '@HasMany(() =\u003e Token)',\n    '1': 'HasMany',\n    '2': '(() =\u003e Token)',\n    index: 2300,\n    groups: [Object: null prototype] {\n      identifier: 'HasMany',\n      parameters: '(() =\u003e Token)'\n    }\n  }\n]\n```\n\n## API\n\nThis package exports the identifier [`DECORATOR_REGEX`](#decorator-regex).\n\nThere is no default export.\n\n### `DECORATOR_REGEX`\n\nRegular expression matching multi and single-line decorators.\n\nIgnores matches in comments.\n\nRequired [flags][3]:\n\n- `s`: dot all\n- `u`: unicode\n\n\u003e **Source**: [`src/decorator-regex.ts`](src/decorator-regex.ts)\n\n## Types\n\nThis package is fully typed with [TypeScript][4].\n\n## Related\n\n- [`decorator-regex`][5] \u0026mdash; `export` statement regex\n- [`import-regex`][6] \u0026mdash; `import` statement regex\n\n## Contribute\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\n[1]: https://github.com/tc39/proposal-decorators\n[2]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n[3]: https://codeguage.com/courses/regexp/flags\n[4]: https://www.typescriptlang.org\n[5]: https://github.com/flex-development/decorator-regex\n[6]: https://github.com/flex-development/import-regex\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fdecorator-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflex-development%2Fdecorator-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fdecorator-regex/lists"}