Test Setup Failed
Push — master ( 8ee19e...25278d )
by recca
05:07 queued 46s
created

resources/assets/js/polyfill.js   A

Size

Lines of Code 59

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
nc 16
dl 0
loc 59
rs 10
c 2
b 0
f 0
noi 1

4 Functions

Rating   Name   Duplication   Size   Complexity  
A Object.defineProperty.value 0 3 1
A 0 15 2
A polyfill.js ➔ ??? 0 9 1
A Object.getPrototypeOf 0 7 2
1
'use strict';
2
3
import './jquery';
4
// import 'babel-polyfill';
5
6
(function() {
7
    var testObject = {};
8
9
    if (!(Object.setPrototypeOf || testObject.__proto__)) {
10
        var nativeGetPrototypeOf = Object.getPrototypeOf;
11
12
        Object.getPrototypeOf = function(object) {
0 ignored issues
show
Compatibility Best Practice introduced by
You are extending the built-in type Object. This may have unintended consequences on other objects using this built-in type. Consider subclassing instead.
Loading history...
13
            if (object.__proto__) {
14
                return object.__proto__;
15
            } else {
16
                return nativeGetPrototypeOf.call(Object, object);
17
            }
18
        }
19
    }
20
})();
21
22
if (!Object.assign) {
23
    Object.assign = $.extend;
24
}
25
26
if (!Array.prototype.includes) {
27
    Object.defineProperty(Array.prototype, 'includes', {
28
        value(...args) {
29
            return $.inArray(...args, this) !== -1;
30
        }
31
    });
32
}
33
34
class jQueryPromise {
35
    constructor(callback) {
36
        this.deferred = $.Deferred();
37
        callback((o) => {
38
            this.deferred.resolve(o);
39
        }, (o) => {
40
            this.deferred.reject(o);
41
        });
42
        this.promise = this.deferred.promise();
43
    }
44
45
    then(resolve, reject) {
46
        this.promise.done(resolve);
47
        this.promise.fail(reject);
48
        return this;
49
    }
50
51
    catch(reject) {
52
        this.promise.fail(reject);
53
        return this;
54
    }
55
}
56
57
if (!window.Promise) {
58
    window.Promise = jQueryPromise;
59
}
60