Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-timers

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-timers

Promise Timers

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
74
increased by2.78%
Maintainers
1
Weekly downloads
 
Created
Source

DEPRECATED (This project has been moved to https://github.com/AlexanderElias/promise-tool)

Promise Timers

A promised library of timers for Node.js and the browser. If you know the WindowTimers and promises you know how to use PromiseTimers.

Install

npm install promise-timers

API

  • PromiseTimers.setTimeout

    • delay The number of milliseconds to wait before calling resolve.
    • ...args Optional arguments to pass when the resolve is executed.
  • PromiseTimers.setInterval

    • delay The number of milliseconds to wait before calling resolve.
    • method A function that repeats on each interval. This function will fire upon each interval unless one of the following returns are implemented.
      • Return Value Actions
        • result Any valid JavaScript error type. Will fire the reject and pass the error.
        • result A boolean that calls resolve if true or reject if false.
        • result Any thing returned besides null, undefined, false, and a valid Error type will resolve with that return value as the first argument.
        • result <Null, Undefined> Both are ignored and will not trigger the resolve or reject.
    • ...args Optional arguments to pass when the resolve is executed.
  • PromiseTimers.setImmediate

    • ...args Optional arguments to pass when the resolve is executed.
  • PromiseTimers.clearTimeout

    • timeout A Timeout object as returned by setInterval().
  • PromiseTimers.clearInterval

    • interval A Interval object as returned by setInterval().
  • PromiseTimers.clearImmediate

    • immediate An Immediate object as returned by setImmediate().

Example

const PromiseTimers = require('promise-timers');
const delay = 500;

PromiseTimers.setTimeout(delay).then(function (args) {
	// this refers to timeout
	console.log(args);
	console.log('timeout done');
});

var i = 0;

function method () {
	// this refers to interval
	if (i > 5) {
		return true;
	} else {
		console.log(i);
		i++;
	}
};

 PromiseTimers.setInterval(delay, method).then(function (args) {
	// this refers to interval
	console.log(args);
	console.log('interval done');
});

PromiseTimers.setImmediate().then(function (args) {
	// this refers to immediate
   console.log(args);
   console.log('immediate done');
});

Keywords

FAQs

Package last updated on 28 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc