Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
LICENSE | D | 12-May-2024 | 752 | 15 | 11 | |
README.md | D | 12-May-2024 | 782 | 35 | 25 | |
inflight.js | D | 12-May-2024 | 842 | 37 | 33 | |
package.json | D | 12-May-2024 | 1.5 KiB | 61 | 60 |
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