timer-decorator

ES7 promise-aware timer decorator

Showing:

Popularity

Downloads/wk

4

GitHub Stars

1

Maintenance

Last Commit

3yrs ago

Contributors

3

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

Unlicense

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Timer Decorator

A simple Promise-aware ES7 timer decorator. Just logs the processing time for the given function, or the time until the promise resolves (ignores rejected promises). Note that the promise itself adds ~35-40ms in my basic testing.

Installation

npm install --save-dev timer-decorator

Usage

import timer from 'timer-decorator';

class Foo {
  @timer
  myMethod() {
    // ...
  }
}

will log something like:

Foo[0].myMethod: 123.456ms

The [0] is the instance #.

Enable and Disable

To enable or disable the timer, call:

timer.enable(this);
timer.disable(this);

where this is the class instance.

Release

timer.release(this);

to release the object and allow for gc to clean it. Note that you probably shouldn't be using this in production anyway, so it's somewhat irrelevant if you don't do this (I'm just writing it for you to be aware that you will keep around every object that has a timer in memory, forever, if release isn't called).

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100