1.0.4 • Published 6 years ago

easy-decorator v1.0.4

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

easy-decorator

Install

npm install easy-decorator --save

Example

import easyDecorator from 'easy-decorator';
import _ from 'lodash';

const once = easyDecorator(fn => {
  let hasRun = false;
  let result;
  return function() {
    if(!hasRun) {
      result = fn.apply(this, arguments);
      hasRun = true;
    }
    return result;
  };
});

const throttle = easyDecorator(_.throttle);

class C {
  @once get myGetter() {

  }

  @once myMethod() {

  }

  @throttle(250) myThrottledMethod() {

  }
}
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago