code: function defer(terminal, deferredFn) {
  
    // Ensure that this method is only used within Terminal class.
    if (!(terminal instanceof Terminal)) {
      throw new Error("Must be instanceof Terminal");
    }
  
    // If the terminal is ready, execute.
    if (terminal.isReady) {
      deferredFn.apply(terminal, null);
      return;
    }
  
    // Queue until terminal is ready.
    terminal.deferreds.push({
      run: function() {
        // Run deffered.
        deferredFn.apply(terminal, null);
      }
    });
  }
docs: Helpers