• Stars
    star
    454
  • Rank 96,373 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 13 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Add sleep() and usleep() to nodejs

Build Status Build status FOSSA Status

sleep

Add sleep(), msleep() and usleep() to Node.js, via a C++ binding.

This is mainly useful for debugging.

Note that because this is a C++ module, it will need to be built on the system you are going to use it on.

These calls will block execution of all JavaScript by halting Node.js' event loop!

Alternative

When using nodejs 9.3 or higher it's better to use Atomics.wait which doesn't require compiling this C++ module. The sleep and msleep functions can be implemented like this:

function msleep(n) {
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n);
}
function sleep(n) {
  msleep(n*1000);
}

If you require usleep this module is still required.

Usage

var sleep = require('sleep');
  • sleep.sleep(n): sleep for n seconds
  • sleep.msleep(n): sleep for n miliseconds
  • sleep.usleep(n): sleep for n microseconds (1 second is 1000000 microseconds)

License

FOSSA Status

More Repositories

1

phpRedisAdmin

Simple web interface to manage Redis databases.
PHP
3,106
star
2

redis-lua-scaling-bloom-filter

LUA Redis scripts for a scaling bloom filter
JavaScript
310
star
3

gspt

setproctitle() for Go
C
107
star
4

brainfuck-jit

Brainfuck JIT
C
45
star
5

php-net-tools

A collection of network tools written in PHP
PHP
27
star
6

libuv-lua-http-server

Simple example webserver using libuv and lua
C
21
star
7

nodeFacebookExample

Sample Facebook application using nodejs and socket.io
JavaScript
21
star
8

ringqueue

Queue for Go implemented as ring buffer
Go
18
star
9

MooComplete

Add autocomplete functionality to input elements
JavaScript
15
star
10

OS-Tutorial

Use GRUB to boot a small operating system running in paged virtual memory.
C
14
star
11

php-repl

Simple php repl with tab completion of functions, variables, class functions, class variables and class constants.
PHP
12
star
12

poki-pixijs-template

Quick and dirty template to help developers swiftly build hypercasual PixiJS games.
JavaScript
11
star
13

discnt

Discnt provides in memory distributed eventually consistent counters.
C
9
star
14

villagebuilder

https://playcanvas.com/project/879310/overview/village-builder
JavaScript
8
star
15

udp-tcp-speed-test

Several implementation of a UDP ping pong speed test.
Python
6
star
16

socketIOFileUpload

Upload files using socket.io
JavaScript
6
star
17

libphonenumberphp

libphonenumber php binding
C++
6
star
18

node-eio-simple

Control libeio from javascript
C++
4
star
19

ip2country

IP to country module for PHP
C
4
star
20

malloc-tools

Shared objects that can be used to debug memory allocations
C
4
star
21

http-digest-auth

Nodejs package to perform http digest authentication
JavaScript
3
star
22

erik-misc-code

Miscellaneous code/experiments that by themselves aren't big enough for their own repository.
C
3
star
23

bpprof

Improved version of net/http/pprof
Go
3
star
24

talks

Go
3
star
25

c-pack

Simple data packing/unpacking in C
C
3
star
26

hench

Http bENCHmarking tool
Go
2
star
27

ngx_http_no_server_module

Simple module to stip the Server header from nginx responses
C
2
star
28

cv

My resume. I'm looking for a job!
TeX
1
star
29

qtos

Go
1
star
30

node-pack

Simple data packing/unpacking in NodeJS
JavaScript
1
star
31

LaravelMysqlQueue

Mysql backend for Laravel job queue
PHP
1
star
32

blog.dubbelboer.com

HTML
1
star
33

json-iterator-benchmark

Benchmarking json-iterator vs easyjson
Go
1
star