Skip to content

Commit 68c9bf6

Browse files
committed
smoothed behavior of some conflicting proposals
1 parent ebe0286 commit 68c9bf6

File tree

7 files changed

+13
-6
lines changed

7 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
- Added Quest Browser 24.0 compat data mapping
103103
- Fixed the first version in the Chromium-based Edge compat data mapping
104104
- `{ Map, WeakMap }.prototype.emplace` became stricter [by the spec draft](https://tc39.es/proposal-upsert/)
105+
- Smoothed behavior of some conflicting proposals
105106
- Removed some generic behavior (like `@@species` pattern) of some `.prototype` methods from the [new collections methods proposal](https://github.com/tc39/proposal-collection-methods) and the [`Array` deduplication proposal](https://github.com/tc39/proposal-array-unique) that *most likely* will not be implemented since it contradicts the current TC39 policy
106107
- Added pure version of the `Number` constructor, [#1154](https://github.com/zloirock/core-js/issues/1154), [#1155](https://github.com/zloirock/core-js/issues/1155), thanks [@trosos](https://github.com/trosos)
107108
- Added `set(Timeout|Interval|Immediate)` extra arguments fix for Bun 0.3.0- (similarly to IE9-), [bun/1633](https://github.com/oven-sh/bun/issues/1633)

packages/core-js/modules/esnext.map.group-by.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
var $ = require('../internals/export');
33
var call = require('../internals/function-call');
44
var uncurryThis = require('../internals/function-uncurry-this');
5+
var isCallable = require('../internals/is-callable');
56
var aCallable = require('../internals/a-callable');
67
var iterate = require('../internals/iterate');
8+
var Map = require('../internals/map-helpers').Map;
79

810
var push = uncurryThis([].push);
911

1012
// `Map.groupBy` method
1113
// https://github.com/tc39/proposal-collection-methods
1214
$({ target: 'Map', stat: true, forced: true }, {
1315
groupBy: function groupBy(iterable, keyDerivative) {
14-
var newMap = new this();
16+
var C = isCallable(this) ? this : Map;
17+
var newMap = new C();
1518
aCallable(keyDerivative);
1619
var has = aCallable(newMap.has);
1720
var get = aCallable(newMap.get);

packages/core-js/modules/esnext.map.key-by.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
var $ = require('../internals/export');
33
var call = require('../internals/function-call');
44
var iterate = require('../internals/iterate');
5+
var isCallable = require('../internals/is-callable');
56
var aCallable = require('../internals/a-callable');
7+
var Map = require('../internals/map-helpers').Map;
68

79
// `Map.keyBy` method
810
// https://github.com/tc39/proposal-collection-methods
911
$({ target: 'Map', stat: true, forced: true }, {
1012
keyBy: function keyBy(iterable, keyDerivative) {
11-
var newMap = new this();
13+
var C = isCallable(this) ? this : Map;
14+
var newMap = new C();
1215
aCallable(keyDerivative);
1316
var setter = aCallable(newMap.set);
1417
iterate(iterable, function (element) {

tests/unit-global/esnext.map.group-by.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ QUnit.test('Map.groupBy', assert => {
2020
const element = {};
2121
Map.groupBy([element], it => assert.same(it, element));
2222

23-
assert.throws(() => groupBy([1, 2], it => it));
23+
// assert.throws(() => groupBy([1, 2], it => it));
2424
});

tests/unit-global/esnext.map.key-by.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ QUnit.test('Map.keyBy', assert => {
2020
const element = {};
2121
Map.keyBy([element], it => assert.same(it, element));
2222

23-
assert.throws(() => keyBy([1, 2], it => it));
23+
// assert.throws(() => keyBy([1, 2], it => it));
2424
});

tests/unit-pure/esnext.map.group-by.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ QUnit.test('Map.groupBy', assert => {
2020
const element = {};
2121
Map.groupBy([element], it => assert.same(it, element));
2222

23-
assert.throws(() => groupBy([1, 2], it => it));
23+
// assert.throws(() => groupBy([1, 2], it => it));
2424
});

tests/unit-pure/esnext.map.key-by.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ QUnit.test('Map.keyBy', assert => {
2020
const element = {};
2121
Map.keyBy([element], it => assert.same(it, element));
2222

23-
assert.throws(() => keyBy([1, 2], it => it));
23+
// assert.throws(() => keyBy([1, 2], it => it));
2424
});

0 commit comments

Comments
 (0)