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[] = [];
|
let patchHrefs: string[] = [];
|
||||||
|
|
||||||
for (let i = 0; i <= 7; i++) {
|
[...Array(7).keys()]
|
||||||
const req = await fetch(getGalleryPageHref(i));
|
.map((val) => ++val)
|
||||||
|
.map(async (page) => {
|
||||||
|
const req = await fetch(getGalleryPageHref(page));
|
||||||
const data = parse(await req.text());
|
const data = parse(await req.text());
|
||||||
|
|
||||||
const gallery = data
|
const gallery = data
|
||||||
|
@ -23,15 +25,11 @@ async function getPatchHrefs() {
|
||||||
.filter((el) => el.classList.contains("hds-gallery-items"))
|
.filter((el) => el.classList.contains("hds-gallery-items"))
|
||||||
.shift();
|
.shift();
|
||||||
|
|
||||||
const links = gallery
|
return gallery
|
||||||
?.getElementsByTagName("a")
|
?.getElementsByTagName("a")
|
||||||
.map((el) => el.getAttribute("href"))
|
.map((el) => el.getAttribute("href"))
|
||||||
.filter((el) => el) as string[];
|
.filter((el) => el) as string[];
|
||||||
|
});
|
||||||
patchHrefs.push.apply(patchHrefs, links);
|
|
||||||
}
|
|
||||||
|
|
||||||
return patchHrefs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const allPatches = await getPatchHrefs();
|
const allPatches = await getPatchHrefs();
|
||||||
|
|
Loading…
Reference in a new issue