Helpful Decorators For Typescript Projects
Installation
npm install helpful-decoratorsyarn add helpful-decorators
Usage
delay
- Add setTimeout
functionality to the method
; @ { // ... }
debounce
- Add debounce
functionality to the method (options)
; @ { // ... }
throttle
- Add throttle
functionality to the method (options)
; @ { // ... }
once
- Add once
functionality to the method
; @once { // This will run only once }
measure
- measure time taken by a function to execute
; @measure { // Call to doSomething took 0.35 milliseconds. }
Mixin
- this pattern is used to achieve multiple inheritance
; @
memo
- memoizes the result of the function
; @ { ...memoized }
bind
- automatically bind methods to class instances
; @ { documentbody; } @bind { console; }
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
)
; @ names = name: 'b' name: 'a' name: 'c' ; @ dates = '2020-06-17' '2020-06-16' '2020-06-20' '2020-06-10' ; @ numbers = 6 3 4 1 ;
License
MIT