From 33265e9f5762e64e871c988167f0d59ef41cb6d4 Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Fri, 1 Nov 2024 02:52:04 +0100 Subject: [PATCH] Refactor signedCookies function for improved readability - Replaced Object.keys() with Object.entries() for cleaner iteration over key-value pairs. - Used destructuring in the loop to enhance code clarity. - Maintained functionality of decoding signed cookies while removing them from the original object. --- index.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index dd6d479..358c8f9 100644 --- a/index.js +++ b/index.js @@ -161,16 +161,10 @@ function signedCookie (str, secret) { */ function signedCookies (obj, secret) { - var cookies = Object.keys(obj) - var dec - var key - var ret = Object.create(null) - var val + const ret = Object.create(null) - for (var i = 0; i < cookies.length; i++) { - key = cookies[i] - val = obj[key] - dec = signedCookie(val, secret) + for (const [key, val] of Object.entries(obj)) { + const dec = signedCookie(val, secret) if (val !== dec) { ret[key] = dec