{"id":16428823,"url":"https://github.com/netanelbasal/helpful-decorators","last_synced_at":"2025-05-16T04:02:30.855Z","repository":{"id":39034554,"uuid":"103775438","full_name":"NetanelBasal/helpful-decorators","owner":"NetanelBasal","description":"Helpful decorators for typescript projects","archived":false,"fork":false,"pushed_at":"2023-01-03T17:48:45.000Z","size":1944,"stargazers_count":466,"open_issues_count":18,"forks_count":50,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-16T04:01:47.686Z","etag":null,"topics":["debounce","decorators","measure","once","settimeout","throttle","typscript"],"latest_commit_sha":null,"homepage":"https://netbasal.com/create-and-test-decorators-in-javascript-85e8d5cf879c","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/NetanelBasal.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}},"created_at":"2017-09-16T18:39:10.000Z","updated_at":"2025-04-21T02:15:57.000Z","dependencies_parsed_at":"2023-02-01T08:31:07.860Z","dependency_job_id":null,"html_url":"https://github.com/NetanelBasal/helpful-decorators","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fhelpful-decorators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fhelpful-decorators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fhelpful-decorators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fhelpful-decorators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetanelBasal","download_url":"https://codeload.github.com/NetanelBasal/helpful-decorators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"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":["debounce","decorators","measure","once","settimeout","throttle","typscript"],"created_at":"2024-10-11T08:19:13.266Z","updated_at":"2025-05-16T04:02:30.323Z","avatar_url":"https://github.com/NetanelBasal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/dt/helpful-decorators.svg)]()\n[![Build Status](https://travis-ci.org/NetanelBasal/helpful-decorators.svg?branch=master)](https://travis-ci.org/NetanelBasal/helpful-decorators)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n\n# Helpful Decorators For Typescript Projects\n\n## Installation\n```js\nnpm install helpful-decorators\nyarn add helpful-decorators\n```\n\n## Usage\n`delay` - Add `setTimeout` functionality to the method\n\n```js\nimport { delay } from 'helpful-decorators';\n\nclass Test {\n @delay(1000)\n method() {\n   // ...\n }\n}\n```\n\n`debounce` - Add `debounce` functionality to the method ([options](https://lodash.com/docs/4.17.4#debounce))\n\n```js\nimport { debounce } from 'helpful-decorators';\n\nclass Test {\n @debounce(1000, options)\n method() {\n   // ...\n }\n}\n```\n\n`throttle` - Add `throttle` functionality to the method ([options](https://lodash.com/docs/4.17.4#throttle))\n```js\nimport { throttle } from 'helpful-decorators';\n\nclass Test {\n @throttle(1000, options)\n method() {\n   // ...\n }\n}\n```\n\n`once` - Add `once` functionality to the method\n```js\nimport { once } from 'helpful-decorators';\n\nclass Test {\n @once\n method() {\n   // This will run only once\n }\n}\n```\n\n`measure` - measure time taken by a function to execute\n```js\nimport { measure } from 'helpful-decorators';\n\nclass Test {\n @measure\n doSomething() {\n   // Call to doSomething took 0.35 milliseconds.\n }\n\n @measure\n async doSomethingHello(){\n    // Call to doSomethingHello took 0.35 milliseconds. \n }\n}\n```\n\n\n`Mixin` - this pattern is used to achieve multiple inheritance\n```js\nimport { Mixin } from 'helpful-decorators';\n\n@Mixin([Disposable, Activatable])\nclass Test {\n}\n```\n\n`memo` - memoizes the result of the function\n```js\nimport { memo } from 'helpful-decorators';\n\nclass Test {\n \n  @memo()\n  method() {\n    ...memoized\n  }\n}\n```\n\n`bind` - automatically bind methods to class instances\n```js\nimport { bind } from 'helpful-decorators';\n\n@Component({\n  selector: 'my-app',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.css']\n})\nexport class AppComponent {\n  constructor() {\n    document.body.addEventListener('click', this.onClick);\n  }\n\n  @bind\n  onClick($event) {\n    console.log($event);\n  }\n}\n```\n\n`SortBy` - sort an array by a specific property in individual elements or non-object items (By default, it sorts by `type === 'string'` and `isDescending === true`)\n```js\nimport { SortBy } from 'helpful-decorators';\n\nclass Test {\n  \n  @SortBy('name', {\n    isDescending: false,\n    type: 'string'\n  })\n  names = [ { name: 'b' }, { name: 'a' }, { name: 'c' } ];\n\n  @SortBy('', {\n    isDescending: true,\n    type: 'date'\n  })\n  dates = [ '2020-06-17', '2020-06-16', '2020-06-20', '2020-06-10' ];\n\n  @SortBy('', {\n    isDescending: false,\n    type: 'number'\n  })\n  numbers = [ 6, 3, 4, 1 ];\n}\n```\n \nLicense\n----\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetanelbasal%2Fhelpful-decorators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetanelbasal%2Fhelpful-decorators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetanelbasal%2Fhelpful-decorators/lists"}