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 May 5, 2024 via pnpm

import-fresh 2.0.0

Import a module while bypassing the cache
Package summary
Share
0
issues
1
license
5
MIT
Package created
21 May 2017
Version published
21 May 2017
Maintainers
1
Total deps
5
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
5 Packages, Including:
caller-callsite@2.0.0
caller-path@2.0.0
callsites@2.0.0
import-fresh@2.0.0
resolve-from@3.0.0
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 import-fresh 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
caller-path2.0.01.44 kBMIT
prod
resolve-from3.0.02.04 kBMIT
prod

Visualizations

Frequently Asked Questions

What does import-fresh do?

The import-fresh module in JavaScript offers an opportunity to import another module while bypassing the cache. This can be extremely useful, particularly when testing, as it allows users to freshly import a module without any residual cache variables or data.

How do you use import-fresh?

The implementation and use of the import-fresh module is very simple. After installing the package using npm install import-fresh, you can require it in your script with const importFresh = require('import-fresh');. Here's how it works in practice:

// In your foo.js file, you might have something like this:
let i = 0;
module.exports = () => ++i;

// Then in your main file:
const importFresh = require('import-fresh');

require('./foo')(); //=> 1
require('./foo')(); //=> 2
importFresh('./foo')(); //=> 1
importFresh('./foo')(); //=> 1

As the above example demonstrates, the same module, when imported normally, maintains the count (i) in the cache. So, every time the module exports function is called, the count increases. However, when the same module is imported using the import-fresh module, the cache is bypassed, resulting in the count resetting to its original value each time the function is called.

Where are the import-fresh docs?

The import-fresh documentation and further details concerning its functionality and usage can be found on its official GitHub page here. This page also discusses how import-fresh can be beneficial for enterprise-level applications, through a Tidelift Subscription, which provides commercial support and maintenance for this and thousands of other open-source dependencies.