Skip to content

micro-js/sleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sleep

Build status Git tag NPM version Code style

Sleep for n milliseconds

Installation

$ npm install @f/sleep

Usage

This is particularly useful when programming with generators, e.g.

var sleep = require('@f/sleep')

function * pollThing () {
  while (!thingIsReady()) {
    yield sleep(100)
  }
}

API

sleep(timeInMs)

  • timeInMs - The time in milliseconds you want to sleep for

Returns: A promise that resolves in timeInMs milliseconds.

License

MIT