Package Exports
- timer-node
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (timer-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
timer-node
A simple timer that enables recording ellapsed time and format the result.
Table of Contents
Install
npm install --save timer-nodeAPI
require
const Timer = require('timer-node');import
import Timer from 'timer-node';Construction
const timer = new Timer('test-timer');.start()
starts the timer
timer.start();.stop()
stops the timer
timer.stop();.isRunning()
checks if the timer is running and hasn't been stopped
console.log(timer.isRunning()); // false.seconds()
return the seconds part in the recorded time
console.log(timer.seconds()); // 4.milliseconds()
return the milliseconds part in the recorded time
console.log(timer.milliseconds()); // 254.microseconds()
return the microseconds part in the recorded time
console.log(timer.microseconds()); // 782.nanoseconds()
return the nanoseconds part in the recorded time
console.log(timer.nanoseconds()); // 615.format(template)
formats the recorded time using a custom or default template. The function replaces the time fractions placeholders in a string. Placeholders are:
%lblfor the timer label.%sfor the seconds.%msfor the milliseconds.%usfor the microseconds.%nsfor the nanoseconds.
// using the default template
console.log(timer.format()); // test-timer: 4 s, 254 ms, 782 us, 615 ns
// using a custom template
const custom = '%lbl [%s] s [%ms] ms';
console.log(timer.format(custom)); // test-timer [4] s [254] ms.clear()
clears the timer values. Can be started again to record new time.
timer.clear();
console.log(timer.seconds()); // nullBuild
grunt buildLicense
The MIT License. Full License is here