Skip to content

Commit

Permalink
add (Async)Iterator.prototype.constructor -> (Async)Iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 27, 2019
1 parent 22626ed commit 16cb899
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@
##### Unreleased
- Added a workaround of V8 deoptimization which causes serious performance degradation (~4x in my tests) of `Array#concat`, [#679](https://github.com/zloirock/core-js/issues/679)
- Added a workaround of V8 deoptimization which causes slightly performance degradation of `Promise`, [#679](https://github.com/zloirock/core-js/issues/679)
- Added `(Async)Iterator.prototype.constructor -> (Async)Iterator` per [this issue](https://github.com/tc39/proposal-iterator-helpers/issues/60)
- Added compat data for Chromium-based Edge

##### 3.3.4 - 2019.10.25
Expand Down
4 changes: 4 additions & 0 deletions packages/core-js/modules/esnext.async-iterator.constructor.js
Expand Up @@ -20,6 +20,10 @@ if (!has(AsyncIteratorPrototype, TO_STRING_TAG)) {
createNonEnumerableProperty(AsyncIteratorPrototype, TO_STRING_TAG, 'AsyncIterator');
}

if (!has(AsyncIteratorPrototype, 'constructor') || AsyncIteratorPrototype.constructor === Object) {
createNonEnumerableProperty(AsyncIteratorPrototype, 'constructor', AsyncIteratorConstructor);
}

$({ global: true, forced: IS_PURE }, {
AsyncIterator: AsyncIteratorConstructor
});
4 changes: 4 additions & 0 deletions packages/core-js/modules/esnext.iterator.constructor.js
Expand Up @@ -32,6 +32,10 @@ if (!has(IteratorPrototype, TO_STRING_TAG)) {
createNonEnumerableProperty(IteratorPrototype, TO_STRING_TAG, 'Iterator');
}

if (!has(IteratorPrototype, 'constructor') || IteratorPrototype.constructor === Object) {
createNonEnumerableProperty(IteratorPrototype, 'constructor', IteratorConstructor);
}

IteratorConstructor.prototype = IteratorPrototype;

$({ global: true, forced: FORCED }, {
Expand Down
4 changes: 4 additions & 0 deletions tests/pure/esnext.async-iterator.constructor.js
Expand Up @@ -12,6 +12,10 @@ QUnit.test('AsyncIterator', assert => {
assert.throws(() => AsyncIterator(), 'throws w/o `new`');
});

QUnit.test('AsyncIterator#constructor', assert => {
assert.strictEqual(AsyncIterator.prototype.constructor, AsyncIterator, 'AsyncIterator#constructor is AsyncIterator');
});

QUnit.test('AsyncIterator#@@toStringTag', assert => {
assert.strictEqual(AsyncIterator.prototype[Symbol.toStringTag], 'AsyncIterator', 'AsyncIterator::@@toStringTag is `AsyncIterator`');
});
4 changes: 4 additions & 0 deletions tests/pure/esnext.iterator.constructor.js
Expand Up @@ -13,6 +13,10 @@ QUnit.test('Iterator', assert => {
assert.throws(() => Iterator(), 'throws w/o `new`');
});

QUnit.test('Iterator#constructor', assert => {
assert.strictEqual(Iterator.prototype.constructor, Iterator, 'Iterator#constructor is Iterator');
});

QUnit.test('Iterator#@@toStringTag', assert => {
assert.strictEqual(Iterator.prototype[Symbol.toStringTag], 'Iterator', 'Iterator::@@toStringTag is `Iterator`');
});
4 changes: 4 additions & 0 deletions tests/tests/esnext.async-iterator.constructor.js
Expand Up @@ -19,6 +19,10 @@ QUnit.test('AsyncIterator', assert => {
assert.throws(() => AsyncIterator(), 'throws w/o `new`');
});

QUnit.test('AsyncIterator#constructor', assert => {
assert.strictEqual(AsyncIterator.prototype.constructor, AsyncIterator, 'AsyncIterator#constructor is AsyncIterator');
});

QUnit.test('AsyncIterator#@@toStringTag', assert => {
assert.strictEqual(AsyncIterator.prototype[Symbol.toStringTag], 'AsyncIterator', 'AsyncIterator::@@toStringTag is `AsyncIterator`');
assert.strictEqual(String(AsyncIterator.from([1, 2, 3])), '[object AsyncIterator]', 'correct stringification');
Expand Down
4 changes: 4 additions & 0 deletions tests/tests/esnext.iterator.constructor.js
Expand Up @@ -25,6 +25,10 @@ QUnit.test('Iterator', assert => {
assert.throws(() => Iterator(), 'throws w/o `new`');
});

QUnit.test('Iterator#constructor', assert => {
assert.strictEqual(Iterator.prototype.constructor, Iterator, 'Iterator#constructor is AsyncIterator');
});

QUnit.test('Iterator#@@toStringTag', assert => {
assert.strictEqual(Iterator.prototype[Symbol.toStringTag], 'Iterator', 'Iterator::@@toStringTag is `Iterator`');
assert.strictEqual(String(Iterator.from({
Expand Down

0 comments on commit 16cb899

Please sign in to comment.