promise-inflight

WebJar for promise-inflight

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

promise-inflight
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

promise-inflight
WebJar for promise-inflight
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/iarna/promise-inflight

Download promise-inflight

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/promise-inflight/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>promise-inflight</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/promise-inflight/
implementation 'org.webjars.npm:promise-inflight:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/promise-inflight/
implementation ("org.webjars.npm:promise-inflight:1.0.1")
'org.webjars.npm:promise-inflight:jar:1.0.1'
<dependency org="org.webjars.npm" name="promise-inflight" rev="1.0.1">
  <artifact name="promise-inflight" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='promise-inflight', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "promise-inflight" % "1.0.1"
[org.webjars.npm/promise-inflight "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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!

Versions

Version
1.0.1