Skip to content

Commit 7aaedbb

Browse files
committed
[Fix] use Symbol.asyncIterator
1 parent 7ac8a1e commit 7aaedbb

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ var hasSymbols = require('has-symbols');
66

77
var asyncIterProto = typeof AsyncIterator === 'function' ? AsyncIterator.prototype : {};
88

9-
if (hasSymbols() && !(Symbol.iterator in asyncIterProto)) {
10-
asyncIterProto[Symbol.iterator] = function () {
9+
if (hasSymbols() && Symbol.asyncIterator && !(Symbol.asyncIterator in asyncIterProto)) {
10+
asyncIterProto[Symbol.asyncIterator] = function () {
1111
return this;
1212
};
1313
}

test/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ test('AsyncIterator.prototype', function (t) {
99
t.ok(asyncIterProto, 'is truthy');
1010
t.equal(typeof asyncIterProto, 'object', 'is an object');
1111

12-
t.test('Symbol.iterator', { skip: !hasSymbols }, function (st) {
13-
var fn = asyncIterProto[Symbol.iterator];
12+
t.test('Symbol.asyncIterator', { skip: !hasSymbols || !Symbol.asyncIterator }, function (st) {
13+
var fn = asyncIterProto[Symbol.asyncIterator];
1414

15-
st.equal(typeof fn, 'function', 'Symbol.iterator is a function');
15+
st.equal(typeof fn, 'function', 'Symbol.asyncIterator is a function');
1616

1717
var sentinel = {};
1818
st.equal(
1919
fn.call(sentinel),
2020
sentinel,
21-
'Symbol.iterator returns receiver'
21+
'Symbol.asyncIterator returns receiver'
2222
);
2323

2424
st.end();

0 commit comments

Comments
 (0)