How to use sleep - 10 common examples

To help you get started, we’ve selected a few sleep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AlejandroEsquivel / Node-Pastebin-Scraper / scraper.js View on Github external
var search = (body ? (match(body)): false);
              if(search){
                console.log('Found '+keyword);
                $ = cheerio.load(body); // html of paste page
                raw = $('#paste_code').eq(0).html(); // raw paste content
                console.log('pastebin.com'+response.request.url.pathname); // url of paste

              }
              return false;
            });
          }
          else {
            console.log("Skipped URL: "+url);
          }
        }
        sleep.sleep(frequency.wait);
      }
    });
};
github ThemisB / diavgeiaRedefined / bitcoin-validator / index.js View on Github external
async.mapLimit(commits, 1, async function (commit) {
      const response = await requestChainSo(commit.txId, commit.txIndex)
      require('sleep').sleep(10) // do not overload chain.so
      return response
    }, (err, blockchainResults) => {
      // We have gathered all the data from the api
github bambenek / bitcoin_tracker / tracker.js View on Github external
function checkVariable() {

  if (current_total == true && current_sent == true && current_rec == true) {
     return;
  } else {
// Just in case
     sleep.sleep(1);
  }
}
setTimeout(checkVariable, 1000);
github mattfroese / vue-identity / examples / server.routes.js View on Github external
router.get('/login', function(req, res) {
  // Simulate latency
  sleep.sleep(3)
  //pretend this reqeust is valid
  let valid = true
  if( valid ) {
    res.status(200).send({
      token: token('vue'),
      refresh: token('vue')
    })
  }
})
github nufyoot / createsend-node / integration / workflow1.js View on Github external
}, function (err, subscriber) {
            should.not.exist(err);
            should.exist(subscriber);
            should.exist(subscriber.getDetails);
            testSubscriber = subscriber;
            // This timeout is necessary.  CM adds subscribers async so we need to wait from them to catch up.
            isIntegrationTest && sleep.sleep(2);
            done();
        });
    });
github nufyoot / createsend-node / integration / subscribers.js View on Github external
}, function (err, subscriber) {
            should.not.exist(err);
            should.exist(subscriber);
            should.exist(subscriber.getDetails);
            testSubscriber = subscriber;
            // This timeout is necessary.  CM adds subscribers async so we need to wait from them to catch up.
            isIntegrationTest && sleep.sleep(1);
            done();
        });
    });
github fmiras / micro-cacheable / test / index.js View on Github external
test('cache(...args) execute the handler twice with 3 requests', async t => {
  const handler = sinon.stub()
  handler.onCall(0).returns(1)
  handler.onCall(1).returns(2)

  const microFn = await cache(1000, handler)
  const req = { url: 'https://someapi.com' }

  t.is(1, await microFn(req))
  t.is(1, await microFn(req))
  await sleep(1)
  t.is(2, await microFn(req))
  t.is(2, handler.callCount)
})
github intuition-io / intuition / server / workerNode.js View on Github external
});

    child.on('exit', function (code, signal) {
        if (code === 0) {
            console.log('[Node:worker] Child exited normaly (' + code + ')')
        } else {
            console.log('[Node:worker] Child process terminated with code ' + code + ', signal: ' + signal);
        }
        child.stdin.end();
        child = undefined;
        frontSocket.send([channel, JSON.stringify({'time': new Date(), 'type': 'acknowledgment', 'msg': code})]);
    });

    console.log(process.pid + ' - ' + process.title + ': Spawned child pid: ' + child.pid);
    console.log('[Node:worker] Running worker: ' + script)
    require('sleep').sleep(5);
        
    if ('configuration' in parameters) {
        console.log('[Node:worker] Sending configuration to worker...');
        backSocket.send(JSON.stringify(parameters.configuration))
        //backSocket.send(JSON.stringify({algorithm: parameters.algorithm, manager: parameters.manager, done:true}))
    }

    process.on("SIGTERM", function() {
        console.log("[Node:worker] Parent SIGTERM detected");
        backSocket.close();
        process.exit();
    });

    process.on("SIGINT", function() {
        console.log("[Node:worker] Signal SIGINT detected");
        backSocket.close();
github ArkEcosystem / core / commander / commands / start-relay / index.js View on Github external
}, () => {
    console.log(chalk.green('The relay node has been started.'))

    sleep(1)

    onCancel()
  })
}
github ArkEcosystem / core / packages / ark-core / commander / commands / stop-relay-and-forger.js View on Github external
stopProcess('ark-core:relay-and-forger', () => {
    console.log(chalk.bgRed('The relay node and forger have been stopped.'))

    sleep(1)

    onCancel()
  })
}

sleep

Add sleep() and usleep() to nodejs

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis

Popular sleep functions