# singleflight

> A wrapper for de-duplicating asynchronous requests

Latest version **0.0.1** (published 2016-08-05) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2016-08-05 |
| First published | 2016-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Noah Adams |
| Maintainers | nba |

## Links

- npm: https://www.npmjs.com/package/singleflight
- Repository: https://github.com/noahadams/singleflight
- Homepage: https://github.com/noahadams/singleflight#readme
- Issues: https://github.com/noahadams/singleflight/issues
- npm.io page: https://npm.io/package/singleflight

## Recent versions

- 0.0.1 (latest) — 2016-08-05

## README

# Singleflight

## A wrapper for de-duplicating in-flight requests

Singleflight allows you to simply wrap asynchronous functions of the form
`function(key, callback)` where key is a single string argument and callback
can be a function of any signature.

### Usage

```javascript
var singleflight = require('singleflight');
var request = require('request');

var wrappedget = singleflight(request.get);

wrappedget('https://www.example.com/cool.jpg', function(error, response) {
  ...
});
wrappedget('https://www.example.com/cool.jpg', function(error, response) {
  ...
});
```

will result in only one call to fetch `https://www.example.com/cool.jpg`.

Useful applications include re-validation and re-population of caches, and any
other de-duplication of longish running asynchronous tasks. Combines well with
other async flow control tools like Promises and the
[async](https://github.com/caolan/async) and
[vasync](https://github.com/davepacheco/node-vasync) libraries.

### Testing
`npm test`

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