Lines of Code | 59 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
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) { |
||
|
|||
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 |