@tbhaxor/node-sleep
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Nodejs Sleep Unit Testing

As we all know that nodejs is a single threaded async language and you need to have async wrapper to execute your own sleep function. But sometimes it is required to have a synchronous sleep to make things simple and easy to understand.

This package use foreign function interface technique to call sleep and usleep functions from libc.so library.

NOTE Libc is guaranteed in macOS and Linux operating systems but not in windows. Therefore windows is not supported yet

Read More:

Installation

npm i @tbhaxor/node-sleep

yarn add @tbhaxor/node-sleep

Usage

// es6
import { sleep, usleep } from "@tbhaxor/node-sleep";

// commonjs
const { sleep, usleep } = require("@tbhaxor/node-sleep");

sleep(3); // sleep for 3 seconds
usleep(1000); // sleep for 1000 micro seconds

Licence

The project is licened under MIT License

Package Sidebar

Install

npm i @tbhaxor/node-sleep

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

14 kB

Total Files

10

Last publish

Collaborators

  • tbhaxor