All files state.js

93.93% Statements 31/33
85.71% Branches 6/7
83.33% Functions 5/6
93.93% Lines 31/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 343x 3x 3x 3x 3x 3x 3x 3x 3x 6x 6x 3x 3x 3x 1149x 1149x 3x 3x 3x 393x 393x 3x 3x 3x     3x 3x 1x 1x 3x 3x 3x  
/**
 * Enum representing the state of a cell (alive or dead).
 */
class State {
  static ALIVE = new State(true);
  static DEAD = new State(false);
 
  /** @param alive {boolean} */
  constructor(alive) {
    this.alive = alive;
  }
 
  /** @returns {boolean} */
  get isAlive() {
    return this.alive;
  }
 
  /** @returns {boolean} */
  get isDead() {
    return !this.alive;
  }
 
  /** @returns {State} */
  get inverse() {
    return this.alive ? State.DEAD : State.ALIVE;
  }
 
  toString() {
    return this.alive ? 'alive' : 'dead';
  }
}
 
export { State };