Appolo Decorators
useful decorators The cache will remove the oldest used item when reached max capacity
Installation:
npm install appolo-decorators --save
Delay
delay call method by given time in milliseconds
; @ { // ... }
Cache
cache method results using appolo-cache
options:
-
maxSize
- max cache size default1000
-
maxAge
- optional set maximum age in ms of all cache items default unlimited -
clone
- clone the cache result defaultfalse
-
interval
- set cache refresh interval -
resolver
- function to get the cache key by default the fist argument will be used as the cache key -
multi
- boolean if no resolver defined use all the arguments as key else use the first argument as key defaultfalse
-
peek
- boolean usepeek
method instead of get defaultfalse
-
refresh
- boolean refresh cache on halfmaxAge
expire defaultfalse
; private counter = 0; @ { return ++thiscounter } let someClass = ;someClassmethod // 1someClassmethod// 1
Bind
bind method to class instance
; @bind { // ... } documentbody;
Debounce
debounce method using lodash debounce
; @ { // ... }
Throttle
throttle method using lodash debounce
; @ { // ... }
Memoize
memoize method using lodash debounce
; @ { // ... }
Once
method will be called max n times and return last call result
; @ { // ... }
Interval
set interval to method once called
; @ { // ... }//start the intervalmethod
Mixins
add prototype to class
; @ { // ... }
License
MIT