0.0.4 • Published 6 years ago

iterable-has-next v0.0.4

Weekly downloads
7
License
ISC
Repository
gitlab
Last release
6 years ago

iterator-has-next

Simple helper that wraps standard AsyncIterableIterator and provides .hasNext() method.

Example code bellow or you can try it on repl.it.

async function usage () {
  // Create dummy iterator with 3 elemnts
  const iterator = createIterator(3)
  // Extend iterator to get one with .hasNext() method
  const extendedIterator = await extendIterator(iterator)
  console.log(`Example #1 how utilize new method`)
  for await (let i of extendedIterator) {
    console.log(`${i} | ${extendedIterator.hasNext()}`)
  }
  console.log(`Example #2 of how to use .hasNext()`)
  const it = await extendIterator(createIterator(3))
  while (it.hasNext()) {
    const { value } = await it.next()
    console.log(`${value} | ${it.hasNext()}`)
  }
}
0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago