1.1.2 • Published 1 year ago

sleep-dots v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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:

npm.io