state-toggle

WebJar for state-toggle

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

state-toggle
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

state-toggle
WebJar for state-toggle
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/wooorm/state-toggle

Download state-toggle

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/state-toggle/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>state-toggle</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/state-toggle/
implementation 'org.webjars.npm:state-toggle:1.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/state-toggle/
implementation ("org.webjars.npm:state-toggle:1.0.3")
'org.webjars.npm:state-toggle:jar:1.0.3'
<dependency org="org.webjars.npm" name="state-toggle" rev="1.0.3">
  <artifact name="state-toggle" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='state-toggle', version='1.0.3')
)
libraryDependencies += "org.webjars.npm" % "state-toggle" % "1.0.3"
[org.webjars.npm/state-toggle "1.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

state-toggle

Build Coverage Downloads Size

Enter/exit a state.

Install

npm:

npm install state-toggle

Use

var toggle = require('state-toggle')

var ctx = {on: false}
var enter = toggle('on', ctx.on, ctx)
var exit

// Entering:
exit = enter()
console.log(ctx.on) // => true

// Exiting:
exit()
console.log(ctx.on) // => false

API

toggle(key, initial[, ctx])

Create a toggle, which when entering toggles key on ctx (or this, if ctx is not given) to !initial, and when exiting, sets key on the context back to the value it had before entering.

Returns

Functionenter.

enter()

Enter the state.

Context

If no ctx was given to toggle, the context object (this) of enter() is used to toggle.

Returns

Functionexit.

exit()

Exit the state, reverting key to the value it had before entering.

License

MIT © Titus Wormer

Versions

Version
1.0.3
1.0.2
1.0.1
1.0.0