Skip to content

Commit

Permalink
prevent potential issue with lack of some dependencies after automati…
Browse files Browse the repository at this point in the history
…c optimization polyfills of some methods in the pure version
  • Loading branch information
zloirock committed Oct 18, 2023
1 parent 9a76ac2 commit c68c6d7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##### Unreleased
- Added one more workaround of possible error with `Symbol` polyfill on global object, [#1289](https://github.com/zloirock/core-js/issues/1289#issuecomment-1768411444)
- Directly specified `type: commonjs` in `package.json` of all packages to avoid potential breakage in future Node versions, see [this issue](https://github.com/nodejs/TSC/issues/1445)
- Prevented potential issue with lack of some dependencies after automatic optimization polyfills of some methods in the pure version
- Some minor internal fixes and optimizations
- Compat data improvements:
- [`String.prototype.{ isWellFormed, toWellFormed }`](https://github.com/tc39/proposal-is-usv-string) marked as [supported from FF119](https://bugzilla.mozilla.org/show_bug.cgi?id=1850755)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';
var global = require('../internals/global');
var path = require('../internals/path');

module.exports = function (CONSTRUCTOR, METHOD) {
var $namespace = path[CONSTRUCTOR + 'Prototype'];
return $namespace && $namespace[METHOD] || global[CONSTRUCTOR].prototype[METHOD];
};
4 changes: 2 additions & 2 deletions packages/core-js/internals/array-from-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ var getIterator = require('../internals/get-iterator');
var getIteratorDirect = require('../internals/get-iterator-direct');
var getIteratorMethod = require('../internals/get-iterator-method');
var getMethod = require('../internals/get-method');
var getVirtual = require('../internals/entry-virtual');
var getBuiltIn = require('../internals/get-built-in');
var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method');
var wellKnownSymbol = require('../internals/well-known-symbol');
var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
var toArray = require('../internals/async-iterator-iteration').toArray;

var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator');
var arrayIterator = uncurryThis(getVirtual('Array').values);
var arrayIterator = uncurryThis(getBuiltInPrototypeMethod('Array', 'values'));
var arrayIteratorNext = uncurryThis(arrayIterator([]).next);

var safeArrayIterator = function () {
Expand Down
6 changes: 6 additions & 0 deletions packages/core-js/internals/get-built-in-prototype-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';
var global = require('../internals/global');

module.exports = function (CONSTRUCTOR, METHOD) {
return global[CONSTRUCTOR].prototype[METHOD];
};
4 changes: 2 additions & 2 deletions packages/core-js/modules/es.array.to-sorted.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var uncurryThis = require('../internals/function-uncurry-this');
var aCallable = require('../internals/a-callable');
var toIndexedObject = require('../internals/to-indexed-object');
var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
var getVirtual = require('../internals/entry-virtual');
var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method');
var addToUnscopables = require('../internals/add-to-unscopables');

var $Array = Array;
var sort = uncurryThis(getVirtual('Array').sort);
var sort = uncurryThis(getBuiltInPrototypeMethod('Array', 'sort'));

// `Array.prototype.toSorted` method
// https://tc39.es/ecma262/#sec-array.prototype.tosorted
Expand Down

0 comments on commit c68c6d7

Please sign in to comment.