vesta
Version:
Simplify time measurements
19 lines (18 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = autoDetect;
var _myrmidon = require("myrmidon");
var _ProcessHrtime = _interopRequireDefault(require("./ProcessHrtime"));
var _PerformanceNow = _interopRequireDefault(require("./PerformanceNow"));
var _Timer = _interopRequireDefault(require("./Timer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function autoDetect() {
var _process, _process$hrtime, _performance;
const useProcess = typeof process !== 'undefined' && (0, _myrmidon.isFunction)((_process = process) === null || _process === void 0 ? void 0 : (_process$hrtime = _process.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.bigint);
if (useProcess) return new _ProcessHrtime.default();
const usePerformance = typeof performance !== 'undefined' && (0, _myrmidon.isFunction)((_performance = performance) === null || _performance === void 0 ? void 0 : _performance.now);
if (usePerformance) return new _PerformanceNow.default();
return new _Timer.default();
}