# hurryup

> hurryUp.js ==========

Latest version **0.0.8** (published 2015-04-10) · BSD license · 0 weekly downloads

## Install

```sh
npm install hurryup
pnpm add hurryup
yarn add hurryup
bun add hurryup
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2015-04-10 |
| First published | 2013-01-29 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | architectd |

## Links

- npm: https://www.npmjs.com/package/hurryup
- Repository: https://github.com/crcn/hurryUp.js
- Issues: https://github.com/crcn/hurryUp.js/issues
- npm.io page: https://npm.io/package/hurryup

## Dependencies (1)

- [comerr](https://npm.io/package/comerr.md) 0.0.x

## Recent versions

- 0.0.8 (latest) — 2015-04-10
- 0.0.7 — 2014-09-18
- 0.0.6 — 2014-08-31
- 0.0.5 — 2014-06-12
- 0.0.4 — 2014-06-05
- 0.0.2 — 2013-03-12
- 0.0.1 — 2013-02-24
- 0.0.0 — 2013-01-29

## README

[![Build Status](https://travis-ci.org/crcn/hurryUp.js.svg)](https://travis-ci.org/crcn/hurryUp.js)

HurryUp is a timeout library for asynchronous, fault-prone function calls. Basically, it'll timeout an async call if it's been running for too long. You can also specify to re-call async functions until they succeed (see below).

What can you use it for?

- db operations
- api calls
- async jobs


#### hurryUp(asyncCallback, optionsOrTimeout, ...args)

- `asyncCallback` - async function to call
- `optionsOrTimeout` 
  - `object` - options passed
    - `retry` - TRUE if the timedCallback should be re-called if it returns an error
    - `retryTimeout` - timeout between retrying timed callback
    - `timeout` - kill timeout
  - `number` - the timeout before killing the function call
- `...args` - additional arguments to pass to the async callback

```javascript
hurryUp(function(next) {
  
  //this will cause an error
  setTimeout(next, 2000);
}, 1000).call(null, function(err, result) {
  console.error("timeout has occurred!")
})
```

Here's an easier way to wrap around a method:

```javascript
hurryUp(emitter.once, 1000).call(emitter, "connected", function(err, result) {
  
});
```

You can also use hurryup to run a callback multiple times until it succeeds, like so:

```javascript

function isItReady(next) {
  //async stuff here
  next(new Error("no!"));
}

hurryUp(function(next) {
  isItReady(next);
}, { retry: true }).call(null, function(err) {
  console.log(err.message); //no!
});
```

---
_Source: https://npm.io/package/hurryup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
