BeDuration Class

A duration of time. Can be either positive (towards future) or negative (in the past). BeDurations are immutable.

Methods

Name Description
executeAfter<T>(fn: (...args: any[]) => T, scope?: any, ...args: any[]): Promise<T> Execute a function after delaying by this duration.  
minus(other: BeDuration): BeDuration Subtract a BeDuration from this BeDuration, returning a new BeDuration.  
plus(other: BeDuration): BeDuration Add a BeDuration to this BeDuration, returning a new BeDuration  
wait(): Promise<void> Utility function to just wait for the specified time  
fromMilliseconds(milliseconds: number): BeDuration Static Create a BeDuration from milliseconds.  
fromSeconds(seconds: number): BeDuration Static Create a BeDuration from seconds.  
race<T>(ms: number, promise: PromiseLike<T>): Promise<T | void> Static Utility function to wait for either the specified time or a promise, whichever resolves first  
wait(ms: number): Promise<void> Static Utility function to just wait for the specified time  

Properties

Name Type Description
isTowardsFuture Accessor ReadOnly boolean Determine whether this BeDuration is towards the future  
isTowardsPast Accessor ReadOnly boolean Determine whether this BeDuration is towards the past  
isZero Accessor ReadOnly boolean Determine whether this BeDuration is 0 seconds  
milliseconds Accessor ReadOnly number The duration in milliseconds  
seconds Accessor ReadOnly number    

Defined in

Last Updated: 23 April, 2020