functional programming
This commit is contained in:
parent
4b9311c61f
commit
f9a5d5cdac
1 changed files with 14 additions and 16 deletions
14
index.ts
14
index.ts
|
@ -14,8 +14,10 @@ async function getPatchHrefs() {
|
|||
|
||||
let patchHrefs: string[] = [];
|
||||
|
||||
for (let i = 0; i <= 7; i++) {
|
||||
const req = await fetch(getGalleryPageHref(i));
|
||||
[...Array(7).keys()]
|
||||
.map((val) => ++val)
|
||||
.map(async (page) => {
|
||||
const req = await fetch(getGalleryPageHref(page));
|
||||
const data = parse(await req.text());
|
||||
|
||||
const gallery = data
|
||||
|
@ -23,15 +25,11 @@ async function getPatchHrefs() {
|
|||
.filter((el) => el.classList.contains("hds-gallery-items"))
|
||||
.shift();
|
||||
|
||||
const links = gallery
|
||||
return gallery
|
||||
?.getElementsByTagName("a")
|
||||
.map((el) => el.getAttribute("href"))
|
||||
.filter((el) => el) as string[];
|
||||
|
||||
patchHrefs.push.apply(patchHrefs, links);
|
||||
}
|
||||
|
||||
return patchHrefs;
|
||||
});
|
||||
}
|
||||
|
||||
const allPatches = await getPatchHrefs();
|
||||
|
|
Loading…
Reference in a new issue