Skip to content

Commit 32cbd8f

Browse files
committedJan 13, 2023
closing of iterators of Set-like objects on early exit
tc39/proposal-set-methods#85
1 parent 9e56d89 commit 32cbd8f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Changelog
22
##### Unreleased
3+
- [`Set` methods proposal](https://github.com/tc39/proposal-set-methods) minor updates:
4+
- Closing of iterators of `Set`-like objects on early exit, [proposal-set-methods/85](https://github.com/tc39/proposal-set-methods/pull/85)
35
- Added one more workaround of a `webpack` dev server bug on IE global methods, [#1161](https://github.com/zloirock/core-js/issues/1161)
46
- Fixed possible `String.{ raw, cooked }` error with empty template array
57
- Used non-standard V8 `Error.captureStackTrace` instead of stack parsing in new error classes / wrappers where it's possible

‎packages/core-js/internals/set-is-disjoint-from.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var has = require('../internals/set-helpers').has;
44
var size = require('../internals/set-size');
55
var getSetRecord = require('../internals/get-set-record');
66
var iterateSet = require('../internals/set-iterate');
7-
var iterateSimple = require('../internals/iterate-simple');
7+
var iterate = require('../internals/iterate');
88

99
// `Set.prototype.isDisjointFrom` method
1010
// https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom
@@ -15,8 +15,8 @@ module.exports = function isDisjointFrom(other) {
1515
? iterateSet(O, function (e) {
1616
if (otherRec.includes(e)) return false;
1717
}, true)
18-
: iterateSimple(otherRec.getIterator(), function (e) {
19-
if (has(O, e)) return false;
20-
})
18+
: !iterate(otherRec.getIterator(), function (e, stop) {
19+
if (has(O, e)) return stop();
20+
}, { IS_ITERATOR: true, INTERRUPTED: true }).stopped
2121
);
2222
};

‎packages/core-js/internals/set-is-superset-of.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ var aSet = require('../internals/a-set');
33
var has = require('../internals/set-helpers').has;
44
var size = require('../internals/set-size');
55
var getSetRecord = require('../internals/get-set-record');
6-
var iterateSimple = require('../internals/iterate-simple');
6+
var iterate = require('../internals/iterate');
77

88
// `Set.prototype.isSupersetOf` method
99
// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf
1010
module.exports = function isSupersetOf(other) {
1111
var O = aSet(this);
1212
var otherRec = getSetRecord(other);
1313
if (size(O) < otherRec.size) return false;
14-
return iterateSimple(otherRec.getIterator(), function (e) {
15-
if (has(O, e) === false) return false;
16-
}) !== false;
14+
return !iterate(otherRec.getIterator(), function (e, stop) {
15+
if (!has(O, e)) return stop();
16+
}, { IS_ITERATOR: true, INTERRUPTED: true }).stopped;
1717
};

0 commit comments

Comments
 (0)
Please sign in to comment.