1.0.1 • Published 6 years ago

unwrap-async-iterable-iterator-promise v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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.