-
Notifications
You must be signed in to change notification settings - Fork 15
Implement getWorkAdult #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f9e6471
6093f89
f9bb38e
c77fcca
18eb2e2
388238a
1404884
cadee7d
006ae21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,11 @@ export const getWorkLocked = ($workPage: WorkPage) => { | |
return !!$workPage("#signin > .heading").text(); | ||
}; | ||
|
||
export const getWorkAdult = ($workPage: WorkPage): boolean => { | ||
const adultCategories: WorkRatings[] = [WorkRatings.EXPLICIT, WorkRatings.MATURE, WorkRatings.NOT_RATED]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I just found out about this: https://mkosir.github.io/typescript-style-guide/#type-safe-constants-with-satisfies Apparently the best way of declaring this constant would be: const ADULT_CATEGORIES = [
WorkRatings.EXPLICIT,
WorkRatings.MATURE,
WorkRatings.NOT_RATED
] as const satisfies ReadonlyArray<WorkRatings>; this would give the most correct typing (feel free to ask if you want to understand more). I'd be ok with keeping it |
||
return adultCategories.includes(getWorkRating($workPage)); | ||
} | ||
|
||
// Chapter-specific (must be multi-chapter fic) | ||
export const getChapterIndex = ( | ||
$workPage: WorkPage | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a constant, we should define it outside this function like this:
see https://google.github.io/styleguide/tsguide.html#identifiers-constants (but it's a common convention)