{"size": 932, "ext": "js", "max_stars_repo_path": "Lesson05/Activtiy06/src/js/flashingLight.js", "max_stars_repo_name": "areskadi/jsbook", "max_stars_repo_stars_event_min_datetime": "2018-05-25T21:04:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T08:59:47.000Z", "max_issues_repo_path": "Lesson05/Activtiy06/src/js/flashingLight.js", "max_issues_repo_name": "areskadi/jsbook", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lesson05/Activtiy06/src/js/flashingLight.js", "max_forks_repo_name": "areskadi/jsbook", "max_forks_repo_forks_event_min_datetime": "2018-11-16T11:30:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-04T15:10:03.000Z"}
{"max_stars_count": 31, "max_issues_count": null, "max_forks_count": 37, "avg_line_length": 21.1818181818, "max_line_length": 61, "alphanum_fraction": 0.6512875536}
import Light from './light.js';
let privateVars = new WeakMap();

class FlashingLight extends Light {

  constructor(state=false, brightness=100, flashMode=true) {
    super(state, brightness);
    let info = {"flashMode": flashMode};
    privateVars.set(this, info);
    if(flashMode===true) {
      this.startFlashing();
    }
  }

  setFlashMode(flashMode) {
    let info = privateVars.get(this);
    info.flashMode = checkStateFormat(flashMode);
    privateVars.set(this, info);
    if(flashMode===true) {
      this.startFlashing();
    } else {
      this.stopFlashing();
    }
  }

  getFlashMode() {
    let info = privateVars.get(this);
    return info.flashMode;
  }

  startFlashing() {
    let info = privateVars.get(this);
    info.flashing = setInterval(this.toggle.bind(this),5000);
  }

  stopFlashing() {
    let info = privateVars.get(this);
    clearInterval(info.flashing);
  }

}

export default FlashingLight;
