import { sleep } from "https://deno.land/x/proc@0.21.9/tools/deps/proc.ts";
The sleep
function is used to pause the execution of the program for a specified amount of
time. It returns a Promise that resolves after a set number of milliseconds, effectively causing a
delay in the execution of the subsequent code.
Returns
A Promise that resolves after the specified number of milliseconds. It does not return any value upon resolution.
Example
console.log("Program starts");
await sleep(2000); // Pauses the execution for 2000 milliseconds
console.log("Program resumes after 2 seconds");
In the above example, the program will print "Program starts", then it will pause for 2 seconds, and then it will print "Program resumes after 2 seconds".