Skip to content

Commit

Permalink
Merge pull request #290 from leebyron/patch-1
Browse files Browse the repository at this point in the history
Make AsyncIterator comply with AsyncIterable by supporting a this-returning
Symbol.asyncIterator method.
  • Loading branch information
benjamn committed Apr 26, 2017
2 parents f2579fc + 379c86b commit 2047ff4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/regenerator-runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";

var inModule = typeof module === "object";
Expand Down Expand Up @@ -229,6 +230,9 @@
}

defineIteratorMethods(AsyncIterator.prototype);
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
return this;
};
runtime.AsyncIterator = AsyncIterator;

// Note that simple async functions are implemented on top of
Expand Down

0 comments on commit 2047ff4

Please sign in to comment.