“in Nodejs schlafen?” Code-Antworten

Knotenschlaf

// one liner
await new Promise(resolve => setTimeout(resolve, 5000));

// or re-usable `sleep` function:
async function init() {
  console.log(1);
  await sleep(1000);
  console.log(2);
}

function sleep(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
}
just-saved-you-a-stackoverflow-visit

in Nodejs schlafen?

await sleep(1000)
function sleep(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
} 
Outstanding Oystercatcher

Knotenschlaf

await sleep(1000)
const sleep = (ms: number) => {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
} 
Stormy Sloth

Ähnliche Antworten wie “in Nodejs schlafen?”

Fragen ähnlich wie “in Nodejs schlafen?”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen