4.1.2 • Published 4 years ago

clear-module v4.1.2

Weekly downloads
68,953
License
MIT
Repository
github
Last release
4 years ago

clear-module

Clear a module from the cache

Useful for testing purposes when you need to freshly import a module.

Install

$ npm install clear-module

Usage

// foo.js
let i = 0;
module.exports = () => ++i;
const clearModule = require('clear-module');

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

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

clearModule('./foo');

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

API

clearModule(moduleId)

moduleId

Type: string

What you would use with require().

clearModule.all()

Clear all modules from the cache.

clearModule.match(regex)

Clear all matching modules from the cache.

regex

Type: RegExp

Regex to match against the module IDs.

clearModule.single(moduleId)

Clear a single module from the cache non-recursively. No parent or children modules will be affected.

This is mostly only useful if you use singletons, where you would want to clear a specific module without causing any side effects.

moduleId

Type: string

What you would use with require().

Related

@saasxx/cli-servicevtex3rf-bot-frameworkmulti-app@avrora/engine@nuxtjs-alt/tailwindcss@hotfusion/servicereact-native-breeze@everything-registry/sub-chunk-1334tachyon-gamepad-inputtachyon-intltachyon-intl-servertachyon-latency-trackertachyon-next-routing-utilstachyon-notificationtachyon-page-utilstachyon-relaytachyon-type-library1tachyon-utils-mem1tachyon-utils1tachyon-debug-reportertachyon-event-reportertailwind-fmtsvrwinston-tcp-graylogwdio-perfecto-ps.v2-servicewdio-perfecto.v2-servicexatxcraft-core-etcxcraft-core-busswafvoicenter-web-sdkvtex-forkvite-plugin-api-mockervue-cli-plugin-mockervue-flags-webpack-plugin@droyer/nuxt-site@booxood/mocker-api@prisma/mdxjinghuanjsjallakoa-dir-routerlambda-mocha-runnerhzero-cli-uuihapi-render-reactlitbotlesswork-cmdliveroutematryoshka.js@whitetrefoil/msm@wetrial/ui@ts-app/graphql@twind/typescript-plugin@tscss/core@umax-admin/umi-plugin-electron@umijs/plugin-electron@tremho/mist-lift@types/clear-require@timhudson/atlas@thejsngin/rollup-plugin@tomw2w/my-nuxt-layer@tfdf/cli-service@ventinc/migrator@victorcolombo/tjwsbfnhsn@ycn/nuxt-tailwindcss@zalastax/nolb-cle@terrajs/mono@ztjy/http-mock-middlewarealfred-cli-serviceass_assw_saassasdasdss_asdssw_sa@cj97/koa-dir-router@cksource-cs/eslint-config-cs-module@guijs/server-core@cmlabs/components@eas-framework/server@adonisjs/dev-utils@copyist/common-utils@svc-npm-perfecto-ps/wdio-perfecto.v.2-servicewdio-perfecto-v-3-servicesquidoubiktimeloadumi-uitoast-statictwitch-clientchattwitch-core-ui-fontstwitch-core-ui-utils@carioca/utils@celljs/cli-serviceyipack-plugin-uniappwatch-moduleswebpack-api-mocker@naze/plugin@metamist/twind-typescript-plugin@mockyeah/server@hotfusion/micro@rxdi/graphqj@radjs/ui@poppinss/dev-utils
4.1.2

4 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.1.0

8 years ago