Socket
Socket
Sign inDemoInstall

timer-decorator

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    timer-decorator

ES7 promise-aware timer decorator


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Install size
3.81 kB
Created
Weekly downloads
 

Readme

Source

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).

Keywords

FAQs

Last updated on 21 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc