From 4bf28d3e70ca16aee077534582a0ce4980b32abe Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Fri, 19 Jul 2024 09:56:21 +0100 Subject: [PATCH] perf: use spread over object.assign (#185) * perf: use spread over object.assign * chore: fix linting * Update verify-bearer-auth-factory.js Co-authored-by: Aras Abbasi Signed-off-by: Frazer Smith --------- Signed-off-by: Frazer Smith Co-authored-by: Aras Abbasi --- index.js | 2 +- lib/verify-bearer-auth-factory.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a633912..25ab65e 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const verifyBearerAuthFactory = require('./lib/verify-bearer-auth-factory') const { FST_BEARER_AUTH_INVALID_LOG_LEVEL } = require('./lib/errors') function fastifyBearerAuth (fastify, options, done) { - options = Object.assign({ addHook: true, verifyErrorLogLevel: 'error' }, options) + options = { addHook: true, verifyErrorLogLevel: 'error', ...options } if ( Object.prototype.hasOwnProperty.call(fastify.log, 'error') === false || diff --git a/lib/verify-bearer-auth-factory.js b/lib/verify-bearer-auth-factory.js index aa17167..a9214c5 100644 --- a/lib/verify-bearer-auth-factory.js +++ b/lib/verify-bearer-auth-factory.js @@ -26,7 +26,7 @@ const defaultOptions = { } module.exports = function verifyBearerAuthFactory (options, done) { - const _options = Object.assign({}, defaultOptions, options) + const _options = { ...defaultOptions, ...options } if (_options.keys instanceof Set) { _options.keys = Array.from(_options.keys) } else if (Array.isArray(_options.keys)) {