2.0.0 • Published 7 years ago

@bikossor/flipflop v2.0.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
7 years ago

flipflop

Getting started

Requirements

  • None

Installing via npm

npm install @bikossor/flipflop

Installing without npm

  • Download the latest release of flipflop here. Paste flipflop into your script and you are done.

API

Methods

Creating a new instance of a flipflop

var ff = new flipflop(initial state);

Toggles the state of the flipflop (false -> true | true -> false)

ff.toggle();

Sets the state of the flipflop to true

ff.set();

Sets the state of the flipflop to false

ff.reset();

Returns the current state of the flipflop

ff.getState();

Checks, if the current state of the flipflop is true

ff.isTrue();

Checks, if the current state of the flipflop is false

ff.isFalse();

Events

ff.onStateChanged(function(state) {
    console.log("State changed! New state:", state);
});
ff.onStateTrue(function() {
    console.log("State is true!");
});
ff.onStateFalse(function() {
    console.log("State is false!");
});
2.0.0

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago