Huge news!Announcing our $20M Series A led by Andreessen Horowitz.Learn more
Socket
Socket
Log inDemoInstall

promise-inflight

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Issues
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

promise-inflight

One promise for multiple requests in flight to avoid async duplication

    1.0.1latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
11,741,766
decreased by-9.17%

Weekly downloads

Readme

Source

promise-inflight

One promise for multiple requests in flight to avoid async duplication

USAGE

const inflight = require('promise-inflight')

// some request that does some stuff
function req(key) {
  // key is any random string.  like a url or filename or whatever.
  return inflight(key, () => {
    // this is where you'd fetch the url or whatever
    return Promise.delay(100)
  })
}

// only assigns a single setTimeout
// when it dings, all thens get called with the same result.  (There's only
// one underlying promise.)
req('foo').then(…)
req('foo').then(…)
req('foo').then(…)
req('foo').then(…)

SEE ALSO

  • inflight - For the callback based function on which this is based.

STILL NEEDS

Tests!

FAQs

Last updated on 26 Feb 2017

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install
SocketSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc