mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
29 lines
725 B
JavaScript
29 lines
725 B
JavaScript
if (!Math.sign) {
|
|
Math.sign = function (x) {
|
|
x = +x; // convert to a number
|
|
if (x === 0 || isNaN(x)) {
|
|
return x;
|
|
}
|
|
return x > 0 ? 1 : -1;
|
|
};
|
|
}
|
|
|
|
if (!Number.isInteger) {
|
|
Number.isInteger = function (value) {
|
|
return typeof value === 'number' && (value | 0) === value;
|
|
};
|
|
}
|
|
|
|
if (!console.time) {
|
|
var Timer = window.performance || Date;
|
|
var _timerTable = Object.create(null);
|
|
console.time = function (label) {
|
|
_timerTable[label] = Timer.now();
|
|
};
|
|
console.timeEnd = function (label) {
|
|
var startTime = _timerTable[label];
|
|
var duration = Timer.now() - startTime;
|
|
console.log(`${label}: ${duration}ms`);
|
|
};
|
|
}
|