{"size": 670, "ext": "js", "max_stars_repo_path": "src/commands/command.js", "max_stars_repo_name": "omriyariv/commando", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/commands/command.js", "max_issues_repo_name": "omriyariv/commando", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/commands/command.js", "max_forks_repo_name": "omriyariv/commando", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 15.9523809524, "max_line_length": 49, "alphanum_fraction": 0.6208955224}
import { Events, Model } from 'backbone';
import _ from 'underscore';

const Command = function Command(deps, args) {
  this._deps = deps;
  this._args = args;
  this.initialize.apply(this, args);
};

_.extend(Command.prototype, Events, {

  register: undefined,

  initialize() {},

  execute() {},

  unexecute() {
    while (this._deps.executer.canUndo()) {
      this._deps.executer.undo();
    }
  },

  do(...args) {
    const cmd = this._deps.factory.make(...args);
    return this._deps.executer.do(cmd);
  },

  setMode(mode) {
    this._mode = mode;
  },

  getMode() {
    return this._mode;
  },

});

Command.extend = Model.extend;

export default Command;
