Skip to content

Commit

Permalink
avoid a check of the target in the internal function-uncurry-this h…
Browse files Browse the repository at this point in the history
…elper where it's not required
  • Loading branch information
zloirock committed Nov 6, 2022
1 parent 5528d56 commit 3bcbad2
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog
##### Unreleased
- Disabled forced replacing of `Array.fromAsync` since it's on Stage 3
- Avoiding a check of the target in the internal `function-uncurry-this` helper where it's not required

##### [3.26.0 - 2022.10.24](https://github.com/zloirock/core-js/releases/tag/v3.26.0)
- [`Array.fromAsync` proposal](https://github.com/tc39/proposal-array-from-async):
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js-pure/override/internals/export.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var global = require('../internals/global');
var apply = require('../internals/function-apply');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var isCallable = require('../internals/is-callable');
var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
var isForced = require('../internals/is-forced');
Expand Down
6 changes: 3 additions & 3 deletions packages/core-js/internals/classof-raw.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var uncurryThisRaw = require('../internals/function-uncurry-this-raw');
var uncurryThis = require('../internals/function-uncurry-this');

var toString = uncurryThisRaw({}.toString);
var stringSlice = uncurryThisRaw(''.slice);
var toString = uncurryThis({}.toString);
var stringSlice = uncurryThis(''.slice);

module.exports = function (it) {
return stringSlice(toString(it), 8, -1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
// TODO: Remove from `core-js@4` since it's moved to entry points
require('../modules/es.regexp.exec');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var defineBuiltIn = require('../internals/define-built-in');
var regexpExec = require('../internals/regexp-exec');
var fails = require('../internals/fails');
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/internals/function-bind-context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var aCallable = require('../internals/a-callable');
var NATIVE_BIND = require('../internals/function-bind-native');

Expand Down
9 changes: 9 additions & 0 deletions packages/core-js/internals/function-uncurry-this-clause.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var classofRaw = require('../internals/classof-raw');
var uncurryThis = require('../internals/function-uncurry-this');

module.exports = function (fn) {
// Nashorn bug:
// https://github.com/zloirock/core-js/issues/1128
// https://github.com/zloirock/core-js/issues/1130
if (classofRaw(fn) === 'Function') return uncurryThis(fn);
};
11 changes: 0 additions & 11 deletions packages/core-js/internals/function-uncurry-this-raw.js

This file was deleted.

16 changes: 9 additions & 7 deletions packages/core-js/internals/function-uncurry-this.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
var classofRaw = require('../internals/classof-raw');
var uncurryThisRaw = require('../internals/function-uncurry-this-raw');
var NATIVE_BIND = require('../internals/function-bind-native');

module.exports = function (fn) {
// Nashorn bug:
// https://github.com/zloirock/core-js/issues/1128
// https://github.com/zloirock/core-js/issues/1130
if (classofRaw(fn) === 'Function') return uncurryThisRaw(fn);
var FunctionPrototype = Function.prototype;
var call = FunctionPrototype.call;
var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);

module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
return function () {
return call.apply(fn, arguments);
};
};
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.array-buffer.slice.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var $ = require('../internals/export');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var fails = require('../internals/fails');
var ArrayBufferModule = require('../internals/array-buffer');
var anObject = require('../internals/an-object');
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.array.index-of.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
/* eslint-disable es/no-array-prototype-indexof -- required for testing */
var $ = require('../internals/export');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var $indexOf = require('../internals/array-includes').indexOf;
var arrayMethodIsStrict = require('../internals/array-method-is-strict');

Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.string.ends-with.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var $ = require('../internals/export');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
var toLength = require('../internals/to-length');
var toString = require('../internals/to-string');
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.string.match-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable es/no-string-prototype-matchall -- safe */
var $ = require('../internals/export');
var call = require('../internals/function-call');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var createIteratorConstructor = require('../internals/iterator-create-constructor');
var createIterResultObject = require('../internals/create-iter-result-object');
var requireObjectCoercible = require('../internals/require-object-coercible');
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.string.starts-with.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var $ = require('../internals/export');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
var toLength = require('../internals/to-length');
var toString = require('../internals/to-string');
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.typed-array.sort.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var global = require('../internals/global');
var uncurryThis = require('../internals/function-uncurry-this');
var uncurryThis = require('../internals/function-uncurry-this-clause');
var fails = require('../internals/fails');
var aCallable = require('../internals/a-callable');
var internalSort = require('../internals/array-sort');
Expand Down
4 changes: 2 additions & 2 deletions packages/core-js/modules/esnext.function.un-this.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var $ = require('../internals/export');
var uncurryThisRaw = require('../internals/function-uncurry-this-raw');
var uncurryThis = require('../internals/function-uncurry-this');
var aCallable = require('../internals/a-callable');

// `Function.prototype.unThis` method
// https://github.com/js-choi/proposal-function-un-this
$({ target: 'Function', proto: true, forced: true }, {
unThis: function unThis() {
return uncurryThisRaw(aCallable(this));
return uncurryThis(aCallable(this));
}
});

0 comments on commit 3bcbad2

Please sign in to comment.