Last active
August 21, 2019 22:46
-
-
Save lennyburdette/a3aaf36ad31c8dca715a6c2d7e1882a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// https://github.com/emberjs/ember.js/blob/v3.13.0-beta.3/packages/%40ember/runloop/index.js#L226 | |
export const bind = (...curried) => { | |
assert( | |
'could not find a suitable method to bind', | |
(function(methodOrTarget, methodOrArg) { | |
// Applies the same logic as backburner parseArgs for detecting if a method | |
// is actually being passed. | |
let length = arguments.length; | |
if (length === 0) { | |
return false; | |
} else if (length === 1) { | |
return typeof methodOrTarget === 'function'; | |
} else { | |
let type = typeof methodOrArg; | |
return ( | |
type === 'function' || // second argument is a function | |
(methodOrTarget !== null && type === 'string' && methodOrArg in methodOrTarget) || // second argument is the name of a method in first argument | |
typeof methodOrTarget === 'function' //first argument is a function | |
); | |
} | |
})(...curried) | |
); | |
return (...args) => join(...curried.concat(args)); | |
}; |
This file contains hidden or 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 is what shows up in the source maps for my vendor.js | |
var bind = (...curried) => { | |
(true && !(function (methodOrTarget, methodOrArg) { | |
// Applies the same logic as backburner parseArgs for detecting if a method | |
// is actually being passed. | |
var length = arguments.length; | |
if (length === 0) { | |
return false; | |
} else if (length === 1) { | |
return typeof methodOrTarget === 'function'; | |
} else { | |
var type = typeof methodOrArg; | |
return type === 'function' || // second argument is a function | |
methodOrTarget !== null && type === 'string' && methodOrArg in methodOrTarget || // second argument is the name of a method in first argument | |
typeof methodOrTarget === 'function' //first argument is a function | |
; | |
} | |
}(...curried)) && (0, _debug.assert)('could not find a suitable method to bind', function (methodOrTarget, methodOrArg) { | |
var length = arguments.length; | |
if (length === 0) { | |
return false; | |
} else if (length === 1) { | |
return typeof methodOrTarget === 'function'; | |
} else { | |
var type = typeof methodOrArg; | |
return type === 'function' || methodOrTarget !== null && type === 'string' && methodOrArg in methodOrTarget || typeof methodOrTarget === 'function'; | |
} | |
}(...curried))); | |
return (...args) => join(...curried.concat(args)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment