new TimingUtility()
- Source:
A general-purpose set of utility and helper functions for timer-based operations.
Members
(static) constants
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
constants |
Object |
Methods
(static) convertHrTimeToNanos(hrTimeTuple) → {Number}
- Source:
Converts the process.hrtime() tuple to a single numerical value.
Parameters:
| Name | Type | Description |
|---|---|---|
hrTimeTuple |
Array.<Number> | The original result of process.hrtime() |
Returns:
The time value in nanoseconds
- Type
- Number
(static) selfCorrectingInterval(callback, intervalDuration) → {Object}
- Source:
A self-correcting recurring interval timer. Intended maximum correction resolution is the interval duration up to +/- the allowed percent tolerance by TimingUtility (currently 20%).
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | Function to call once each interval |
intervalDuration |
Number | Delay duration (msec) |
Returns:
Reference to an object whose 'timer' field refers to a NodeJS.Timer
- Type
- Object
(static) setImmediatePromise() → {Promise}
- Source:
Wraps Node.js setImmediate() in a thenable/Promise-like
Returns:
- Type
- Promise
(static) setIntervalByFrames(callback, intervalDuration, numFramesPerIntervalopt) → {Object}
- Source:
Runs a recurring interval timer that checks for its deadline at multiple smaller frames which are smaller than the specified interval. Depends on the base method: TimingUtility#selfCorrectingInterval
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
|||
intervalDuration |
Number | Must be at least 100 ms |
|
numFramesPerInterval |
Number |
<optional> |
The number of frames to divide the interval into. Default is 20 frames per interval. The acceptable divisions are currently between 20 and 40 frames per interval. Currently, only the 20 frames per interval option is supported with a known tolerance of +/- 20%. |
Returns:
The frameIntervalTimer field yields a: reference to an object whose 'timer' field refers to a NodeJS.Timer
- Type
- Object
(static) setTimeoutPromise(delay) → {Promise}
- Source:
Wraps Node.js setTimeout() in a thenable. It has some additional computation to guarantee that at least the specified delay duration has elapsed.
Parameters:
| Name | Type | Description |
|---|---|---|
delay |
Number | The minimum wait duration (msec) |
Returns:
- Type
- Promise