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 object that enables recording time and format the result.
Install
npm install --save timer-nodeUsage
Creation
const timerFn = require('timer-node');
const timer = timerFn('test-timer');.start()
starts the timer
timer.start();.stop()
stops the timer
timer.stop();.seconds()
return the seconds part in the recorded timer
console.log(timer.seconds()); // 4.milliseconds()
return the milliseconds part in the recorded timer
console.log(timer.milliseconds()); // 254.microseconds()
return the microseconds part in the recorded timer
console.log(timer.microseconds()); // 782.nanoseconds()
return the nanoseconds part in the recorded timer
console.log(timer.nanoseconds()); // 615.isRunning()
checks if the timer is running and hasn't been stopped
console.log(timer.isRunning()); // false.isStopped()
checks if the timer has been stopped
console.log(timer.isStopped()); // true.format(template)
formats the recorded time using a custom or default template. The function replaces the time fractions placeholders in a string. Placeholders are:
%labelfor 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 = '%label: [%s secs %ms ms]';
console.log(timer.format(custom)); // test-timer: [4 secs 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