A lightweight utility function that pauses execution for a specified duration using promises. This simple sleep function can be used to add delays in asynchronous JavaScript code.
- Pauses execution for the specified number of milliseconds.
- Leverages promises for seamless integration with async/await syntax
- Includes error handling for invalid input to ensure robustness.
Inspiration for this package comes from personal usage of Python's time sleep function.
To use this function in your project, copy the code into your desired file or add it as a custom module.
npm install js-sleep-ms
const sleep = require("js-sleep-ms")