unwrap-async-iterable-iterator-promise
v1.0.1
Published
Unwrap a `Promise` of an `AsyncIterableIterator` into a `AsyncIterableIterator`.
Downloads
11
Readme
Unwrap Async Iterable Iterator Promise
Unwrap a Promise
of an AsyncIterableIterator
into a AsyncIterableIterator
.
Installation
npm install --save unwrap-async-iterable-iterator-promise
Usage
const unwrapAsyncIterableIteratorPromise = require('unwrap-async-iterable-iterator-promise')
function iterateOverItems () {
const iteratorPromise = getResource().then((resource) => {
return resource.iterateItems()
})
return unwrapAsyncIterableIteratorPromise(iteratorPromise)
}
API
unwrapAsyncIterableIteratorPromise<T> (input: Promise<AsyncIterableIterator<T>>): AsyncIterableIterator<T>
Returns an async iterator that will wait for input
to resolve, and the yield the items from the resolved iterator.