Global Kill is a convenient package that enables you to disable certain features of your code with ease. This package draws inspiration from Cloudflare.
npm:
npm install global-kill
yarn:
yarn add global-kill
pnpm:
pnpm add global-kill
const { GlobalKill } = require("global-kill")
or in ES6
import { GlobalKill } from "global-kill"
const { GlobalKill } = require("global-kill")
// Create a new module
const sumOperations = new GlobalKill.module("sumOperations")
function sum(a, b) {
// Check if the module is enabled
if (sumOperations.enabled) {
return a + b
}
return 0
}
To create a new module
You can use GlobalKill.module
constructor:
const feature = new GlobalKill.module("myFeature")
You can also create a module that is disabled by default:
const feature = GlobalKill.module("myFeature", false)
To enable or disable a module, you can use the enable
and disable
methods:
const feature = new GlobalKill.module("myFeature")
feature.enable() // Enables the module
feature.disable() // Disables the module
To remove a module, you can use the remove
method:
const feature = new GlobalKill.module("myFeature")
feature.remove() // Removes the module
To get a module by name
You can use the get
method:
const feature = GlobalKill.get("myFeature")
To reset all modules
You can use the reset
method:
GlobalKill.reset() // Resets all modules
Contributions, issues and feature requests are welcome!
PR Checklist
- Code is up-to-date with the
main
branch npm run lint
passes with this changenpm run test
passes with this change- This pull request links relevant issues as
Fixes #0000
- There are new or updated unit tests validating the change
- Documentation has been updated to reflect this change
- The new commits follow conventions outlined in the conventional commit spec
MIT © net-tech-#7475