Skip to content

Commit

Permalink
perf(index): use optional chaining (#318)
Browse files Browse the repository at this point in the history
Signed-off-by: Frazer Smith <[email protected]>
  • Loading branch information
Fdawgs authored Jan 7, 2025
1 parent e6b2811 commit 7ba7b7f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function fastifyWebsocket (fastify, opts, next) {
}

let preClose = defaultPreClose
if (opts && opts.preClose) {
if (opts?.preClose) {
if (typeof opts.preClose !== 'function') {
return next(new Error('invalid preClose function'))
}

preClose = opts.preClose
}

if (opts.options && opts.options.noServer) {
if (opts.options?.noServer) {
return next(new Error("fastify-websocket doesn't support the ws noServer option. If you want to create a websocket server detatched from fastify, use the ws library directly."))
}

Expand Down

0 comments on commit 7ba7b7f

Please sign in to comment.