diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -237,6 +237,7 @@ Some functions are also available in the following forms: * [`log`](#log) * [`dir`](#dir) * [`noConflict`](#noConflict) +* [`timeout`](#timeout) ## Collections @@ -1903,3 +1904,25 @@ node> async.dir(hello, 'world'); Changes the value of `async` back to its original value, returning a reference to the `async` object. + +--------------------------------------- + +<a name="timeout"></a> +### timeout(function, miliseconds) + +Sets a time limit on an asynchronous function. If the function does not call its callback within the specified miliseconds, it will be called with a timeout error. The code property for the error object will be `'ETIMEDOUT'`. + +Returns a wrapped function that can be used with any of the control flow functions. + +__Arguments__ + +* `function` - The asynchronous function you want to set the time limit. +* `miliseconds` - The specified time limit. + +__Example__ + +```js +async.timeout(function(callback) { + doAsyncTask(callback); +}, 1000); +``` |