# freshy

> A node module (un|re)loader.

Latest version **1.0.4** (published 2017-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install freshy
pnpm add freshy
yarn add freshy
bun add freshy
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-11-10 |
| First published | 2014-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/freshy) |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Erik Toth |
| Maintainers | gabrielcsapo, totherik |

## Links

- npm: https://www.npmjs.com/package/freshy
- Repository: https://github.com/totherik/freshy
- Homepage: https://github.com/totherik/freshy#readme
- Issues: https://github.com/totherik/freshy/issues
- npm.io page: https://npm.io/package/freshy

## Dependencies (4)

- [caller](https://npm.io/package/caller.md) 0.0.1
- [resolve](https://npm.io/package/resolve.md) ^1.1.6
- [debuglog](https://npm.io/package/debuglog.md) ^1.0.1
- [path-is-absolute](https://npm.io/package/path-is-absolute.md) ^1.0.0

## Recent versions

- 1.0.4 (latest) — 2017-11-10
- 1.0.3 — 2017-06-14
- 1.0.2 — 2016-02-09
- 1.0.1 — 2015-07-15
- 1.0.0 — 2015-02-10
- 0.0.2 — 2014-02-13
- 0.0.1 — 2014-02-13

## README

# freshy

An (admittedly naïve) node module (un|re)loader/refreshener.

[![Build Status](https://travis-ci.org/totherik/freshy.png)](https://travis-ci.org/totherik/freshy)


## API
### unload(module)

* `module` (*String*) - the module to unload

Completely unload a node module from the cache. Returns `true` if the module was present in the cache, `false` if not.

```javascript
var minimist = require('minimist'),
    freshy = require('freshy');

freshy.unload('minimist'); // true
```


### reload(module)

* `module` (*String*) - the module to reload

Completely unload and reload a given module in place, leaving the new copy in the cache. Returns reloaded module.

```javascript
var minimist = require('minimist'),
    freshy = require('freshy');

var fresh = freshy.reload('minimist');
console.log(minimist === fresh); // false
```


### freshy(module, [callback])

* `module` (*String*) - the module for which to fetch a fresh instance
* `callback` (*function*, optional) - A function called while the fresh module is the one in cache

Get a fresh instance of a module without disturbing the cached copy. Returns the fresh module instance.

```javascript
var minimist = require('minimist'),
    freshy = require('freshy');

var fresh = freshy.freshy('minimist');
console.log(minimist === fresh); // false

var mini = require('minimist');
console.log(minimist === mini); // true
```

And to get a consistent require of modules that require each other, you can use the callback style:

```javascript
var minimist = require('minimist'),
    freshy = require('freshy');

var alsofresh;
var fresh = freshy.freshy('minimist', function (fresh) {
    alsofresh = require('minimist');

    console.log(fresh === alsofresh); // true
});
console.log(minimist === fresh); // false
console.log(fresh == alsofresh); // true

var mini = require('minimist');
console.log(minimist === mini); // true
```

This is useful for modules that alter other modules you require. `dustjs-linkedin` and `dustjs-helpers` is an example of this.

---
_Source: https://npm.io/package/freshy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
