-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathuniversalApply.js
More file actions
45 lines (40 loc) · 1.04 KB
/
universalApply.js
File metadata and controls
45 lines (40 loc) · 1.04 KB
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
37
38
39
40
41
42
43
44
45
(function(){
'use strict';
(function(define){
function evaluates (statement) {
try {
/* jshint evil: true */
eval(statement);
/* jshint evil: false */
return true;
} catch (err) {
return false;
}
}
// we have to know it synchronously, we are unable to load this module in asynchronous way
// we cannot defer `define` and we cannot load module, that would not compile in browser
// so we can't delegate this check to another module
function isSpreadAvailable() {
return evaluates('Math.max(...[ 5, 10 ])');
}
var requires = [];
if (typeof(process) !== 'undefined' && 'ES_VERSION' in process.env) {
requires.push('./es'+process.env.ES_VERSION+'Apply');
} else {
if(isSpreadAvailable()) {
requires.push('./es6Apply');
} else {
requires.push('./es5Apply');
}
}
define(requires, function(apply){
return apply;
});
})(
typeof define === 'function'
? define
: function(requires, factory) {
module.exports = factory.apply(null, requires.map(require));
}
);
})();