Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / composer / test / helpers / pack / phantomjs-shims.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19 (function() {
20
21 var Ap = Array.prototype;
22 var slice = Ap.slice;
23 var Fp = Function.prototype;
24
25 if (!Fp.bind) {
26 // PhantomJS doesn't support Function.prototype.bind natively, so
27 // polyfill it whenever this module is required.
28 Fp.bind = function(context) {
29 var func = this;
30 var args = slice.call(arguments, 1);
31
32 function bound() {
33 var invokedAsConstructor = func.prototype && (this instanceof func);
34 return func.apply(
35 // Ignore the context parameter when invoking the bound function
36 // as a constructor. Note that this includes not only constructor
37 // invocations using the new keyword but also calls to base class
38 // constructors such as BaseClass.call(this, ...) or super(...).
39 !invokedAsConstructor && context || this,
40 args.concat(slice.call(arguments))
41 );
42 }
43
44 // The bound function must share the .prototype of the unbound
45 // function so that any object created by one constructor will count
46 // as an instance of both constructors.
47 bound.prototype = func.prototype;
48
49 return bound;
50 };
51 }
52 })();