MCPcopy Create free account
hub / github.com/apache/cloudstack / bind

Function bind

tools/ngui/static/js/lib/angular.js:711–729  ·  view source on GitHub ↗

* @ngdoc function * @name angular.bind * @function * * @description * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for * `fn`). You can supply optional `args` that are prebound to the function. This feature is also * known as [function currying](http

(self, fn)

Source from the content-addressed store, hash-verified

709 * @returns {function()} Function that wraps the `fn` with all the specified bindings.
710 */
711function bind(self, fn) {
712 var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : [];
713 if (isFunction(fn) && !(fn instanceof RegExp)) {
714 return curryArgs.length
715 ? function() {
716 return arguments.length
717 ? fn.apply(self, curryArgs.concat(slice.call(arguments, 0)))
718 : fn.apply(self, curryArgs);
719 }
720 : function() {
721 return arguments.length
722 ? fn.apply(self, arguments)
723 : fn.call(self);
724 };
725 } else {
726 // in IE, native methods are not functions so they cannot be bound (note: they don't need to be)
727 return fn;
728 }
729}
730
731
732function toJsonReplacer(key, value) {

Callers 2

compositeLinkFnFunction · 0.85
getterFunction · 0.85

Calls 4

sliceArgsFunction · 0.85
isFunctionFunction · 0.85
applyMethod · 0.65
callMethod · 0.45

Tested by

no test coverage detected