Methods
log()
Log the Horloge instance
raw() → {Object}
Returns the raw values for start, end and (optionally) the difference between the two
Returns:
raw
- Type
- Object
reset()
Initialises start and end times to null
start()
Records the start time
stop()
Records the end time and sets the difference
stopAndLog()
Convenience function to stop the timer and log the result
toMs() → {String}
Convert time in milliseconds to a readable format, with provided options
Returns:
Readable time with unit
- Type
- String
toString()
Override for the toString method
wrapFunction(fn, callback) → {Horloge}
Wraps a function with a callback and calls it, recording start and end time
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | The function to wrap |
callback |
function | Callback to call when `fn` finishes |
Returns:
An Horloge instance
- Type
- Horloge
wrapPromise(p) → {Horloge}
Wraps a promise and calls it, recording start and end time
Parameters:
Name | Type | Description |
---|---|---|
p |
Promise | The promise to wrap |
Returns:
An Horloge instance
- Type
- Horloge