Giter Club home page Giter Club logo

decache's Introduction

decache

Build Status codecov.io Code Climate Dependency Status devDependency Status

In node.js when you require() a module, node stores a cached version of the module, so that all subsequent calls to require() do not have to reload the module from the filesystem.

decache ( Delete Cache ) lets you delete modules from node.js require() cache this is useful when testing your modules/projects.

Why?

When testing our modules we often need to re-require the module being tested. This makes it easy.

What?

An easy way to delete a cached module.

How? (usage)

### install

Install the module from npm:

npm install decache --save-dev

Use it in your code:

// require the decache module:
var decache = require('decache');

// require a module that you wrote"
var mymod = require('./mymodule.js');

// use your module the way you need to:
console.log(mymod.count()); // 0   (the initial state for our counter is zero)
console.log(mymod.incrementRunCount()); // 1

// delete the cached module:
decache('./mymodule.js');

//
mymod = require('./mymodule.js'); // fresh start
console.log(mymod.count()); // 0   (back to initial state ... zero)

Modules other than .js, like for example, .jsx, are supported as well.

If you have any questions or need more examples, please create a GitHub issue: https://github.com/nelsonic/decache/issues

Thanks!

decache's People

Contributors

benjaminlees avatar besarthoxhaj avatar iteles avatar jupiter avatar nelsonic avatar perrin4869 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.