mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Install prettier and eslint
This commit is contained in:
@@ -4,27 +4,31 @@
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
let EventLoopMonitor;
|
||||
module.exports = (EventLoopMonitor = {
|
||||
monitor(logger, interval, log_threshold) {
|
||||
if (interval == null) { interval = 1000; }
|
||||
if (log_threshold == null) { log_threshold = 100; }
|
||||
const Metrics = require("./index");
|
||||
// check for logger on startup to avoid exceptions later if undefined
|
||||
if ((logger == null)) { throw new Error("logger is undefined"); }
|
||||
// monitor delay in setInterval to detect event loop blocking
|
||||
let previous = Date.now();
|
||||
const intervalId = setInterval(function() {
|
||||
const now = Date.now();
|
||||
const offset = now - previous - interval;
|
||||
if (offset > log_threshold) {
|
||||
logger.warn({offset}, "slow event loop");
|
||||
}
|
||||
previous = now;
|
||||
return Metrics.timing("event-loop-millsec", offset);
|
||||
}
|
||||
, interval);
|
||||
|
||||
return Metrics.registerDestructor(() => clearInterval(intervalId));
|
||||
}
|
||||
});
|
||||
module.exports = {
|
||||
monitor(logger, interval, logThreshold) {
|
||||
if (interval == null) {
|
||||
interval = 1000
|
||||
}
|
||||
if (logThreshold == null) {
|
||||
logThreshold = 100
|
||||
}
|
||||
const Metrics = require('./index')
|
||||
// check for logger on startup to avoid exceptions later if undefined
|
||||
if (logger == null) {
|
||||
throw new Error('logger is undefined')
|
||||
}
|
||||
// monitor delay in setInterval to detect event loop blocking
|
||||
let previous = Date.now()
|
||||
const intervalId = setInterval(function() {
|
||||
const now = Date.now()
|
||||
const offset = now - previous - interval
|
||||
if (offset > logThreshold) {
|
||||
logger.warn({ offset }, 'slow event loop')
|
||||
}
|
||||
previous = now
|
||||
return Metrics.timing('event-loop-millsec', offset)
|
||||
}, interval)
|
||||
|
||||
return Metrics.registerDestructor(() => clearInterval(intervalId))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user