Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add asyncForEach #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

quadramadery
Copy link
Contributor

I've been playing around with Issue #17

Example asyncForEach, using async/await. If you like it, I can add asyncRange as well.
Although asyncForEach fails miserably in benchmark.

@w8r
Copy link
Owner

w8r commented Oct 19, 2018

Thanks a lot! I will look into it (try and find how to compile it into es5-6). Do you have some use cases in mind?

@vladislav-atakhanov
Copy link

I think it's better to add an [Symbol.iterator]. Iterators are used in more cases than asyncForEach.

*[Symbol.iterator]() {
  var current = this._root
  var stack = []

  var done = false
  while (!done) {
    if (current) {
      stack.push(current)
      current = current.left
    } else {
      if (stack.length > 0) {
        current = stack.pop()
        yield current
        current = current.right
      } else done = true
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants