How to create a sleep/delay in nodejs that is Blocking?

后端 未结 12 644
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 07:00

I\'m currently trying to learn nodejs and a small project I\'m working is writing an API to control some networked LED lights.

The microprocessor controlling the LED

12条回答
  •  一整个雨季
    2020-12-02 07:23

    use Node sleep package. https://www.npmjs.com/package/sleep.

    in your code you can use

    var sleep = require('sleep'); 
    sleep.sleep(n)
    

    to sleep for a specific n seconds.

提交回复
热议问题