-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.test.ts
33 lines (33 loc) · 946 Bytes
/
mod.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ExFetch } from "./mod.ts";
Deno.test("Single 1", {
permissions: {
net: ["jsonplaceholder.typicode.com"]
}
}, async () => {
const response = await new ExFetch().single("https://jsonplaceholder.typicode.com/posts");
console.log(await response.json());
});
Deno.test("URLPaginate 1", {
permissions: {
net: ["api.github.com"]
}
}, async () => {
const responses = await new ExFetch({
paginate: {
onURLPaginate({
countCurrent,
countMaximum,
timeWait,
urlNext
}) {
console.debug(`Fetching #${countCurrent}/${countMaximum} after ${timeWait / 1000} seconds via ${urlNext}.`);
}
}
}).urlPaginate("https://api.github.com/repos/microsoft/vscode/labels?per_page=100");
const result = await Array.fromAsync(responses.map((response) => {
return response.json();
}));
console.log(result);
console.log(`Result Length: ${result.length}`);
console.log(`Result Flat Length: ${result.flat().length}`);
});