Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()
```

Response:
({
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {
      return this.loadJsonStringIntoProjectFromExternalSource(jsonString);
    });
  },
  // ===========================================================================
  // External URL
  // ===========================================================================

  // TODO: Deal with error conditions, timeout, etc.
  // TODO: Maybe move xhr stuff to Util.
  // TODO: Show some sort of loading indicator.
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      return this.loadJsonStringIntoProjectFromExternalSource(jsonString);
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.getJsonStringOfProject();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.loadJsonStringIntoProject(this.current);
    return this.saveToLocalStorage();
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
({
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {
      return this.loadJsonStringIntoProjectFromExternalSource(jsonString);
    });
  },
  // ===========================================================================
  // External URL
  // ===========================================================================

  // TODO: Deal with error conditions, timeout, etc.
  // TODO: Maybe move xhr stuff to Util.
  // TODO: Show some sort of loading indicator.
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      return this.loadJsonStringIntoProjectFromExternalSource(jsonString);
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.getJsonStringOfProject();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.loadJsonStringIntoProject(this.current);
    return this.saveToLocalStorage();
  }
});
```

Response:
loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()


Prompt:
loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History

Response:
# ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()


Response:
redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0
```

Response:
({
  redo: function() {
    if (!this.isRedoable()) {
      return;
    }
    this.undoStack.push(this.current);
    this.current = this.redoStack.pop();
    this.loadJsonStringIntoProject(this.current);
    return this.saveToLocalStorage();
  },
  isUndoable: function() {
    return this.undoStack.length > 0;
  },
  isRedoable: function() {
    return this.redoStack.length > 0;
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
({
  redo: function() {
    if (!this.isRedoable()) {
      return;
    }
    this.undoStack.push(this.current);
    this.current = this.redoStack.pop();
    this.loadJsonStringIntoProject(this.current);
    return this.saveToLocalStorage();
  },
  isUndoable: function() {
    return this.undoStack.length > 0;
  },
  isRedoable: function() {
    return this.redoStack.length > 0;
  }
});
```

Response:
redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Prompt:
redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

Response:
isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Response:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  loadJsonStringIntoProject: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  loadJsonStringIntoProject: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.
```

Response:
var Editor,
  hasProp = {}.hasOwnProperty;

module.exports = Editor = (function() {
  class Editor {
    constructor() {
      this._setupLayout();
      this._setupSerializer();
      this._setupProject();
      this._setupRevision();
      this._parseQueryString();
    }

    _setupLayout() {
      return this.layout = new Model.Layout();
    }

    _setupProject() {
      this.loadFromLocalStorage();
      if (!this.project) {
        return this.createNewProject();
      }
    }

    _setupSerializer() {
      var builtInObjects, name, object, ref;
      builtInObjects = [];
      ref = this._builtIn();
      for (name in ref) {
        if (!hasProp.call(ref, name)) continue;
        object = ref[name];
        if (_.isFunction(object)) {
          object = object.prototype;
        }
        Util.assignId(object, name);
        builtInObjects.push(object);
      }
      return this.serializer = new Storage.Serializer(builtInObjects);
    }

    // Checks if we should load an external JSON file based on the query string
    // (the ?stuff at the end of the URL).
    _parseQueryString() {
      var parsed;
      parsed = queryString.parse(location.search);
      if (parsed.load) {
        return this.loadFromURL(parsed.load);
      }
    }

    // builtIn returns all of the built in classes and objects that are used as
    // the "anchors" for serialization and deserialization. That is, all of the
    // objects and classes which should not themselves be serialized but instead
    // be *referenced* from a serialization. When deserialized, these references
    // are then bound appropriately.
    _builtIn() {
      var builtIn;
      builtIn = _.clone(Model);
      builtIn["SpreadEnv"] = Dataflow.SpreadEnv;
      builtIn["Matrix"] = Util.Matrix;
      return builtIn;
    }

    loadJsonStringIntoProject(jsonString) {
      var json;
      return json = JSON.parse(jsonString);
    }

  };

  // TODO: get version via build process / ENV variable?
  Editor.prototype.version = "0.4.1";

  return Editor;

}).call(this);

// TODO: If the file format changes, this will need to check the version
// and convert or fail appropriately.


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Editor,
  hasProp = {}.hasOwnProperty;

module.exports = Editor = (function() {
  class Editor {
    constructor() {
      this._setupLayout();
      this._setupSerializer();
      this._setupProject();
      this._setupRevision();
      this._parseQueryString();
    }

    _setupLayout() {
      return this.layout = new Model.Layout();
    }

    _setupProject() {
      this.loadFromLocalStorage();
      if (!this.project) {
        return this.createNewProject();
      }
    }

    _setupSerializer() {
      var builtInObjects, name, object, ref;
      builtInObjects = [];
      ref = this._builtIn();
      for (name in ref) {
        if (!hasProp.call(ref, name)) continue;
        object = ref[name];
        if (_.isFunction(object)) {
          object = object.prototype;
        }
        Util.assignId(object, name);
        builtInObjects.push(object);
      }
      return this.serializer = new Storage.Serializer(builtInObjects);
    }

    // Checks if we should load an external JSON file based on the query string
    // (the ?stuff at the end of the URL).
    _parseQueryString() {
      var parsed;
      parsed = queryString.parse(location.search);
      if (parsed.load) {
        return this.loadFromURL(parsed.load);
      }
    }

    // builtIn returns all of the built in classes and objects that are used as
    // the "anchors" for serialization and deserialization. That is, all of the
    // objects and classes which should not themselves be serialized but instead
    // be *referenced* from a serialization. When deserialized, these references
    // are then bound appropriately.
    _builtIn() {
      var builtIn;
      builtIn = _.clone(Model);
      builtIn["SpreadEnv"] = Dataflow.SpreadEnv;
      builtIn["Matrix"] = Util.Matrix;
      return builtIn;
    }

    loadJsonStringIntoProject(jsonString) {
      var json;
      return json = JSON.parse(jsonString);
    }

  };

  // TODO: get version via build process / ENV variable?
  Editor.prototype.version = "0.4.1";

  return Editor;

}).call(this);

// TODO: If the file format changes, this will need to check the version
// and convert or fail appropriately.
```

Response:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  loadJsonStringIntoProject: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.


Prompt:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

Response:
# Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  loadJsonStringIntoProject: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.


Response:
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  loadJsonStringIntoProjectFromExternalSource: (jsonString) ->
    @loadJsonStringIntoProject(jsonString)
    @checkpoint()
    Apparatus.refresh()  # HACK: calling Apparatus seems funky here.

  getJsonStringOfProject: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @getJsonStringOfProject()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @loadJsonStringIntoProject(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @getJsonStringOfProject()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  loadJsonStringIntoProjectFromExternalSource: (jsonString) ->
    @loadJsonStringIntoProject(jsonString)
    @checkpoint()
    Apparatus.refresh()  # HACK: calling Apparatus seems funky here.

  getJsonStringOfProject: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @getJsonStringOfProject()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @loadJsonStringIntoProject(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @getJsonStringOfProject()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
```

Response:
if (json.type === "Apparatus") {
  this.project = this.serializer.dejsonify(json);
}

({
  loadJsonStringIntoProjectFromExternalSource: function(jsonString) {
    this.loadJsonStringIntoProject(jsonString);
    this.checkpoint();
    return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.
  },
  getJsonStringOfProject: function() {
    var json, jsonString;
    json = this.serializer.jsonify(this.project);
    json.type = "Apparatus";
    json.version = this.version;
    jsonString = JSON.stringify(json);
    return jsonString;
  },
  createNewProject: function() {
    return this.project = new Model.Project();
  },
  // ===========================================================================
  // Local Storage
  // ===========================================================================
  localStorageName: "apparatus",
  saveToLocalStorage: function() {
    var jsonString;
    jsonString = this.getJsonStringOfProject();
    window.localStorage[this.localStorageName] = jsonString;
    return jsonString;
  },
  loadFromLocalStorage: function() {
    var jsonString;
    jsonString = window.localStorage[this.localStorageName];
    if (jsonString) {
      return this.loadJsonStringIntoProject(jsonString);
    }
  },
  resetLocalStorage: function() {
    return delete window.localStorage[this.localStorageName];
  },
  // ===========================================================================
  // File System
  // ===========================================================================
  saveToFile: function() {
    var fileName, jsonString;
    jsonString = this.getJsonStringOfProject();
    fileName = this.project.editingElement.label + ".json";
    return Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8");
  },
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {});
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
if (json.type === "Apparatus") {
  this.project = this.serializer.dejsonify(json);
}

({
  loadJsonStringIntoProjectFromExternalSource: function(jsonString) {
    this.loadJsonStringIntoProject(jsonString);
    this.checkpoint();
    return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.
  },
  getJsonStringOfProject: function() {
    var json, jsonString;
    json = this.serializer.jsonify(this.project);
    json.type = "Apparatus";
    json.version = this.version;
    jsonString = JSON.stringify(json);
    return jsonString;
  },
  createNewProject: function() {
    return this.project = new Model.Project();
  },
  // ===========================================================================
  // Local Storage
  // ===========================================================================
  localStorageName: "apparatus",
  saveToLocalStorage: function() {
    var jsonString;
    jsonString = this.getJsonStringOfProject();
    window.localStorage[this.localStorageName] = jsonString;
    return jsonString;
  },
  loadFromLocalStorage: function() {
    var jsonString;
    jsonString = window.localStorage[this.localStorageName];
    if (jsonString) {
      return this.loadJsonStringIntoProject(jsonString);
    }
  },
  resetLocalStorage: function() {
    return delete window.localStorage[this.localStorageName];
  },
  // ===========================================================================
  // File System
  // ===========================================================================
  saveToFile: function() {
    var fileName, jsonString;
    jsonString = this.getJsonStringOfProject();
    fileName = this.project.editingElement.label + ".json";
    return Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8");
  },
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {});
  }
});
```

Response:
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  loadJsonStringIntoProjectFromExternalSource: (jsonString) ->
    @loadJsonStringIntoProject(jsonString)
    @checkpoint()
    Apparatus.refresh()  # HACK: calling Apparatus seems funky here.

  getJsonStringOfProject: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @getJsonStringOfProject()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @loadJsonStringIntoProject(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @getJsonStringOfProject()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>


Prompt:
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  loadJsonStringIntoProjectFromExternalSource: (jsonString) ->
    @loadJsonStringIntoProject(jsonString)
    @checkpoint()
    Apparatus.refresh()  # HACK: calling Apparatus seems funky here.

  getJsonStringOfProject: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

Response:
saveToLocalStorage: ->
    jsonString = @getJsonStringOfProject()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @loadJsonStringIntoProject(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @getJsonStringOfProject()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>


Response:
@loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  redo: ->


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
@loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  redo: ->
```

Response:
this.loadJsonStringIntoProjectFromExternalSource(jsonString)({
  // ===========================================================================
  // External URL
  // ===========================================================================

  // TODO: Deal with error conditions, timeout, etc.
  // TODO: Maybe move xhr stuff to Util.
  // TODO: Show some sort of loading indicator.
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      return this.loadJsonStringIntoProjectFromExternalSource(jsonString);
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.getJsonStringOfProject();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.loadJsonStringIntoProject(this.current);
    return this.saveToLocalStorage();
  },
  redo: function() {}
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
this.loadJsonStringIntoProjectFromExternalSource(jsonString)({
  // ===========================================================================
  // External URL
  // ===========================================================================

  // TODO: Deal with error conditions, timeout, etc.
  // TODO: Maybe move xhr stuff to Util.
  // TODO: Show some sort of loading indicator.
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      return this.loadJsonStringIntoProjectFromExternalSource(jsonString);
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.getJsonStringOfProject();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.loadJsonStringIntoProject(this.current);
    return this.saveToLocalStorage();
  },
  redo: function() {}
});
```

Response:
@loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  redo: ->


Prompt:
@loadJsonStringIntoProjectFromExternalSource(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @loadJsonStringIntoProjectFromExternalSource(jsonString)
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

Response:
_setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @getJsonStringOfProject()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  redo: ->


Response:
return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0
```

Response:
if (!this.isRedoable()) {
  this.undoStack.push(this.current);
  this.current = this.redoStack.pop();
  this.loadJsonStringIntoProject(this.current);
  return this.saveToLocalStorage();
}

({
  isUndoable: function() {
    return this.undoStack.length > 0;
  },
  isRedoable: function() {
    return this.redoStack.length > 0;
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
if (!this.isRedoable()) {
  this.undoStack.push(this.current);
  this.current = this.redoStack.pop();
  this.loadJsonStringIntoProject(this.current);
  return this.saveToLocalStorage();
}

({
  isUndoable: function() {
    return this.undoStack.length > 0;
  },
  isRedoable: function() {
    return this.redoStack.length > 0;
  }
});
```

Response:
return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Prompt:
return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @loadJsonStringIntoProject(@current)
    @saveToLocalStorage()

Response:
isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Response:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.
```

Response:
var Editor,
  hasProp = {}.hasOwnProperty;

module.exports = Editor = (function() {
  class Editor {
    constructor() {
      this._setupLayout();
      this._setupSerializer();
      this._setupProject();
      this._setupRevision();
      this._parseQueryString();
    }

    _setupLayout() {
      return this.layout = new Model.Layout();
    }

    _setupProject() {
      this.loadFromLocalStorage();
      if (!this.project) {
        return this.createNewProject();
      }
    }

    _setupSerializer() {
      var builtInObjects, name, object, ref;
      builtInObjects = [];
      ref = this._builtIn();
      for (name in ref) {
        if (!hasProp.call(ref, name)) continue;
        object = ref[name];
        if (_.isFunction(object)) {
          object = object.prototype;
        }
        Util.assignId(object, name);
        builtInObjects.push(object);
      }
      return this.serializer = new Storage.Serializer(builtInObjects);
    }

    // Checks if we should load an external JSON file based on the query string
    // (the ?stuff at the end of the URL).
    _parseQueryString() {
      var parsed;
      parsed = queryString.parse(location.search);
      if (parsed.load) {
        return this.loadFromURL(parsed.load);
      }
    }

    // builtIn returns all of the built in classes and objects that are used as
    // the "anchors" for serialization and deserialization. That is, all of the
    // objects and classes which should not themselves be serialized but instead
    // be *referenced* from a serialization. When deserialized, these references
    // are then bound appropriately.
    _builtIn() {
      var builtIn;
      builtIn = _.clone(Model);
      builtIn["SpreadEnv"] = Dataflow.SpreadEnv;
      builtIn["Matrix"] = Util.Matrix;
      return builtIn;
    }

    load(jsonString) {
      var json;
      return json = JSON.parse(jsonString);
    }

  };

  // TODO: get version via build process / ENV variable?
  Editor.prototype.version = "0.4.1";

  return Editor;

}).call(this);

// TODO: If the file format changes, this will need to check the version
// and convert or fail appropriately.


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Editor,
  hasProp = {}.hasOwnProperty;

module.exports = Editor = (function() {
  class Editor {
    constructor() {
      this._setupLayout();
      this._setupSerializer();
      this._setupProject();
      this._setupRevision();
      this._parseQueryString();
    }

    _setupLayout() {
      return this.layout = new Model.Layout();
    }

    _setupProject() {
      this.loadFromLocalStorage();
      if (!this.project) {
        return this.createNewProject();
      }
    }

    _setupSerializer() {
      var builtInObjects, name, object, ref;
      builtInObjects = [];
      ref = this._builtIn();
      for (name in ref) {
        if (!hasProp.call(ref, name)) continue;
        object = ref[name];
        if (_.isFunction(object)) {
          object = object.prototype;
        }
        Util.assignId(object, name);
        builtInObjects.push(object);
      }
      return this.serializer = new Storage.Serializer(builtInObjects);
    }

    // Checks if we should load an external JSON file based on the query string
    // (the ?stuff at the end of the URL).
    _parseQueryString() {
      var parsed;
      parsed = queryString.parse(location.search);
      if (parsed.load) {
        return this.loadFromURL(parsed.load);
      }
    }

    // builtIn returns all of the built in classes and objects that are used as
    // the "anchors" for serialization and deserialization. That is, all of the
    // objects and classes which should not themselves be serialized but instead
    // be *referenced* from a serialization. When deserialized, these references
    // are then bound appropriately.
    _builtIn() {
      var builtIn;
      builtIn = _.clone(Model);
      builtIn["SpreadEnv"] = Dataflow.SpreadEnv;
      builtIn["Matrix"] = Util.Matrix;
      return builtIn;
    }

    load(jsonString) {
      var json;
      return json = JSON.parse(jsonString);
    }

  };

  // TODO: get version via build process / ENV variable?
  Editor.prototype.version = "0.4.1";

  return Editor;

}).call(this);

// TODO: If the file format changes, this will need to check the version
// and convert or fail appropriately.
```

Response:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.


Prompt:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

Response:
# Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.1"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    # TODO: If the file format changes, this will need to check the version
    # and convert or fail appropriately.


Response:
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL
```

Response:
if (json.type === "Apparatus") {
  this.project = this.serializer.dejsonify(json);
}

({
  save: function() {
    var json, jsonString;
    json = this.serializer.jsonify(this.project);
    json.type = "Apparatus";
    json.version = this.version;
    jsonString = JSON.stringify(json);
    return jsonString;
  },
  createNewProject: function() {
    return this.project = new Model.Project();
  },
  // ===========================================================================
  // Local Storage
  // ===========================================================================
  localStorageName: "apparatus",
  saveToLocalStorage: function() {
    var jsonString;
    jsonString = this.save();
    window.localStorage[this.localStorageName] = jsonString;
    return jsonString;
  },
  loadFromLocalStorage: function() {
    var jsonString;
    jsonString = window.localStorage[this.localStorageName];
    if (jsonString) {
      return this.load(jsonString);
    }
  },
  resetLocalStorage: function() {
    return delete window.localStorage[this.localStorageName];
  },
  // ===========================================================================
  // File System
  // ===========================================================================
  saveToFile: function() {
    var fileName, jsonString;
    jsonString = this.save();
    fileName = this.project.editingElement.label + ".json";
    return Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8");
  },
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {
      return this.load(jsonString);
    });
  }
});

// ===========================================================================
// External URL


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
if (json.type === "Apparatus") {
  this.project = this.serializer.dejsonify(json);
}

({
  save: function() {
    var json, jsonString;
    json = this.serializer.jsonify(this.project);
    json.type = "Apparatus";
    json.version = this.version;
    jsonString = JSON.stringify(json);
    return jsonString;
  },
  createNewProject: function() {
    return this.project = new Model.Project();
  },
  // ===========================================================================
  // Local Storage
  // ===========================================================================
  localStorageName: "apparatus",
  saveToLocalStorage: function() {
    var jsonString;
    jsonString = this.save();
    window.localStorage[this.localStorageName] = jsonString;
    return jsonString;
  },
  loadFromLocalStorage: function() {
    var jsonString;
    jsonString = window.localStorage[this.localStorageName];
    if (jsonString) {
      return this.load(jsonString);
    }
  },
  resetLocalStorage: function() {
    return delete window.localStorage[this.localStorageName];
  },
  // ===========================================================================
  // File System
  // ===========================================================================
  saveToFile: function() {
    var fileName, jsonString;
    jsonString = this.save();
    fileName = this.project.editingElement.label + ".json";
    return Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8");
  },
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {
      return this.load(jsonString);
    });
  }
});

// ===========================================================================
// External URL
```

Response:
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL


Prompt:
if json.type == "Apparatus"
      @project = @serializer.dejsonify(json)

  save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

Response:
loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL


Response:
# ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @load(jsonString)
      @checkpoint()
      Apparatus.refresh() # HACK: calling Apparatus seems funky here.
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @save()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @load(@current)
    @saveToLocalStorage()

  redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
# ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @load(jsonString)
      @checkpoint()
      Apparatus.refresh() # HACK: calling Apparatus seems funky here.
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @save()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @load(@current)
    @saveToLocalStorage()

  redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
```

Response:
// ===========================================================================

// TODO: Deal with error conditions, timeout, etc.
// TODO: Maybe move xhr stuff to Util.
// TODO: Show some sort of loading indicator.
({
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      this.load(jsonString);
      this.checkpoint();
      return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.save();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.load(this.current);
    return this.saveToLocalStorage();
  },
  redo: function() {
    if (!this.isRedoable()) {
      return;
    }
    this.undoStack.push(this.current);
    return this.current = this.redoStack.pop();
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
// ===========================================================================

// TODO: Deal with error conditions, timeout, etc.
// TODO: Maybe move xhr stuff to Util.
// TODO: Show some sort of loading indicator.
({
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      this.load(jsonString);
      this.checkpoint();
      return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.save();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.load(this.current);
    return this.saveToLocalStorage();
  },
  redo: function() {
    if (!this.isRedoable()) {
      return;
    }
    this.undoStack.push(this.current);
    return this.current = this.redoStack.pop();
  }
});
```

Response:
# ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @load(jsonString)
      @checkpoint()
      Apparatus.refresh() # HACK: calling Apparatus seems funky here.
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @save()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @load(@current)
    @saveToLocalStorage()

  redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()


Prompt:
# ===========================================================================

  # TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @load(jsonString)
      @checkpoint()
      Apparatus.refresh() # HACK: calling Apparatus seems funky here.
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.

Response:
@current = @save()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @load(@current)
    @saveToLocalStorage()

  redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()


Response:
@load(@current)
    @saveToLocalStorage()

  isUndoable: ->
    return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Prompt:
@load(@current)
    @saveToLocalStorage()

  isUndoable: ->

Response:
return @undoStack.length > 0

  isRedoable: ->
    return @redoStack.length > 0


Response:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.0"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    if json.type == "Apparatus" and json.version == @version
      @project = @serializer.dejsonify(json)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.0"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    if json.type == "Apparatus" and json.version == @version
      @project = @serializer.dejsonify(json)
```

Response:
var Editor,
  hasProp = {}.hasOwnProperty;

module.exports = Editor = (function() {
  class Editor {
    constructor() {
      this._setupLayout();
      this._setupSerializer();
      this._setupProject();
      this._setupRevision();
      this._parseQueryString();
    }

    _setupLayout() {
      return this.layout = new Model.Layout();
    }

    _setupProject() {
      this.loadFromLocalStorage();
      if (!this.project) {
        return this.createNewProject();
      }
    }

    _setupSerializer() {
      var builtInObjects, name, object, ref;
      builtInObjects = [];
      ref = this._builtIn();
      for (name in ref) {
        if (!hasProp.call(ref, name)) continue;
        object = ref[name];
        if (_.isFunction(object)) {
          object = object.prototype;
        }
        Util.assignId(object, name);
        builtInObjects.push(object);
      }
      return this.serializer = new Storage.Serializer(builtInObjects);
    }

    // Checks if we should load an external JSON file based on the query string
    // (the ?stuff at the end of the URL).
    _parseQueryString() {
      var parsed;
      parsed = queryString.parse(location.search);
      if (parsed.load) {
        return this.loadFromURL(parsed.load);
      }
    }

    // builtIn returns all of the built in classes and objects that are used as
    // the "anchors" for serialization and deserialization. That is, all of the
    // objects and classes which should not themselves be serialized but instead
    // be *referenced* from a serialization. When deserialized, these references
    // are then bound appropriately.
    _builtIn() {
      var builtIn;
      builtIn = _.clone(Model);
      builtIn["SpreadEnv"] = Dataflow.SpreadEnv;
      builtIn["Matrix"] = Util.Matrix;
      return builtIn;
    }

    load(jsonString) {
      var json;
      json = JSON.parse(jsonString);
      if (json.type === "Apparatus" && json.version === this.version) {
        return this.project = this.serializer.dejsonify(json);
      }
    }

  };

  // TODO: get version via build process / ENV variable?
  Editor.prototype.version = "0.4.0";

  return Editor;

}).call(this);


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Editor,
  hasProp = {}.hasOwnProperty;

module.exports = Editor = (function() {
  class Editor {
    constructor() {
      this._setupLayout();
      this._setupSerializer();
      this._setupProject();
      this._setupRevision();
      this._parseQueryString();
    }

    _setupLayout() {
      return this.layout = new Model.Layout();
    }

    _setupProject() {
      this.loadFromLocalStorage();
      if (!this.project) {
        return this.createNewProject();
      }
    }

    _setupSerializer() {
      var builtInObjects, name, object, ref;
      builtInObjects = [];
      ref = this._builtIn();
      for (name in ref) {
        if (!hasProp.call(ref, name)) continue;
        object = ref[name];
        if (_.isFunction(object)) {
          object = object.prototype;
        }
        Util.assignId(object, name);
        builtInObjects.push(object);
      }
      return this.serializer = new Storage.Serializer(builtInObjects);
    }

    // Checks if we should load an external JSON file based on the query string
    // (the ?stuff at the end of the URL).
    _parseQueryString() {
      var parsed;
      parsed = queryString.parse(location.search);
      if (parsed.load) {
        return this.loadFromURL(parsed.load);
      }
    }

    // builtIn returns all of the built in classes and objects that are used as
    // the "anchors" for serialization and deserialization. That is, all of the
    // objects and classes which should not themselves be serialized but instead
    // be *referenced* from a serialization. When deserialized, these references
    // are then bound appropriately.
    _builtIn() {
      var builtIn;
      builtIn = _.clone(Model);
      builtIn["SpreadEnv"] = Dataflow.SpreadEnv;
      builtIn["Matrix"] = Util.Matrix;
      return builtIn;
    }

    load(jsonString) {
      var json;
      json = JSON.parse(jsonString);
      if (json.type === "Apparatus" && json.version === this.version) {
        return this.project = this.serializer.dejsonify(json);
      }
    }

  };

  // TODO: get version via build process / ENV variable?
  Editor.prototype.version = "0.4.0";

  return Editor;

}).call(this);
```

Response:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

  # Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.0"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    if json.type == "Apparatus" and json.version == @version
      @project = @serializer.dejsonify(json)


Prompt:
module.exports = class Editor
  constructor: ->
    @_setupLayout()
    @_setupSerializer()
    @_setupProject()
    @_setupRevision()
    @_parseQueryString()

  _setupLayout: ->
    @layout = new Model.Layout()

  _setupProject: ->
    @loadFromLocalStorage()
    if !@project
      @createNewProject()

  _setupSerializer: ->
    builtInObjects = []
    for own name, object of @_builtIn()
      if _.isFunction(object)
        object = object.prototype
      Util.assignId(object, name)
      builtInObjects.push(object)
    @serializer = new Storage.Serializer(builtInObjects)

Response:
# Checks if we should load an external JSON file based on the query string
  # (the ?stuff at the end of the URL).
  _parseQueryString: ->
    parsed = queryString.parse(location.search)
    if parsed.load
      @loadFromURL(parsed.load)

  # builtIn returns all of the built in classes and objects that are used as
  # the "anchors" for serialization and deserialization. That is, all of the
  # objects and classes which should not themselves be serialized but instead
  # be *referenced* from a serialization. When deserialized, these references
  # are then bound appropriately.
  _builtIn: ->
    builtIn = _.clone(Model)
    builtIn["SpreadEnv"] = Dataflow.SpreadEnv
    builtIn["Matrix"] = Util.Matrix
    return builtIn

  # TODO: get version via build process / ENV variable?
  version: "0.4.0"

  load: (jsonString) ->
    json = JSON.parse(jsonString)
    if json.type == "Apparatus" and json.version == @version
      @project = @serializer.dejsonify(json)


Response:
save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================
```

Response:
({
  save: function() {
    var json, jsonString;
    json = this.serializer.jsonify(this.project);
    json.type = "Apparatus";
    json.version = this.version;
    jsonString = JSON.stringify(json);
    return jsonString;
  },
  createNewProject: function() {
    return this.project = new Model.Project();
  },
  // ===========================================================================
  // Local Storage
  // ===========================================================================
  localStorageName: "apparatus",
  saveToLocalStorage: function() {
    var jsonString;
    jsonString = this.save();
    window.localStorage[this.localStorageName] = jsonString;
    return jsonString;
  },
  loadFromLocalStorage: function() {
    var jsonString;
    jsonString = window.localStorage[this.localStorageName];
    if (jsonString) {
      return this.load(jsonString);
    }
  },
  resetLocalStorage: function() {
    return delete window.localStorage[this.localStorageName];
  },
  // ===========================================================================
  // File System
  // ===========================================================================
  saveToFile: function() {
    var fileName, jsonString;
    jsonString = this.save();
    fileName = this.project.editingElement.label + ".json";
    return Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8");
  },
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {
      return this.load(jsonString);
    });
  }
});

// ===========================================================================
// External URL
// ===========================================================================


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
({
  save: function() {
    var json, jsonString;
    json = this.serializer.jsonify(this.project);
    json.type = "Apparatus";
    json.version = this.version;
    jsonString = JSON.stringify(json);
    return jsonString;
  },
  createNewProject: function() {
    return this.project = new Model.Project();
  },
  // ===========================================================================
  // Local Storage
  // ===========================================================================
  localStorageName: "apparatus",
  saveToLocalStorage: function() {
    var jsonString;
    jsonString = this.save();
    window.localStorage[this.localStorageName] = jsonString;
    return jsonString;
  },
  loadFromLocalStorage: function() {
    var jsonString;
    jsonString = window.localStorage[this.localStorageName];
    if (jsonString) {
      return this.load(jsonString);
    }
  },
  resetLocalStorage: function() {
    return delete window.localStorage[this.localStorageName];
  },
  // ===========================================================================
  // File System
  // ===========================================================================
  saveToFile: function() {
    var fileName, jsonString;
    jsonString = this.save();
    fileName = this.project.editingElement.label + ".json";
    return Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8");
  },
  loadFromFile: function() {
    return Storage.loadFile((jsonString) => {
      return this.load(jsonString);
    });
  }
});

// ===========================================================================
// External URL
// ===========================================================================
```

Response:
save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]
    if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================


Prompt:
save: ->
    json = @serializer.jsonify(@project)
    json.type = "Apparatus"
    json.version = @version
    jsonString = JSON.stringify(json)
    return jsonString

  createNewProject: ->
    @project = new Model.Project()

  # ===========================================================================
  # Local Storage
  # ===========================================================================

  localStorageName: "apparatus"

  saveToLocalStorage: ->
    jsonString = @save()
    window.localStorage[@localStorageName] = jsonString
    return jsonString

  loadFromLocalStorage: ->
    jsonString = window.localStorage[@localStorageName]

Response:
if jsonString
      @load(jsonString)

  resetLocalStorage: ->
    delete window.localStorage[@localStorageName]

  # ===========================================================================
  # File System
  # ===========================================================================

  saveToFile: ->
    jsonString = @save()
    fileName = @project.editingElement.label + ".json"
    Storage.saveFile(jsonString, fileName, "application/json;charset=utf-8")

  loadFromFile: ->
    Storage.loadFile (jsonString) =>
      @load(jsonString)

  # ===========================================================================
  # External URL
  # ===========================================================================


Response:
# TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @load(jsonString)
      @checkpoint()
      Apparatus.refresh() # HACK: calling Apparatus seems funky here.
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @save()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @load(@current)
    @saveToLocalStorage()

  redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @load(@current)
    @saveToLocalStorage()


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
# TODO: Deal with error conditions, timeout, etc.
  # TODO: Maybe move xhr stuff to Util.
  # TODO: Show some sort of loading indicator.
  loadFromURL: (url) ->
    xhr = new XMLHttpRequest()
    xhr.onreadystatechange = =>
      return unless xhr.readyState == 4
      return unless xhr.status == 200
      jsonString = xhr.responseText
      @load(jsonString)
      @checkpoint()
      Apparatus.refresh() # HACK: calling Apparatus seems funky here.
    xhr.open("GET", url, true)
    xhr.send()

  # ===========================================================================
  # Revision History
  # ===========================================================================

  _setupRevision: ->
    # @current is a JSON string representing the current state. @undoStack and
    # @redoStack are arrays of such JSON strings.
    @current = @save()
    @undoStack = []
    @redoStack = []
    @maxUndoStackSize = 100

  checkpoint: ->
    jsonString = @saveToLocalStorage()
    return if @current == jsonString
    @undoStack.push(@current)
    if @undoStack.length > @maxUndoStackSize
      @undoStack.shift()
    @redoStack = []
    @current = jsonString

  undo: ->
    return unless @isUndoable()
    @redoStack.push(@current)
    @current = @undoStack.pop()
    @load(@current)
    @saveToLocalStorage()

  redo: ->
    return unless @isRedoable()
    @undoStack.push(@current)
    @current = @redoStack.pop()
    @load(@current)
    @saveToLocalStorage()
```

Response:
// TODO: Deal with error conditions, timeout, etc.
// TODO: Maybe move xhr stuff to Util.
// TODO: Show some sort of loading indicator.
({
  loadFromURL: function(url) {
    var xhr;
    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = () => {
      var jsonString;
      if (xhr.readyState !== 4) {
        return;
      }
      if (xhr.status !== 200) {
        return;
      }
      jsonString = xhr.responseText;
      this.load(jsonString);
      this.checkpoint();
      return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.
    };
    xhr.open("GET", url, true);
    return xhr.send();
  },
  // ===========================================================================
  // Revision History
  // ===========================================================================
  _setupRevision: function() {
    // @current is a JSON string representing the current state. @undoStack and
    // @redoStack are arrays of such JSON strings.
    this.current = this.save();
    this.undoStack = [];
    this.redoStack = [];
    return this.maxUndoStackSize = 100;
  },
  checkpoint: function() {
    var jsonString;
    jsonString = this.saveToLocalStorage();
    if (this.current === jsonString) {
      return;
    }
    this.undoStack.push(this.current);
    if (this.undoStack.length > this.maxUndoStackSize) {
      this.undoStack.shift();
    }
    this.redoStack = [];
    return this.current = jsonString;
  },
  undo: function() {
    if (!this.isUndoable()) {
      return;
    }
    this.redoStack.push(this.current);
    this.current = this.undoStack.pop();
    this.load(this.current);
    return this.saveToLocalStorage();
  },
  redo: function() {
    if (!this.isRedoable()) {
      return;
    }
    this.undoStack.push(this.current);
    this.current = this.redoStack.pop();
    this.load(this.current);
    return this.saveToLocalStorage();
  }
});