Skip to content

Commit 75bfc4f

Browse files
committed
refactor: Use helpers in API methods
1 parent 483f3e6 commit 75bfc4f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/api/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { VaultError } from "@/errors";
2+
import { isNull, isUndefined } from "@/helpers";
23
import indexPageByDaysTemplate from "@/templates/indexPageByDays.hbs";
34
import indexPageByLanguagesTemplate from "@/templates/indexPageByLanguages.hbs";
45
import indexPageByOwnersTemplate from "@/templates/indexPageByOwners.hbs";
@@ -98,7 +99,7 @@ export class GithubStarsPluginApi {
9899
}
99100

100101
const starredCount = Stream.of(repos)
101-
.filter((r) => typeof r.unstarredAt === "undefined")
102+
.filter((r) => isUndefined(r.unstarredAt) || isNull(r.unstarredAt))
102103
.toCount();
103104
const unstarredCount = Stream.of(repos)
104105
.filter((r) => !!r.unstarredAt)
@@ -150,7 +151,7 @@ export class GithubStarsPluginApi {
150151
.groupBy((r) => r.mainLanguage)
151152
.sort();
152153
const starredCount = Stream.of(repos)
153-
.filter((r) => typeof r.unstarredAt === "undefined")
154+
.filter((r) => isUndefined(r.unstarredAt) || isNull(r.unstarredAt))
154155
.toCount();
155156
const unstarredCount = Stream.of(repos)
156157
.filter((r) => !!r.unstarredAt)
@@ -221,7 +222,7 @@ export class GithubStarsPluginApi {
221222
.groupBy((r) => r.owner.login)
222223
.sort();
223224
const starredCount = Stream.of(repos)
224-
.filter((r) => typeof r.unstarredAt === "undefined")
225+
.filter((r) => isUndefined(r.unstarredAt) || isNull(r.unstarredAt))
225226
.toCount();
226227
const unstarredCount = Stream.of(repos)
227228
.filter((r) => !!r.unstarredAt)

0 commit comments

Comments
 (0)