Skip to content

Commit

Permalink
perf: use optional chaining (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Jan 7, 2025
1 parent 6a2c669 commit d09e531
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Boot.prototype._loadPlugin = function (plugin, callback) {
return
}

let server = (last && last.server) || instance._server
let server = last?.server || instance._server

if (!plugin.isAfter) {
// Skip override for after
Expand Down Expand Up @@ -547,7 +547,7 @@ function encapsulateTwoParam (func, that) {
let res
if (func.length === 0) {
res = func()
if (res && res.then) {
if (res?.then) {
res.then(function () {
process.nextTick(cb)
}, cb)
Expand All @@ -557,7 +557,7 @@ function encapsulateTwoParam (func, that) {
} else if (func.length === 1) {
res = func(this)

if (res && res.then) {
if (res?.then) {
res.then(function () {
process.nextTick(cb)
}, cb)
Expand All @@ -580,7 +580,7 @@ function encapsulateThreeParam (func, that) {
process.nextTick(cb)
} else if (func.length === 0) {
res = func()
if (res && res.then) {
if (res?.then) {
res.then(function () {
process.nextTick(cb, err)
}, cb)
Expand All @@ -589,7 +589,7 @@ function encapsulateThreeParam (func, that) {
}
} else if (func.length === 1) {
res = func(err)
if (res && res.then) {
if (res?.then) {
res.then(function () {
process.nextTick(cb)
}, cb)
Expand Down
4 changes: 2 additions & 2 deletions lib/get-plugin-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const { kPluginMeta } = require('./symbols')
*/
function getPluginName (plugin, options) {
// use explicit function metadata if set
if (plugin[kPluginMeta] && plugin[kPluginMeta].name) {
if (plugin[kPluginMeta]?.name) {
return plugin[kPluginMeta].name
}

// use explicit name option if set
if (options && options.name) {
if (options?.name) {
return options.name
}

Expand Down

0 comments on commit d09e531

Please sign in to comment.