eno/fetch.test.tsx
2023-04-20 21:07:26 -04:00

35 lines
782 B
TypeScript

import {Fetch} from "./lib/iso.tsx";
const delay =async(inHandler:()=>void, inDelay:number):Promise<void>=>
{
return new Promise((accept)=>{
setTimeout(()=>{
accept(inHandler());
}, inDelay);
});
};
const queue = [1, 2, 3];
while(queue.length)
{
await(delay(()=>{console.log(queue.pop())}, 1000))
}
console.log("all done!");
/*
let r1, r2, r3;
delay(()=>{r1 = Fetch.Request(`https://catfact.ninja/fact`, undefined, 0.2); console.log(r1); }, 10);
delay(()=>{r2 = Fetch.Request(`https://catfact.ninja/fact`, undefined, 0.2); console.log(r2); }, 20);
delay(()=>{r3 = Fetch.Request(`https://catfact.ninja/fact`, undefined, 0.2); console.log(r3); }, 2000);
await delay(()=>{}, 3000);
console.log(r1);
console.log(r2);
console.log(r3);
*/