• Home
Name Date Size #Lines LOC

..--

LICENSED12-May-2024752 1511

README.mdD12-May-2024782 3525

inflight.jsD12-May-2024842 3733

package.jsonD12-May-20241.5 KiB6160

README.md

1# promise-inflight
2
3One promise for multiple requests in flight to avoid async duplication
4
5## USAGE
6
7```javascript
8const inflight = require('promise-inflight')
9
10// some request that does some stuff
11function 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.)
22req('foo').then(…)
23req('foo').then(…)
24req('foo').then(…)
25req('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
34Tests!
35