Skip to content

russoedu/elapsy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elapsy

Elapsy is a singleton class that calculates the elapsed time from the moment the first instance until the moment one of the possible functions is called.

Install

npm install --save elapsy

Usage

In order to use elapsy, you need to instantiate the class when you want to start counting the time. EG right after you start your application

const Elapsy = require('elapsy');

// This will mark the current time for the next calls
const elapsy = new Elapsy();

When you want to check the execution time, you can use one of the following functions:

time

Returns the number of the execution time in miliseconds

const elapsy = new Elapsy();

const elapsed = elapsy.time();
console.log(elapsed);

formated

Returns a formated string of the execution time in the format hh:mm:ss:ms.

If the elapsed time is more than a day, the number of days is show in the start of the string.

Examples:

00:13:08.324

03:00:59.999

1 day, 12:43:17.385

428 days, 04:58:23.032

const elapsy = new Elapsy();

const formatedElapsed = elapsy.formated();
console.log(formatedElapsed);

log

Insert the formated (hh:mm:ss.ms) string of the current elapsed time in the right end of the terminal.

You can pass a chalk color to the method (default is blue) and if you want to show the miliseconds;

Example:

const elapsy = new Elapsy();

elapsy.log('white', false);

About

Elapsy calculates the elapsed time from the moment the first instance (singleton) is created

Resources

License

Stars

Watchers

Forks

Packages

No packages published