Skip to content

Commit

Permalink
perf(utils): use | 0 instead of Math.floor (#3605)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdamAme-x authored Nov 2, 2024
1 parent 8d775dc commit e9830c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const _serialize = (name: string, value: string, opt: CookieOptions = {}): strin
'Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.'
)
}
cookie += `; Max-Age=${Math.floor(opt.maxAge)}`
cookie += `; Max-Age=${opt.maxAge | 0}`
}

if (opt.domain && opt.prefix !== 'host') {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/jwt/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const verify = async (
if (!isTokenHeader(header)) {
throw new JwtHeaderInvalid(header)
}
const now = Math.floor(Date.now() / 1000)
const now = (Date.now() / 1000) | 0
if (payload.nbf && payload.nbf > now) {
throw new JwtTokenNotBefore(token)
}
Expand Down

0 comments on commit e9830c6

Please sign in to comment.