easy-decorator

1.0.4 • Public • Published

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() {

  }
}

Package Sidebar

Install

npm i easy-decorator

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

1.95 kB

Total Files

3

Last publish

Collaborators

  • simplej