Methods
batch(values, optionsopt) → {external:Promise}
Settles (resolves or rejects) every mixed value in the input array.
The method resolves with an array of results, the same as the standard promise.all, while providing comprehensive error details in case of a reject, in the form of type BatchError.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
values |
Array | Array of mixed values (it can be empty), to be resolved asynchronously, in no particular order. Passing in anything other than an array will reject with TypeError =
|
|||||||||
options |
Object |
<optional> |
Optional Parameters. Properties
|
- Source:
Returns:
The method resolves with an array of individual resolved results, the same as the standard promise.all.
In addition, the array is extended with a hidden read-only property duration
- number of milliseconds
spent resolving all the data.
The method rejects with BatchError when any of the following occurs:
- one or more values rejected or threw an error while being resolved as a mixed value
- notification callback
cb
returned a rejected promise or threw an error
- Type
- external:Promise
page(source, optionsopt) → {external:Promise}
Resolves a dynamic sequence of pages/arrays with mixed values.
The method acquires pages (arrays of mixed values) from the source
function, one by one,
and resolves each page as a batch, till no more pages left or an error/reject occurs.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
function | generator | Expected to return a mixed value that resolves with the next page of data (array of mixed values).
Returning or resolving with The function inherits Parameters:
If the function throws an error or returns a rejected promise, the method rejects with
PageError, which will have property And if the function returns or resolves with anything other than an array or Passing in anything other than a function will reject with TypeError = |
||||||||||||||||
options |
Object |
<optional> |
Optional Parameters. Properties
|
- Source:
Returns:
When successful, the method resolves with object {pages, total, duration}
:
pages
= number of pages resolvedtotal
= the sum of all page sizes (total number of values resolved)duration
= number of milliseconds consumed by the method
When the method fails, it rejects with PageError.
- Type
- external:Promise
sequence(source, optionsopt) → {external:Promise}
Resolves a dynamic sequence of mixed values.
The method acquires mixed values from the source
function, one at a time, and resolves them,
till either no more values left in the sequence or an error/reject occurs.
It supports both linked and detached sequencing.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
function | generator | Expected to return the next mixed value to be resolved. Returning or resolving
with Parameters:
The function inherits If the function throws an error or returns a rejected promise, the sequence terminates,
and the method rejects with SequenceError, which will have property Passing in anything other than a function will reject with TypeError = |
|||||||||||||||||||||
options |
Object |
<optional> |
Optional Parameters. Properties
|
- Source:
Returns:
When successful, the resolved data depends on parameter track
. When track
is false
(default), the method resolves with object {total, duration}
:
total
= number of values resolved by the sequenceduration
= number of milliseconds consumed by the method
When track
is true
, the method resolves with an array of all the data that has been resolved,
the same way that the standard promise.all resolves. In addition, the array comes extended with
a hidden read-only property duration
- number of milliseconds consumed by the method.
When the method fails, it rejects with SequenceError.
- Type
- external:Promise