wrap-function-timer

1.0.3 • Public • Published

function-timer

A wrapper for any functions you wish to time.

Getting started

npm i wrap-function-timer

Usage

Pass the function and any of its parameters into the 'time' method. We also pass in a variable which tells our timer whether or not to time the function. We return the results with the 'report' method which will then reset the stored times.

For example:

const timer = require('wrap-function-timer');

const myFunction = (args) => {
  console.log('I am about to be timed!');
  console.log('some functionality', args);
};

// regular invocation of function
myFunction(arg1, arg2, ...)

// timed invocation of function
// enabled param can be used to turn timer on/off
timer.time(myFunction, enabled = true, arg1, arg2, ...);
timer.report();

Readme

Keywords

none

Package Sidebar

Install

npm i wrap-function-timer

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

2.86 kB

Total Files

3

Last publish

Collaborators

  • connorft