Skip to content

Commit

Permalink
closing of iterators of Set-like objects on early exit
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jan 13, 2023
1 parent 9e56d89 commit 32cbd8f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog
##### Unreleased
- [`Set` methods proposal](https://github.com/tc39/proposal-set-methods) minor updates:
- Closing of iterators of `Set`-like objects on early exit, [proposal-set-methods/85](https://github.com/tc39/proposal-set-methods/pull/85)
- Added one more workaround of a `webpack` dev server bug on IE global methods, [#1161](https://github.com/zloirock/core-js/issues/1161)
- Fixed possible `String.{ raw, cooked }` error with empty template array
- Used non-standard V8 `Error.captureStackTrace` instead of stack parsing in new error classes / wrappers where it's possible
Expand Down
8 changes: 4 additions & 4 deletions packages/core-js/internals/set-is-disjoint-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var has = require('../internals/set-helpers').has;
var size = require('../internals/set-size');
var getSetRecord = require('../internals/get-set-record');
var iterateSet = require('../internals/set-iterate');
var iterateSimple = require('../internals/iterate-simple');
var iterate = require('../internals/iterate');

// `Set.prototype.isDisjointFrom` method
// https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom
Expand All @@ -15,8 +15,8 @@ module.exports = function isDisjointFrom(other) {
? iterateSet(O, function (e) {
if (otherRec.includes(e)) return false;
}, true)
: iterateSimple(otherRec.getIterator(), function (e) {
if (has(O, e)) return false;
})
: !iterate(otherRec.getIterator(), function (e, stop) {
if (has(O, e)) return stop();
}, { IS_ITERATOR: true, INTERRUPTED: true }).stopped
);
};
8 changes: 4 additions & 4 deletions packages/core-js/internals/set-is-superset-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var aSet = require('../internals/a-set');
var has = require('../internals/set-helpers').has;
var size = require('../internals/set-size');
var getSetRecord = require('../internals/get-set-record');
var iterateSimple = require('../internals/iterate-simple');
var iterate = require('../internals/iterate');

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

0 comments on commit 32cbd8f

Please sign in to comment.