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

deferred-bounce

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deferred-bounce

Deferred call reject function by timeout if resolve function was not called.

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

deferred-bounce Build Status

Call reject-function after expiration of timeout if resolve-function was not called.

Installation

  npm i --save deferred-bounce

Usage

deferredBound(resolveFunction, rejectFunction, scope, delay);

  var db = require('deferred-bounce');
  
  var resolve = function(err, response) {
    if (err) return;
    console.log(response);
  };
  
  var reject = function() {
    console.log('no 2 seconds response');
  };
  
  var deferred = db(resolve, reject, this, 2000);
  
  anyAsyncFunction(deferred);

Arguments

  • resolveFunction - function which will be called if deferred instance will called
  • rejectFunction - function which will be called after expiration of delay and if deferred instance will not called
  • scope - (optional) - bind scope to resolve and reject functions
  • delay - timeout

Examples

  var db = require('deferred-bounce');
  
  var resolve = function() {
    console.log('resolve');
  };
  
  var reject = function() {
    console.log('no 2 seconds response');
  };
  
  var deferred = db(resolve, reject, this, 2000);
  
  deferred();
  // will call resolve function. reject function  will not be called ever
  var db = require('deferred-bounce');
  
  var resolve = function() {
    console.log('resolve');
  };
  
  var reject = function() {
    console.log('no 2 seconds response');
  };
  
  var deferred = db(resolve, reject, this, 2000);
  
  setTimout(function() {
    deferred();
  }, 3000);
  
  // reject function will be called. resolve will not be called ever

License

WTFPL © Dmitry Pavlovsky

Keywords

FAQs

Package last updated on 29 Jul 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