Skip to content

Commit 36369f8

Browse files
committed
Create categoriesHandlers.class.js
1 parent 95ba903 commit 36369f8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Array.prototype.isEmpty = (arr) => {
3+
return (arr === undefined || arr.length === 0) ? false : true
4+
}
5+
6+
class Categories {
7+
getCategoriesFlags = array => {
8+
return (!Array.isEmpty(array) ?? false) ? `--only-categories=${lighthouseCategories(array ?? "accessibility")} ` : ""
9+
}
10+
11+
getCurrentCategories = categories => {
12+
return categories ?? ["accessibility", "pwa", "best-practices", "performance", "seo"]
13+
}
14+
15+
lighthouseCategories = (categories = []) => {
16+
return (typeof categories == "string") ? categories : categories.join(',')
17+
}
18+
19+
getCategoriesFromCategoriesFlags = array => {
20+
return (!Array.isEmpty(array)) ? array : undefined
21+
}
22+
}
23+
24+
export const { getCategoriesFlags, lighthouseCategories, getCurrentCategories, getCategoriesFromCategoriesFlags } = new Categories()
25+
export default Categories

0 commit comments

Comments
 (0)