-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromise.js
36 lines (30 loc) · 1.19 KB
/
promise.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function (context) {
/*jscs:disable validateIndentation*//*jscs:enable validateIndentation*/
// -----------------------------------------------------------------------------
'use strict';
var id = 'Promise';
var dependencies = Promise ? [] : ['./polyfill'];
function factory(Polyfill) {
var PromiseConstructor = Polyfill || Promise;
/**
* ES3-compatible alias for
* `[Promise.prototype.catch()](https://goo.gl/u3nRi1)`.
*/
PromiseConstructor.prototype.$catch = PromiseConstructor.prototype['catch'];
return PromiseConstructor;
}
// -----------------------------------------------------------------------------
var x = dependencies.length; var o = 'object';
context = typeof global === o ? global : typeof window === o ? window : context;
if (typeof define === 'function' && define.amd) {
define(dependencies, function () {
return factory.apply(context, [].slice.call(arguments));
});
} else if (typeof module === o && module.exports) {
for (; x--;) {dependencies[x] = require(dependencies[x]);}
module.exports = factory.apply(context, dependencies);
} else {
for (; x--;) {dependencies[x] = context[dependencies[x]];}
context[id] = factory.apply(context, dependencies);
}
}(this));