Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

state-toggle

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

state-toggle

Enter/exit a state

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
decreased by-3.8%
Maintainers
1
Weekly downloads
 
Created

What is state-toggle?

The state-toggle npm package provides a simple utility to manage toggle states. It is particularly useful for managing binary states such as on/off, true/false, or active/inactive in applications. This package helps in creating a toggle function that can switch between two states and also provides a method to get the current state.

What are state-toggle's main functionalities?

Creating a toggle

This feature allows you to create a toggle between two states. The `toggle` function initializes the state and provides a method to switch between the initialized states. The example demonstrates initializing a toggle between 'on' and 'off' and toggling between these states.

const toggle = require('state-toggle');
const myToggle = toggle('on', 'off');
console.log(myToggle()); // 'on'
console.log(myToggle.toggle()); // 'off'
console.log(myToggle()); // 'off'

Getting the current state

This feature is used to retrieve the current state of the toggle. The example shows how to initialize a toggle and retrieve the state before and after toggling.

const toggle = require('state-toggle');
const myToggle = toggle('active', 'inactive');
console.log(myToggle()); // 'active'
myToggle.toggle();
console.log(myToggle()); // 'inactive'

Other packages similar to state-toggle

Keywords

FAQs

Package last updated on 14 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc