Skip to content

Small wrappers for setTimeout and setInterval which return methods to cancel them.

License

Notifications You must be signed in to change notification settings

chrisinajar/thyming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thyming

Small wrappers for setTimeout and setInterval which return methods to cancel them.

Install

npm install thyming

Usage

// same with require('thyming').timeout;
var interval = require('thyming').interval;

var stop = interval(function () {
  // do something later!
});

/* ... */
// cancel the timer
stop();

API

thyming.timeout(fn, ms) -> function

Returns a method to cancel the timer.

fn

Required
Type: function

The method to pass in to setTimeout, will be run after ms milliseconds.

ms

Type: number

The number of milliseconds to wait before executing fn.

thyming.interval(fn, ms) -> function

Returns a method to cancel the timer.

fn

Required
Type: function

The method to pass in to setInterval, will be run every ms milliseconds.

ms

Type: number

The number of milliseconds to wait between executing fn.

License

MIT

About

Small wrappers for setTimeout and setInterval which return methods to cancel them.

Resources

License

Stars

Watchers

Forks

Packages

No packages published