@chargedcloud/promise-sleep

1.2.1 • Public • Published

@chargedcloud/promise-sleep

The promise-sleep package is a simple function who returns a promise that resolves after a certain amount of time.

InstallationUsage

Installation

You can install the package using npm:

npm install @chargedcloud/promise-sleep

Usage

First, you need to import the package:

// CommonJS
const sleep = require("@chargedcloud/promise-sleep");

// ES6
import sleep from "@chargedcloud/promise-sleep";

Then, you can use the function passing the amount of time in milliseconds:

// Sleep for 1 second
await sleep(1000);

// Sleep for 1 second and then log "Hello, world!"
await sleep(1000).then(() => console.log("Hello, world!"));

Package Sidebar

Install

npm i @chargedcloud/promise-sleep

Weekly Downloads

102

Version

1.2.1

License

ISC

Unpacked Size

2.89 kB

Total Files

6

Last publish

Collaborators

  • igorpdasilvaa