Class: TimeWindow

TimeWindow

Iterable class representing a collection of elements that fall within a time window.

Members

(readonly) durationMillis :number

Get the duration of the window in milliseconds.
Type:
  • number
Source:

end :number

End time of the window, expressed as milliseconds elapsed since January 1, 1970 00:00:00 UTC. The object's inclusiveEnd field indicates whether the end is inclusive or exclusive.
Type:
  • number
Source:

(readonly) endDate :Date

Get the end time of the window as a Date object. The object's inclusiveEnd field indicates whether the end is inclusive or exclusive.
Type:
  • Date
Source:

isEndInclusive :bool

Whether the end time is inclusive (true) or exclusive (false)
Type:
  • bool
Source:

start :number

Start time (inclusive) of the window, expressed as milliseconds elapsed since January 1, 1970 00:00:00 UTC.
Type:
  • number
Source:

(readonly) startDate :Date

Get the start time (inclusive) of the window as a Date object.
Type:
  • Date
Source:

Methods

every(callbackfn, thisArgopt) → {boolean}

The every() method tests whether all elements in the TimeWindow pass the test implemented by the provided function. If the window is empty then the method will always return true.
Parameters:
Name Type Attributes Description
callbackfn predicateCallback Function to test for each element.
thisArg any <optional>
Optional. Value to use as this when executing the callback.
Source:
Returns:
true if the callback function returns a truthy value for every TimeWindow element; otherwise, false.
Type
boolean

filter(callbackfn, thisArgopt) → {Array}

Creates a new array containing elements from the TimeWindow that pass the test implemented by the provided function.
Parameters:
Name Type Attributes Description
callbackfn predicateCallback Function is a predicate used to test each element of the array. Return true to keep the element, false otherwise.
thisArg any <optional>
Optional. Value to use as this when executing the callback.
Source:
Returns:
A new array with the elements that pass the test. If no elements pass the test, an empty array will be returned.
Type
Array

find(callbackfn, thisArgopt) → {any}

Returns the value of the first element in the TimeWindow that satisfies the provided testing function. Otherwise undefined is returned.
Parameters:
Name Type Attributes Description
callbackfn predicateCallback Function to test for each element.
thisArg any <optional>
Optional. Value to use as this when executing the callback.
Source:
Returns:
The value of the first element in the TimeWindow that satisfies the provided testing function; otherwise, undefined is returned.
Type
any

forEach(callbackfn, thisArgopt) → {undefined}

Executes a provided function once for each TimeWindow element.
Parameters:
Name Type Attributes Description
callbackfn predicateCallback Function to execute for each element.
thisArg any <optional>
Optional. Value to use as this when executing the callback.
Source:
Returns:
Type
undefined

map(callbackfn, thisArgopt) → {Array}

Creates a new array with the results of calling a provided function on every element in the calling TimeWindow instance.
Parameters:
Name Type Attributes Description
callbackfn mapCallback Function that produces an element of the new Array.
thisArg any <optional>
Optional. Value to use as this when executing callback.
Source:
Returns:
A new array with each element being the result of the callback function.
Type
Array

reduce(callbackfn, initialValueopt) → {any}

Executes the provided reducer function on each member of the TimeWindow, resulting in a single output value.
Parameters:
Name Type Attributes Description
callbackfn reduceCallback Function that executes each element in the TimeWindow and returns an accumulating value.
initialValue any <optional>
Optional. Value to use as the first argument to the first call of the callback. If no initial value is supplied, the first element in the window will be used. Calling reduce() on an empty window without an initial value is an error.
Source:
Returns:
The accumulated value that results from the reduction.
Type
any

some(callbackfn, thisArgopt) → {boolean}

The some() method tests whether at least one element in the TimeWindow passes the test implemented by the provided function. If the window is empty then the method will always return false.
Parameters:
Name Type Attributes Description
callbackfn predicateCallback Function to test for each element.
thisArg any <optional>
Optional. Value to use as this when executing the callback.
Source:
Returns:
true if the callback function returns a truthy value for any array element; otherwise, false.
Type
boolean

toArray() → {Array}

Returns elements in the window as an Array.
Source:
Returns:
The window's elements as a new Array.
Type
Array