diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-03 01:33:53 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-03 01:33:53 +0100 |
commit | d1291f67551c58168af43698a359cb5ddfd266b0 (patch) | |
tree | 55a13ed29fe1915e3f42f1b1b7038dafa2e975a7 /node_modules/async/timeout.js | |
parent | d0a0695fb5d34996850723f7d4b1b59c3df909c2 (diff) |
node_modules
Diffstat (limited to 'node_modules/async/timeout.js')
-rw-r--r-- | node_modules/async/timeout.js | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/node_modules/async/timeout.js b/node_modules/async/timeout.js index a8de4373c..81a5b7ad4 100644 --- a/node_modules/async/timeout.js +++ b/node_modules/async/timeout.js @@ -27,12 +27,31 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) * to timeout Error for more information.. * @returns {Function} Returns a wrapped function that can be used with any of - * the control flow functions. + * the control flow functions. Invoke this function with the same + * parameters as you would `asyncFunc`. * @example * - * async.timeout(function(callback) { - * doAsyncTask(callback); - * }, 1000); + * function myFunction(foo, callback) { + * doAsyncTask(foo, function(err, data) { + * // handle errors + * if (err) return callback(err); + * + * // do some stuff ... + * + * // return processed data + * return callback(null, data); + * }); + * } + * + * var wrapped = async.timeout(myFunction, 1000); + * + * // call `wrapped` as you would `myFunction` + * wrapped({ bar: 'bar' }, function(err, data) { + * // if `myFunction` takes < 1000 ms to execute, `err` + * // and `data` will have their expected values + * + * // else `err` will be an Error with the code 'ETIMEDOUT' + * }); */ function timeout(asyncFn, milliseconds, info) { var originalCallback, timer; |