1.0.1 • Published 2 years ago
global-kill v1.0.1
Global Kill
Global Kill is a convenient package that enables you to disable certain features of your code with ease. This package draws inspiration from Cloudflare.
Install
npm:
npm install global-killyarn:
yarn add global-killpnpm:
pnpm add global-killUsage
Importing the module
const { GlobalKill } = require("global-kill")or in ES6
import { GlobalKill } from "global-kill"Example
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
}Creating a new module
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)Enabling and disabling a module
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 moduleRemoving a module
To remove a module, you can use the remove method:
const feature = new GlobalKill.module("myFeature")
feature.remove() // Removes the moduleGetting a module
To get a module by name
You can use the get method:
const feature = GlobalKill.get("myFeature")Resetting all modules
To reset all modules
You can use the reset method:
GlobalKill.reset() // Resets all modulesContributing
Contributions, issues and feature requests are welcome!
PR Checklist
- Code is up-to-date with the
mainbranch npm run lintpasses with this changenpm run testpasses 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
License
MIT © net-tech-#7475