timeout-async
v1.0.0
Published
Provides the option to call a callback function with default arguments if an async function takes too long.
Downloads
8
Readme
timeout-async
Javascript library that provides the option to call a callback function with default arguments if an async function takes too long.
Import the library
var ta = require('timeout-async')
Arguments
- function - async function that should be called
- number - amount time that should elapse before the callback function is called with default arguments
- array - default arguments for the callback function
- array - arguments to the async function (including the callback function)
Example
var ta = require('timeout-async')
var request = require('request')
ta(request.get, 5000, ['default-err', 'default-response', 'default-body'], [{url: 'http://my-ip.herokuapp.com'}, function(err, response, body) {
console.log(err, response, body)
}])