init commit
This commit is contained in:
31
src/polyfill/_es6.js
Normal file
31
src/polyfill/_es6.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { polyfill } from 'es6-promise';
|
||||
|
||||
// Object.assign
|
||||
if (typeof Object.assign != 'function') {
|
||||
// Must be writable: true, enumerable: false, configurable: true
|
||||
Object.defineProperty(Object, "assign", {
|
||||
value: function assign(target, varArgs) { // .length of function is 2
|
||||
'use strict';
|
||||
if (target == null) { // TypeError if undefined or null
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
var to = Object(target);
|
||||
for (var index = 1; index < arguments.length; index++) {
|
||||
var nextSource = arguments[index];
|
||||
if (nextSource != null) { // Skip over if undefined or null
|
||||
for (var nextKey in nextSource) {
|
||||
// Avoid bugs when hasOwnProperty is shadowed
|
||||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return to;
|
||||
},
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
||||
polyfill();
|
||||
24
src/polyfill/_global.js
Normal file
24
src/polyfill/_global.js
Normal file
@@ -0,0 +1,24 @@
|
||||
let _global = {};
|
||||
// global
|
||||
if (typeof GameGlobal !== 'undefined') {
|
||||
_global = Object.assign({}, GameGlobal);
|
||||
} else if (typeof window === 'undefined') {
|
||||
_global = {
|
||||
setTimeout: (...params) => {
|
||||
return setTimeout(...params);
|
||||
},
|
||||
setInterval: (...params) => {
|
||||
return setInterval(...params);
|
||||
},
|
||||
clearTimeout: (...params) => {
|
||||
return clearTimeout(...params);
|
||||
},
|
||||
clearInterval: (...params) => {
|
||||
return clearInterval(...params);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
_global = window;
|
||||
}
|
||||
|
||||
export default _global;
|
||||
2
src/polyfill/index.js
Normal file
2
src/polyfill/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import './_global';
|
||||
import './_es6';
|
||||
Reference in New Issue
Block a user