From e9830c6ba19052d81ef0aeba9d65a1a130f7cf9e Mon Sep 17 00:00:00 2001 From: EdamAmex <121654029+EdamAme-x@users.noreply.github.com> Date: Sun, 3 Nov 2024 07:50:10 +0900 Subject: [PATCH] perf(utils): use `| 0` instead of `Math.floor` (#3605) --- src/utils/cookie.ts | 2 +- src/utils/jwt/jwt.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/cookie.ts b/src/utils/cookie.ts index 5163246d..45797ddf 100644 --- a/src/utils/cookie.ts +++ b/src/utils/cookie.ts @@ -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') { diff --git a/src/utils/jwt/jwt.ts b/src/utils/jwt/jwt.ts index 23ab901d..b470e5b6 100644 --- a/src/utils/jwt/jwt.ts +++ b/src/utils/jwt/jwt.ts @@ -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) }