decaf cleanup: rewrite code to no longer use __guard__

GitOrigin-RevId: 591dbefe98423ead89505250c4f46c8ad2610305
This commit is contained in:
Tim Alby 2022-01-07 11:36:03 +01:00 committed by Copybot
parent 291f28a655
commit ea8e0af551

View file

@ -1,8 +1,3 @@
/*
* decaffeinate suggestions:
* DS103: Rewrite code to no longer use __guard__
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const logger = require('@overleaf/logger')
const settings = require('@overleaf/settings')
@ -11,16 +6,8 @@ const Server = require('./app/js/server')
if (!module.parent) {
// Called directly
const port =
__guard__(
settings.internal != null ? settings.internal.chat : undefined,
x => x.port
) || 3010
const host =
__guard__(
settings.internal != null ? settings.internal.chat : undefined,
x1 => x1.host
) || 'localhost'
const port = settings.internal.chat.port
const host = settings.internal.chat.host
mongodb
.waitForDb()
.then(() => {
@ -39,9 +26,3 @@ if (!module.parent) {
}
module.exports = Server.server
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}