Skip to content

Commit

Permalink
Merge jridgewell/bind-nativeBind into executeBound-constructor-fix
Browse files Browse the repository at this point in the history
This fixes jashkenas#2214.
  • Loading branch information
jgonggrijp committed May 3, 2020
2 parents 2a11f87 + 72645ef commit bf24482
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ var root = typeof self == 'object' && self.self === self && self ||
{};

// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
var ArrayProto = Array.prototype, FuncProto = Function.prototype, ObjProto = Object.prototype;
var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;

// Create quick reference variables for speed access to core prototypes.
var push = ArrayProto.push,
slice = ArrayProto.slice,
_bind = FuncProto.bind,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty;

Expand Down Expand Up @@ -766,7 +767,9 @@ function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
// available.
export var bind = restArguments(function(func, context, args) {
export var bind = _bind ? restArguments(function(func, args) {
return _bind.apply(func, args);
}) : restArguments(function(func, context, args) {
if (!isFunction(func)) throw new TypeError('Bind must be called on a function');
var bound = restArguments(function(callArgs) {
return executeBound(func, bound, context, this, args.concat(callArgs));
Expand Down
7 changes: 5 additions & 2 deletions underscore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion underscore.js.map

Large diffs are not rendered by default.

0 comments on commit bf24482

Please sign in to comment.