Projekt

Obecné

Profil

Stáhnout (782 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
# promise-inflight
2
3
One promise for multiple requests in flight to avoid async duplication
4
5
## USAGE
6
7
```javascript
8
const inflight = require('promise-inflight')
9
10
// some request that does some stuff
11
function req(key) {
12
  // key is any random string.  like a url or filename or whatever.
13
  return inflight(key, () => {
14
    // this is where you'd fetch the url or whatever
15
    return Promise.delay(100)
16
  })
17
}
18
19
// only assigns a single setTimeout
20
// when it dings, all thens get called with the same result.  (There's only
21
// one underlying promise.)
22
req('foo').then()
23
req('foo').then()
24
req('foo').then()
25
req('foo').then()
26
```
27
28
## SEE ALSO
29
30
* [inflight](https://npmjs.com/package/inflight) - For the callback based function on which this is based.
31
32
## STILL NEEDS
33
34
Tests!