From 20ab9c5807a540abd291abada6e1dca8d9a37b0f Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Tue, 17 Jan 2023 02:15:19 +0700 Subject: [PATCH] coerce negative set size in `get-set-record` to 0 --- CHANGELOG.md | 3 ++- packages/core-js/internals/get-set-record.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a39689499b6..cff5166aeec4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ## Changelog ##### Unreleased -- [`Set` methods proposal](https://github.com/tc39/proposal-set-methods) minor updates: +- [`Set` methods proposal](https://github.com/tc39/proposal-set-methods) updates: - Closing of iterators of `Set`-like objects on early exit, [proposal-set-methods/85](https://github.com/tc39/proposal-set-methods/pull/85) + - Some other minor internal changes - 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 diff --git a/packages/core-js/internals/get-set-record.js b/packages/core-js/internals/get-set-record.js index a0d5133d7fdb..b6c6e6a08e84 100644 --- a/packages/core-js/internals/get-set-record.js +++ b/packages/core-js/internals/get-set-record.js @@ -4,6 +4,7 @@ var call = require('../internals/function-call'); var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var $TypeError = TypeError; +var max = Math.max; var SetRecord = function (set, size, has, keys) { this.set = set; @@ -31,7 +32,7 @@ module.exports = function (obj) { if (numSize != numSize) throw $TypeError('Invalid size'); return new SetRecord( obj, - toIntegerOrInfinity(numSize), + max(toIntegerOrInfinity(numSize), 0), aCallable(obj.has), aCallable(obj.keys) );