-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var NATIVE_BIND = require('../internals/function-bind-native'); | ||
|
||
var FunctionPrototype = Function.prototype; | ||
var apply = FunctionPrototype.apply; | ||
var bind = FunctionPrototype.bind; | ||
var call = FunctionPrototype.call; | ||
|
||
// eslint-disable-next-line es/no-reflect -- safe | ||
module.exports = typeof Reflect == 'object' && Reflect.apply || (bind ? call.bind(apply) : function () { | ||
module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () { | ||
return call.apply(apply, arguments); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var aCallable = require('../internals/a-callable'); | ||
var NATIVE_BIND = require('../internals/function-bind-native'); | ||
|
||
var bind = uncurryThis(uncurryThis.bind); | ||
|
||
// optional / simple context binding | ||
module.exports = function (fn, that) { | ||
aCallable(fn); | ||
return that === undefined ? fn : bind ? bind(fn, that) : function (/* ...args */) { | ||
return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) { | ||
return fn.apply(that, arguments); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var fails = require('../internals/fails'); | ||
|
||
module.exports = !fails(function () { | ||
var test = (function () { /* empty */ }).bind(); | ||
// eslint-disable-next-line no-prototype-builtins -- safe | ||
return typeof test != 'function' || test.hasOwnProperty('prototype'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
var NATIVE_BIND = require('../internals/function-bind-native'); | ||
|
||
var call = Function.prototype.call; | ||
|
||
module.exports = call.bind ? call.bind(call) : function () { | ||
module.exports = NATIVE_BIND ? call.bind(call) : function () { | ||
return call.apply(call, arguments); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters