question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Iterator function doesn't work

See original GitHub issue

I followed your instructions in the issue #276 (you have closed it) But there is an error when using the iterator function.

Error: TypeError: this.keyv.iterator is not a function or its return value is not iterable

Code:

console.log(this.keyv.iterator()); // Return: Object [AsyncGenerator] {}
for (const [key, value] of this.keyv.iterator()) {
      console.log(key, value); 
};

I have tried with no specified database to use in the Keyv class and with SQLite

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
LACOSTAR91commented, Apr 21, 2022

This code doesn’t work:


console.log(this.keyv.iterator()); // Return: Object [AsyncGenerator] {}
for (const [key, value] of this.keyv.iterator()) {
      console.log(key, value); // Return nothing
};

This code work:


console.log(this.keyv.iterator()); // Return: Object [AsyncGenerator] {}
for await (const [key, value] of this.keyv.iterator()) {
      console.log(key, value); // Return: key and value 
};

(Sorry for my bad English, I’m French)

3reactions
jaredwraycommented, Apr 12, 2022

Ok. I will look into this and figure out why this is happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Iterator function not working on internal variable - Stack Overflow
I'm receiving an Unresolved reference: next on currentDay() . I'm aware the answer to this question is the exact same code without next()...
Read more >
Iterators and generators - JavaScript - MDN Web Docs
When called, generator functions do not initially execute their code. Instead, they return a special type of iterator, called a Generator.
Read more >
4. Iterators and Generators - Python Cookbook, 3rd ... - O'Reilly
You want to take a slice of data produced by an iterator, but the normal slicing operator doesn't work. Solution. The itertools.islice() function...
Read more >
Iterators - The Conservative Python 3 Porting Guide
In Python 3, the map() and filter() functions return iterators ( map or filter ... The fixers do not work properly if the...
Read more >
Async iteration and generators - The Modern JavaScript Tutorial
Features that require regular, synchronous iterators, don't work with ... Generators are labelled with function* (note the star) and use ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found