import { AsyncIterator } from "https://deno.land/x/ldkit@v0.7.0/library/asynciterator.ts";
An asynchronous iterator provides pull-based access to a stream of objects.
Properties
Gets whether the iterator will not emit anymore items, either due to being closed or due to being destroyed.
Methods
Changes the iterator to the given state if possible and necessary, possibly emitting events to signal that change.
Called by module:asynciterator.AsyncIterator#destroy. Implementers can override this, but this should not be called directly.
Ends the iterator and cleans up.
Should never be called before module:asynciterator.AsyncIterator#close;
typically, close
is responsible for calling _end
.
Asynchronously calls _end
.
Generates details for a textual representation of the iterator.
Appends the items after those of the current iterator. After this operation, only read the returned iterator instead of the current one.
Creates a copy of the current iterator, containing all items emitted from this point onward. Further copies can be created; they will all start from this same point. After this operation, only read the returned copies instead of the original iterator.
Stops the iterator from generating new items. Already generated items or terminating items can still be emitted. After this, the iterator will end asynchronously.
Copies the given properties from the source iterator.
Destroy the iterator and stop it from generating new items. This will not do anything if the iterator was already ended or destroyed. All internal resources will be released an no new items will be emitted, even not already generated items. Implementors should not override this method, but instead implement module:asynciterator.AsyncIterator#_destroy.
Return items from this iterator that match the filter. After this operation, only read the returned iterator instead of the current one.
Invokes the callback for each remaining item in the iterator. Switches the iterator to flow mode.
Retrieves all properties of the iterator.
Retrieves the property with the given name from the iterator.
If no callback is passed, it returns the value of the property
or undefined
if the property is not set.
If a callback is passed, it returns undefined
and calls the callback with the property the moment it is set.
Maps items from this iterator using the given function. After this operation, only read the returned iterator instead of the current one.
Prepends the items after those of the current iterator. After this operation, only read the returned iterator instead of the current one.
Limits the current iterator to the given range. The current iterator may not be read anymore until the returned iterator ends.
Tries to read the next item from the iterator.
This is the main method for reading the iterator in on-demand mode,
where new items are only created when needed by consumers.
If no items are currently available, this methods returns null
.
The module:asynciterator.event:readable event
will then signal when new items might be ready.
To read all items from the iterator,
switch to flow mode by subscribing
to the module:asynciterator.event:data event.
When in flow mode, do not use the read
method.
Sets all of the given properties.
Sets the property with the given name to the value.
Skips the given number of items from the current iterator. The current iterator may not be read anymore until the returned iterator ends.
Surrounds items of the current iterator with the given items. After this operation, only read the returned iterator instead of the current one.
Limits the current iterator to the given number of items. The current iterator may not be read anymore until the returned iterator ends.
Consume all remaining items of the iterator into an array that will be returned asynchronously.
Transforms items from this iterator. After this operation, only read the returned iterator instead of the current one.
Returns a new iterator containing all of the unique items in the original iterator.