function withSwitch(a, b) {
  let state = a;
  let next = b;

  /**
   * Returns the state of the switch.
   * @returns {*} - The current state.
   */
  function get() {
    return state;
  }

  /**
   * Toggles the state of the switch.
   */
  function toggle() {
    const prev = state;
    state = next;
    next = prev;
  }

  return [get, toggle];
}
Create enclosed state. Returns functions to getting and cycling between states.
@param {*} a - initial state.
@param {*} b - next state.
@returns {Functions[]} -- [get, toggle];