decorators-es6
Decorators for es6+, with promise support(Async support)
Install
npm install decorators-es6
yarn add decorators-es6
Decorators
- debounce
- memoize
- cache - alias for memoize
- throttle
Features
- Easy to use as decorator in es6
- Promise support
- Decorated function return value in promise chain
- Async(work with async as promise)
Warning
For use this package your app need to support these features(Babel or Polyfills):
- Promise
- arrow functions () => {}
- import, export
Usage
debounce(time)
Default debounce time = 500ms
; message = 'msg'; @ { thismessage = message; return 'updated'; }; @ { return axios; } const store = ;store; store; store;
memoize(time) or cache(time)
Default memoize time = 9999999ms
; @ { return number * 5; }; // memoize product info for 100 secs @ { return axios; } const service = ;service service
throtle(time)
Default debounce time = 500ms Example: see debounce example