Skip to content

Commit 6686bb8

Browse files
authored
perf: 2x faster hash stringify
1 parent 4930de7 commit 6686bb8

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,8 @@ function getcookie(req, name, secrets) {
603603

604604
function hash(sess) {
605605
// serialize
606-
var str = JSON.stringify(sess, function (key, val) {
607-
// ignore sess.cookie property
608-
if (this === sess && key === 'cookie') {
609-
return
610-
}
611-
612-
return val
613-
})
606+
const { cookie, ...sessWithoutCookie } = sess;
607+
const str = JSON.stringify(sessWithoutCookie);
614608

615609
// hash
616610
return crypto

0 commit comments

Comments
 (0)