Skip to content

Commit 848f355

Browse files
committed
compact npmjs.com script
1 parent 7a4c3a4 commit 848f355

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

npmjs.com/index.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,16 @@ const listItem = (text, href) => {
1414

1515
if (repos) {
1616
const pkg = document.querySelector("#top h1 span").textContent;
17-
list.append(
18-
listItem("Bundlephobia", `https://bundlephobia.com/package/${pkg}`),
19-
);
20-
21-
list.append(
22-
listItem("npm-stat", `https://npm-stat.com/charts.html?package=${pkg}`),
23-
);
24-
25-
list.append(
26-
listItem("Packagephobia", `https://packagephobia.com/result?p=${pkg}`),
27-
);
28-
29-
list.append(
30-
listItem("pkg-size.dev", `https://pkg-size.dev/${pkg}`)
31-
);
17+
const sites = [
18+
["Bundlephobia", `https://bundlephobia.com/package/${pkg}`],
19+
["npm-stat", `https://npm-stat.com/charts.html?package=${pkg}`],
20+
["Packagephobia", `https://packagephobia.com/result?p=${pkg}`],
21+
["pkg-size.dev", `https://pkg-size.dev/${pkg}`],
22+
];
23+
24+
for (const [label, site] of sites) {
25+
list.append(listItem(label, site));
26+
}
3227

3328
repos.parentNode.append(list);
3429
}

0 commit comments

Comments
 (0)