# inflight

> Add callbacks to requests in flight to avoid async duplication

Latest version **1.0.6** (published 2016-10-13) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2016-10-13 |
| First published | 2014-05-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/inflight) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 76 |
| Author | Isaac Z. Schlueter |
| Maintainers | iarna, isaacs, othiym23, zkat |

## Links

- npm: https://www.npmjs.com/package/inflight
- Repository: https://github.com/npm/inflight
- Homepage: https://github.com/isaacs/inflight
- Issues: https://github.com/isaacs/inflight/issues
- npm.io page: https://npm.io/package/inflight

## Dependencies (2)

- [once](https://npm.io/package/once.md) ^1.3.0
- [wrappy](https://npm.io/package/wrappy.md) 1

## Recent versions

- 1.0.6 (latest) — 2016-10-13
- 1.0.5 — 2016-05-18
- 1.0.4 — 2014-10-03
- 1.0.3 — 2014-10-01
- 1.0.2 — 2014-09-18
- 1.0.1 — 2014-05-05
- 1.0.0 — 2014-05-05

## README

# inflight

Add callbacks to requests in flight to avoid async duplication

## USAGE

```javascript
var inflight = require('inflight')

// some request that does some stuff
function req(key, callback) {
  // key is any random string.  like a url or filename or whatever.
  //
  // will return either a falsey value, indicating that the
  // request for this key is already in flight, or a new callback
  // which when called will call all callbacks passed to inflightk
  // with the same key
  callback = inflight(key, callback)

  // If we got a falsey value back, then there's already a req going
  if (!callback) return

  // this is where you'd fetch the url or whatever
  // callback is also once()-ified, so it can safely be assigned
  // to multiple events etc.  First call wins.
  setTimeout(function() {
    callback(null, key)
  }, 100)
}

// only assigns a single setTimeout
// when it dings, all cbs get called
req('foo', cb1)
req('foo', cb2)
req('foo', cb3)
req('foo', cb4)
```

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