refactor: ♻️ isNan -> Number.isNan
This commit is contained in:
parent
34ce779309
commit
a6f0143017
4 changed files with 9 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
))
|
||||
);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue