Skip to content

add asyncForEach#26

Open
quadramadery wants to merge 1 commit intow8r:masterfrom
quadramadery:asyncForEach
Open

add asyncForEach#26
quadramadery wants to merge 1 commit intow8r:masterfrom
quadramadery:asyncForEach

Conversation

@quadramadery
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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