⏱️ TrackTimeWrapper — Time Utilities
Measure execution time and format durations with ease.
🕒 TrackTimeWrapper.formatDuration(ms)
Convert milliseconds into a human-readable duration string.
1import { TrackTimeWrapper } from 'hbh-nodes';3TrackTimeWrapper.formatDuration(65000); // "1 min 5 sec"4TrackTimeWrapper.formatDuration(3600000); // "1 hr 0 sec"
✨ Features
- Converts milliseconds to weeks, days, hours, minutes, seconds
- Clean output for logs & CLIs
- Zero dependencies
⏱️ TrackTimeWrapper.Wrapper(asyncFn, ...args)
Wrap any async function and return its execution time.
1import { TrackTimeWrapper } from 'hbh-nodes';3async function task() {4 await new Promise(res => setTimeout(res, 1200));5 return 'Done';6}8const { result, duration } =9 await TrackTimeWrapper.Wrapper(task);11console.log(result); // "Done"12console.log(duration); // "1 sec"
✨ Features
- Measures async function runtime
- Returns
{ result, duration } - Internally uses
TrackTimeWrapper.formatDuration - Ideal for benchmarking & performance logs
💡 When to Use
- CLI tools
- Performance measurement
- Async task monitoring
- Developer debugging