Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 7, 2024 via pnpm

inflight 1.0.6

Add callbacks to requests in flight to avoid async duplication
Package summary
Share
0
issues
1
license
3
ISC
Package created
5 May 2014
Version published
13 Oct 2016
Maintainers
6
Total deps
3
Direct deps
2
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
inflight@1.0.6
once@1.4.0
wrappy@1.0.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
ⓘ This is a list of inflight 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
once1.4.01.93 kBISC
prod
wrappy1.0.21.64 kBISC
prod

Visualizations

Frequently Asked Questions

What does inflight do?

Inflight is a popular JavaScript package in the npm registry. Its core function is to add callbacks to requests that are currently in flight to prevent asynchronous duplication. This means that if multiple asynchronous requests are made using the same key, Inflight ensures that only one request actually gets executed and the resulting value is shared among all the requests. This helps to prevent unnecessary requests and enhances the performance of your JavaScript code.

How do you use inflight?

To utilize the Inflight package, you first need to install it with npm in your project. Once that is done, you can require it in your JavaScript file. Below is an example of how you can use Inflight in a function that makes some request, utilizing a key and a callback function:

In JavaScript:

var inflight = require('inflight'); // Require the package

// Function that uses inflight
function req(key, callback) {
  callback = inflight(key, callback);

  if (!callback) return;

  setTimeout(function() {
    callback(null, key);
  }, 100);
}

// Call function with requests
req('foo', cb1);
req('foo', cb2);
req('foo', cb3);
req('foo', cb4);

In the above code, only a single setTimeout assignment is made. When the timer expires, all callback functions get called.

Where are the inflight docs?

For more detailed information about Inflight, you can refer to the official documentation available in the readme.md file on the project’s GitHub page, accessible at git+https://github.com/npm/inflight.git. This documentation provides an in-depth overview of the package, including its usage and more concrete examples to guide users. For any JavaScript developer keen on preventing asynchronous duplication in their requests, Inflight represents an excellent solution.