1.0.1 • Published 1 year ago

global-kill v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Global Kill

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

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-kill

yarn:

yarn add global-kill

pnpm:

pnpm add global-kill

Usage

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 module

Removing a module

To remove a module, you can use the remove method:

const feature = new GlobalKill.module("myFeature")

feature.remove() // Removes the module

Getting 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 modules

Contributing

Contributions, issues and feature requests are welcome!

PR Checklist

  • Code is up-to-date with the main branch
  • npm run lint passes with this change
  • npm 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

License

MIT © net-tech-#7475

Donate

ko-fi