sleep-dots
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

sleep-dots 💤

A light Node.js utility (549 bytes gzipped) for pausing the program execution for a specified amount of time and displaying a message with moving dots.

Installation 💻

You can install the sleep-dots package using npm:

npm install sleep-dots

Configuration 🔧

The sleepWithLog function displays the custom message along with the formatted remaining time in a loop until the specified time has elapsed.

It takes an object with three optional parameters:

  • customMessage: The custom message to display. The default value is 'Waiting for'.
  • finalBreakLine: Add a break line (\n) at the end of the output. The default value is true.
  • stepTime: The time to wait between dots updates in milliseconds. The default value is 500 (0.5 seconds).
  • totalTime: The total time to sleep in milliseconds. The default value is 3000 (3 seconds).

Example Usage 🚀

import sleepWithLog from 'sleep-dots'
// or
const sleepWithLog = require('sleep-dots')

async function main() {
  console.log('Start sleeping...')
  await sleepWithLog({
    customMessage: 'Waiting for data',
    finalBreakLine: false,
    stepTime: 1000,
    totalTime: 5000,
  })
  console.log('Wake up!')
}

main()

The above example will output the following to the console:

Package Sidebar

Install

npm i sleep-dots

Weekly Downloads

4

Version

1.1.2

License

MIT

Unpacked Size

6.06 kB

Total Files

8

Last publish

Collaborators

  • fentosv