From a6f0143017c3205fc215100711b2a9df77eb207e Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 4 Dec 2023 22:36:57 -0800 Subject: [PATCH] refactor: :recycle: isNan -> Number.isNan --- packages/backend/src/db/meilisearch.ts | 2 +- packages/backend/src/server/web/index.ts | 10 +++++----- packages/backend/src/services/note/create.ts | 4 ++-- packages/client/src/components/mfm.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/db/meilisearch.ts b/packages/backend/src/db/meilisearch.ts index a98c3e80ce..6762986284 100644 --- a/packages/backend/src/db/meilisearch.ts +++ b/packages/backend/src/db/meilisearch.ts @@ -154,7 +154,7 @@ function timestampToUnix(timestamp: string) { if (unix === 0) { // Try to parse the timestamp as JavaScript Date const date = Date.parse(timestamp); - if (isNaN(date)) return 0; + if (Number.isNaN(date)) return 0; unix = date / 1000; } diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index d3c751acc6..12119ef3c3 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -301,12 +301,12 @@ const getFeed = async ( return; } let thread = parseInt(threadDepth, 10); - if (isNaN(thread) || thread < 0 || thread > 30) { + if (Number.isNaN(thread) || thread < 0 || thread > 30) { thread = 3; } let history = parseInt(historyCount, 10); //cant be 0 here or it will get all posts - if (isNaN(history) || history <= 0 || history > 30) { + if (Number.isNaN(history) || history <= 0 || history > 30) { history = 20; } return ( @@ -315,9 +315,9 @@ const getFeed = async ( user, thread, history, - !isNaN(noteInTitle), - isNaN(noRenotes), - isNaN(noReplies), + !Number.isNaN(noteInTitle), + Number.isNaN(noRenotes), + Number.isNaN(noReplies), )) ); }; diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 1e57d20f00..ed6ab932c1 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -201,7 +201,7 @@ export default async ( const now = new Date(); if ( !data.createdAt || - isNaN(data.createdAt.getTime()) || + Number.isNaN(data.createdAt.getTime()) || data.createdAt > now ) data.createdAt = now; @@ -782,7 +782,7 @@ async function insertNote( await transactionalEntityManager.insert(Note, insert); let expiresAt: Date | null; - if (!data.poll.expiresAt || isNaN(data.poll.expiresAt.getTime())) { + if (!data.poll.expiresAt || Number.isNaN(data.poll.expiresAt.getTime())) { expiresAt = null; } else { expiresAt = data.poll.expiresAt; diff --git a/packages/client/src/components/mfm.ts b/packages/client/src/components/mfm.ts index 5dbf710118..8de385c40f 100644 --- a/packages/client/src/components/mfm.ts +++ b/packages/client/src/components/mfm.ts @@ -61,7 +61,7 @@ export default defineComponent({ const validNumber = (n: string | null | undefined) => { if (n == null) return null; const parsed = parseFloat(n); - return !isNaN(parsed) && isFinite(parsed) && parsed > 0; + return !Number.isNaN(parsed) && Number.isFinite(parsed) && parsed > 0; }; // const validEase = (e: string | null | undefined) => { // if (e == null) return null;