Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81152 views
1
(function() {
2
3
var Ap = Array.prototype;
4
var slice = Ap.slice;
5
var Fp = Function.prototype;
6
7
if (!Fp.bind) {
8
// PhantomJS doesn't support Function.prototype.bind natively, so
9
// polyfill it whenever this module is required.
10
Fp.bind = function(context) {
11
var func = this;
12
var args = slice.call(arguments, 1);
13
14
function bound() {
15
var invokedAsConstructor = func.prototype && (this instanceof func);
16
return func.apply(
17
// Ignore the context parameter when invoking the bound function
18
// as a constructor. Note that this includes not only constructor
19
// invocations using the new keyword but also calls to base class
20
// constructors such as BaseClass.call(this, ...) or super(...).
21
!invokedAsConstructor && context || this,
22
args.concat(slice.call(arguments))
23
);
24
}
25
26
// The bound function must share the .prototype of the unbound
27
// function so that any object created by one constructor will count
28
// as an instance of both constructors.
29
bound.prototype = func.prototype;
30
31
return bound;
32
};
33
}
34
35
})();
36
37