Skip to content
/ timing Public
forked from koaxjs/timing

Delay, timeout, and interval effects.

Notifications You must be signed in to change notification settings

floxjs/timing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timing

Build status Git tag NPM version Code style

Delay, timeout, and interval effects. (Included in flox)

Installation

$ npm install @flox/timing

Usage

import {delay, timeout, interval} from '@flox/timing'

function * () {
  yield delay(500)
  // do something later
}

function * () {
  yield timeout(doSomethingLater, 500)
  // do something now
}

function * () {
  let task = yield interval(repeatSomething, 500)
  // do something and then cancel
  yield cancel(task)
}

API

delay(wait)

  • wait - time to block

Returns: delay action

timeout(fn, wait)

  • fn - function to run after wait ms
  • wait - time to wait

Returns: timeout action

interval(fn, wait)

  • fn - function to run on an interval
  • wait - time in between runs

Returns: interval action

License

MIT

About

Delay, timeout, and interval effects.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 86.1%
  • Makefile 13.9%