Constructor
new TransformIterator(sourceopt, optionsopt)
Creates a new TransformIterator
.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
module:asynciterator.AsyncIterator | Readable |
<optional> |
The source this iterator generates items from |
||||||||||||||||||||||||||||||
options |
object |
<optional> |
Settings of the iterator Properties
|
Extends
- module:asynciterator.BufferedIterator
Members
source :module:asynciterator.AsyncIterator
The source this iterator generates items from.
Type:
- module:asynciterator.AsyncIterator
Methods
(protected) _closeWhenDone()
Closes the iterator when pending items are transformed.
(protected) _loadSourceAsync()
Initializes a source that was set through a promise
_optionalTransform()
Tries to transform the item; if the transformation yields no items, pushes the original item.
_read()
Tries to read transformed items.
_readAndTransform()
Reads a transforms an item
(protected) _transform(item, done, push)
Generates items based on the item from the source. Implementers should add items through BufferedIterator#_push. The default implementation pushes the source item as-is.
Parameters:
Name | Type | Description |
---|---|---|
item |
object | The last read item from the source |
done |
function | To be called when reading is complete |
push |
function | A callback to push zero or more transformation results. |
(protected) _validateSource(source, allowDestination)
Validates whether the given iterator can be used as a source.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
source |
object | The source to validate |
|
allowDestination |
boolean | false | Whether the source can already have a destination |