New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wait-a-bit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wait-a-bit

An Event emitter based timer with argument returns

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-77.78%
Maintainers
1
Weekly downloads
 
Created
Source

Wait-a-bit

An Event Emitter based timer with return arguments

Install

npm install wait-a-bit -save

Usage Example

var  waitABit  	=  require('wait-a-bit');
var  timer  	=  new waitABit();

timer.set(2000); //milliseconds

timer.on('expire',function(returnArguments){
    console.log('Ended', returnArguments);
    //anything passed into timer.start() will be called back here;
});
var  sendObject  = {hello:  'world',this:  'is-me'}
timer.start(sendObject);
//if you want to stop a timer once started use the timer.clear() method.

API

Constructor

var timer = new waitABit();

Set [milliseconds]

Takes milliseconds as an argument, does not initiate the timer; timer.set(milliseconds);

Start [any number of arguments]

Takes any number of arguments and passes it back via the 'expired' event after the milliseconds of SET has expired.

timer.start([object],[string],[int],[array]);

Clear

Resets the timer and does not emit the 'expired' event

timer.clear();

Events

Start Event

You can listen for the start event if you need to know exactly when the timer started counting down;

timer.on('start',function(){
    console.log('timer started')
});
Clear Event

You can listen for the clear event if you need to execute code after a timer has been cleared.

timer.on('clear',function(){
    console.log('timer cleared')
});
Expired Event

You cal listen for the end event if you need to execute code after a timer has expired.

timer.on('expired',function(args){
    console.log('timer expired with arguments returned:',args);
});

FAQs

Package last updated on 11 Sep 2018

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