4.1.2 • Published 2 years ago

clear-module v4.1.2

Weekly downloads
68,953
License
MIT
Repository
github
Last release
2 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-1334dw-mx-request-mockdw-mx-request-mockerdw-gs-mx-request-mockeregg-site-renderendpoint-imposterfirost@svc-npm-perfecto-ps/wdio-perfecto.v.2-servicewdio-perfecto-v-3-servicejallahapi-render-reactgoblin-webpackjinghuanjshzero-cli-uuikoa-dir-routerlambda-mocha-runner@malmo/cli-utils@malagu/cli-servicematryoshka.jslesswork-cmd@jazzyclimber/parachutemockyeahmrnodebotmitm-play@joedoyle23/semantic-release-github-pullrequestliveroutelitbotmocker-apimocker-api-pathmono-coremonote@mockyeah/server@naze/plugin@nuxtjs/tailwindcss-edgeparcel-u@poppinss/dev-utils@prisma/mdxnow-we-testnode-js-preprocessor@radjs/uipinokiodproxy-switch-plugin@rxdi/graphqjnuxt-tailwind-breakpoints@openeagle/http-mock-middlewareprisma-mdx@ztjy/http-mock-middlewaresellerass_assw_saassasdasdss_asdssw_sa@booxood/mocker-api@victorcolombo/tjwsbfnhsn@appruut/node-dev-utilssemantic-release-github-pullrequest@tfdf/cli-service@wetrial/ui@terrajs/mono@ycn/nuxt-tailwindcss@thejsngin/rollup-plugin@whitetrefoil/msm@ventinc/migrator@static-suite/static-suite-data-server@spingroup/parachute@twind/typescript-plugin@tomw2w/my-nuxt-layer@umijs/plugin-electron@umax-admin/umi-plugin-electron@ts-app/graphqlqu4rtet-ui@timhudson/atlaspulsar-player-corepulsar-utils@adonisjs/dev-utilsrestart@zalastax/nolb-clealfred-cli-service@droyer/nuxt-site@socicam/sip-receipt-sender@tscss/core@cj97/koa-dir-router@carioca/utils@cksource-cs/eslint-config-cs-modulesindresorhus.jssquido@cmlabs/components@copyist/common-utilscspell-libswafsvr@docus/apptachyon-debug-reportertachyon-event-reporter
4.1.2

2 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

6 years ago

2.1.0

7 years ago