<NME> apiInterface.js
<BEF> /*jslint indent:2, white:true, node:true, sloppy:true, browser:true */
var PromiseCompat = require('es6-promise').Promise;

var util = require('../util');
var Consumer = require('../consumer');

var ApiInterface = function(def, onMsg, emit, debug) {
  var inflight = {},
      events = null,
      emitter = null,
      reqId = 0,
      args = arguments;

  eachProp(def, function(prop, name) {
    switch(prop.type) {
      case 'property':
        //TODO(willscott): how should asynchronous properties work?
        break;
      case 'method':
        this[name] = function() {
          // Note: inflight should be registered before message is passed
          // in order to prepare for synchronous in-window pipes.
          var deferred = fdom.proxy.Deferred();
          inflight[reqId] = deferred;
          emit({
            to: id,
            action: 'method',
            type: name,
            reqId: reqId,
            value: fdom.proxy.conform(prop.value, arguments)
          });
          reqId += 1;
          return deferred.promise();
        };
        break;
      case 'event':
        if(!events) {
          handleEvents(this);
          emitter = this.emit;
          delete this.emit;
          events = {};
        }
        events[name] = prop;
        break;
    }
  }.bind(this));

          reqId: null,  // Marks this as a reckless call.
          text: streams.text,
          binary: streams.binary
        });
        // Return type is void.
      };
      break;
    case 'event':
      if(!events) {
        util.handleEvents(this);
        emitter = this.emit;
        delete this.emit;
        events = {};
      }
      events[name] = prop;
      break;
    case 'constant':
      Object.defineProperty(this, name, {
        value: Consumer.recursiveFreezeObject(prop.value),
        writable: false
      });
      break;
    }
  }.bind(this));

  onMsg(this, function(type, msg) {
    if (type === 'close') {
 */
fdom.proxy.conform = function(template, value) {
  switch(template) {
    case 'string':
      return String('') + value;
    case 'number':
      return Number(1) * value;
    case 'bool':
      return Boolean(value === true);
    case 'object':
      // TODO(willscott): Allow removal if sandboxing enforces this.
      return JSON.parse(JSON.stringify(value));
    case 'blob':
      return value instanceof Blob ? value : new Blob([]);
    case 'buffer':
      return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);
    case 'data':
      // TODO(willscott): should be opaque to non-creator.
      return value;
    case 'proxy':
      if (Array.isArray(value)) {
        return value;
      } else {
        // TODO: make proxy.
        return value;
      }
  }
  var val, i;
  if (Array.isArray(template)) {
                msg, debug));
      }
    }
  }.bind(this));

  args = Consumer.messageToPortable(
      (def.constructor && def.constructor.value) ? def.constructor.value : [],
      Array.prototype.slice.call(args, 4),
      debug);

  emit({
    type: 'construct',
    text: args.text,
    binary: args.binary
  });
};

module.exports = ApiInterface;

<MSG> linting errors picked up by jshint

<DFF> @@ -13,35 +13,35 @@ fdom.proxy.ApiInterface = function(def, onMsg, emit, id) {
 
   eachProp(def, function(prop, name) {
     switch(prop.type) {
-      case 'property':
-        //TODO(willscott): how should asynchronous properties work?
-        break;
-      case 'method':
-        this[name] = function() {
-          // Note: inflight should be registered before message is passed
-          // in order to prepare for synchronous in-window pipes.
-          var deferred = fdom.proxy.Deferred();
-          inflight[reqId] = deferred;
-          emit({
-            to: id,
-            action: 'method',
-            type: name,
-            reqId: reqId,
-            value: fdom.proxy.conform(prop.value, arguments)
-          });
-          reqId += 1;
-          return deferred.promise();
-        };
-        break;
-      case 'event':
-        if(!events) {
-          handleEvents(this);
-          emitter = this.emit;
-          delete this.emit;
-          events = {};
-        }
-        events[name] = prop;
-        break;
+    case 'property':
+      //TODO(willscott): how should asynchronous properties work?
+      break;
+    case 'method':
+      this[name] = function() {
+        // Note: inflight should be registered before message is passed
+        // in order to prepare for synchronous in-window pipes.
+        var deferred = fdom.proxy.Deferred();
+        inflight[reqId] = deferred;
+        emit({
+          to: id,
+          action: 'method',
+          type: name,
+          reqId: reqId,
+          value: fdom.proxy.conform(prop.value, arguments)
+        });
+        reqId += 1;
+        return deferred.promise();
+      };
+      break;
+    case 'event':
+      if(!events) {
+        handleEvents(this);
+        emitter = this.emit;
+        delete this.emit;
+        events = {};
+      }
+      events[name] = prop;
+      break;
     }
   }.bind(this));
 
@@ -75,29 +75,29 @@ fdom.proxy.ApiInterface = function(def, onMsg, emit, id) {
  */
 fdom.proxy.conform = function(template, value) {
   switch(template) {
-    case 'string':
-      return String('') + value;
-    case 'number':
-      return Number(1) * value;
-    case 'bool':
-      return Boolean(value === true);
-    case 'object':
-      // TODO(willscott): Allow removal if sandboxing enforces this.
-      return JSON.parse(JSON.stringify(value));
-    case 'blob':
-      return value instanceof Blob ? value : new Blob([]);
-    case 'buffer':
-      return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);
-    case 'data':
-      // TODO(willscott): should be opaque to non-creator.
+  case 'string':
+    return String('') + value;
+  case 'number':
+    return Number(1) * value;
+  case 'bool':
+    return Boolean(value === true);
+  case 'object':
+    // TODO(willscott): Allow removal if sandboxing enforces this.
+    return JSON.parse(JSON.stringify(value));
+  case 'blob':
+    return value instanceof Blob ? value : new Blob([]);
+  case 'buffer':
+    return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);
+  case 'data':
+    // TODO(willscott): should be opaque to non-creator.
+    return value;
+  case 'proxy':
+    if (Array.isArray(value)) {
       return value;
-    case 'proxy':
-      if (Array.isArray(value)) {
-        return value;
-      } else {
-        // TODO: make proxy.
-        return value;
-      }
+    } else {
+      // TODO: make proxy.
+      return value;
+    }
   }
   var val, i;
   if (Array.isArray(template)) {

{'commit': "diff --git a/src/proxy/apiInterface.js b/src/proxy/apiInterface.js\nindex eb54e29..56e22b9 100644\n--- a/src/proxy/apiInterface.js\n+++ b/src/proxy/apiInterface.js\n@@ -13,35 +13,35 @@ fdom.proxy.ApiInterface = function(def, onMsg, emit, id) {\n \n   eachProp(def, function(prop, name) {\n     switch(prop.type) {\n-      case 'property':\n-        //TODO(willscott): how should asynchronous properties work?\n-        break;\n-      case 'method':\n-        this[name] = function() {\n-          // Note: inflight should be registered before message is passed\n-          // in order to prepare for synchronous in-window pipes.\n-          var deferred = fdom.proxy.Deferred();\n-          inflight[reqId] = deferred;\n-          emit({\n-            to: id,\n-            action: 'method',\n-            type: name,\n-            reqId: reqId,\n-            value: fdom.proxy.conform(prop.value, arguments)\n-          });\n-          reqId += 1;\n-          return deferred.promise();\n-        };\n-        break;\n-      case 'event':\n-        if(!events) {\n-          handleEvents(this);\n-          emitter = this.emit;\n-          delete this.emit;\n-          events = {};\n-        }\n-        events[name] = prop;\n-        break;\n+    case 'property':\n+      //TODO(willscott): how should asynchronous properties work?\n+      break;\n+    case 'method':\n+      this[name] = function() {\n+        // Note: inflight should be registered before message is passed\n+        // in order to prepare for synchronous in-window pipes.\n+        var deferred = fdom.proxy.Deferred();\n+        inflight[reqId] = deferred;\n+        emit({\n+          to: id,\n+          action: 'method',\n+          type: name,\n+          reqId: reqId,\n+          value: fdom.proxy.conform(prop.value, arguments)\n+        });\n+        reqId += 1;\n+        return deferred.promise();\n+      };\n+      break;\n+    case 'event':\n+      if(!events) {\n+        handleEvents(this);\n+        emitter = this.emit;\n+        delete this.emit;\n+        events = {};\n+      }\n+      events[name] = prop;\n+      break;\n     }\n   }.bind(this));\n \n@@ -75,29 +75,29 @@ fdom.proxy.ApiInterface = function(def, onMsg, emit, id) {\n  */\n fdom.proxy.conform = function(template, value) {\n   switch(template) {\n-    case 'string':\n-      return String('') + value;\n-    case 'number':\n-      return Number(1) * value;\n-    case 'bool':\n-      return Boolean(value === true);\n-    case 'object':\n-      // TODO(willscott): Allow removal if sandboxing enforces this.\n-      return JSON.parse(JSON.stringify(value));\n-    case 'blob':\n-      return value instanceof Blob ? value : new Blob([]);\n-    case 'buffer':\n-      return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);\n-    case 'data':\n-      // TODO(willscott): should be opaque to non-creator.\n+  case 'string':\n+    return String('') + value;\n+  case 'number':\n+    return Number(1) * value;\n+  case 'bool':\n+    return Boolean(value === true);\n+  case 'object':\n+    // TODO(willscott): Allow removal if sandboxing enforces this.\n+    return JSON.parse(JSON.stringify(value));\n+  case 'blob':\n+    return value instanceof Blob ? value : new Blob([]);\n+  case 'buffer':\n+    return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);\n+  case 'data':\n+    // TODO(willscott): should be opaque to non-creator.\n+    return value;\n+  case 'proxy':\n+    if (Array.isArray(value)) {\n       return value;\n-    case 'proxy':\n-      if (Array.isArray(value)) {\n-        return value;\n-      } else {\n-        // TODO: make proxy.\n-        return value;\n-      }\n+    } else {\n+      // TODO: make proxy.\n+      return value;\n+    }\n   }\n   var val, i;\n   if (Array.isArray(template)) {\n", 'commit_subject': 'linting errors picked up by jshint', 'repo_name': 'freedomjs/freedom', 'committer': {'name': 'Will Scott', 'email': '875c9445a153c314133ded6fd4bbcc3267a13eea@gmail.com', 'time_sec': '1377575729', 'tz_offset': '-420', 'date': {'seconds': '1377575729'}}, 'commit_tree': '809879360886f7c3a29b0d5d4cb0ceb9b5baf7aa', 'commit_message': 'linting errors picked up by jshint\n', 'language_name': 'Shell', 'license': 'apache-2.0', 'hunks': "@@ -13,35 +13,35 @@ fdom.proxy.ApiInterface = function(def, onMsg, emit, id) {\n \n   eachProp(def, function(prop, name) {\n     switch(prop.type) {\n-      case 'property':\n-        //TODO(willscott): how should asynchronous properties work?\n-        break;\n-      case 'method':\n-        this[name] = function() {\n-          // Note: inflight should be registered before message is passed\n-          // in order to prepare for synchronous in-window pipes.\n-          var deferred = fdom.proxy.Deferred();\n-          inflight[reqId] = deferred;\n-          emit({\n-            to: id,\n-            action: 'method',\n-            type: name,\n-            reqId: reqId,\n-            value: fdom.proxy.conform(prop.value, arguments)\n-          });\n-          reqId += 1;\n-          return deferred.promise();\n-        };\n-        break;\n-      case 'event':\n-        if(!events) {\n-          handleEvents(this);\n-          emitter = this.emit;\n-          delete this.emit;\n-          events = {};\n-        }\n-        events[name] = prop;\n-        break;\n+    case 'property':\n+      //TODO(willscott): how should asynchronous properties work?\n+      break;\n+    case 'method':\n+      this[name] = function() {\n+        // Note: inflight should be registered before message is passed\n+        // in order to prepare for synchronous in-window pipes.\n+        var deferred = fdom.proxy.Deferred();\n+        inflight[reqId] = deferred;\n+        emit({\n+          to: id,\n+          action: 'method',\n+          type: name,\n+          reqId: reqId,\n+          value: fdom.proxy.conform(prop.value, arguments)\n+        });\n+        reqId += 1;\n+        return deferred.promise();\n+      };\n+      break;\n+    case 'event':\n+      if(!events) {\n+        handleEvents(this);\n+        emitter = this.emit;\n+        delete this.emit;\n+        events = {};\n+      }\n+      events[name] = prop;\n+      break;\n     }\n   }.bind(this));\n \n@@ -75,29 +75,29 @@ fdom.proxy.ApiInterface = function(def, onMsg, emit, id) {\n  */\n fdom.proxy.conform = function(template, value) {\n   switch(template) {\n-    case 'string':\n-      return String('') + value;\n-    case 'number':\n-      return Number(1) * value;\n-    case 'bool':\n-      return Boolean(value === true);\n-    case 'object':\n-      // TODO(willscott): Allow removal if sandboxing enforces this.\n-      return JSON.parse(JSON.stringify(value));\n-    case 'blob':\n-      return value instanceof Blob ? value : new Blob([]);\n-    case 'buffer':\n-      return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);\n-    case 'data':\n-      // TODO(willscott): should be opaque to non-creator.\n+  case 'string':\n+    return String('') + value;\n+  case 'number':\n+    return Number(1) * value;\n+  case 'bool':\n+    return Boolean(value === true);\n+  case 'object':\n+    // TODO(willscott): Allow removal if sandboxing enforces this.\n+    return JSON.parse(JSON.stringify(value));\n+  case 'blob':\n+    return value instanceof Blob ? value : new Blob([]);\n+  case 'buffer':\n+    return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);\n+  case 'data':\n+    // TODO(willscott): should be opaque to non-creator.\n+    return value;\n+  case 'proxy':\n+    if (Array.isArray(value)) {\n       return value;\n-    case 'proxy':\n-      if (Array.isArray(value)) {\n-        return value;\n-      } else {\n-        // TODO: make proxy.\n-        return value;\n-      }\n+    } else {\n+      // TODO: make proxy.\n+      return value;\n+    }\n   }\n   var val, i;\n   if (Array.isArray(template)) {\n", 'addition_count': 51, 'deletion_count': 51, 'src_file': 'a/src/proxy/apiInterface.js', 'tgt_file': 'b/src/proxy/apiInterface.js', 'file_extension': '.js', 'before_file': "/*jslint indent:2, white:true, node:true, sloppy:true, browser:true */\nvar PromiseCompat = require('es6-promise').Promise;\n\nvar util = require('../util');\nvar Consumer = require('../consumer');\n\nvar ApiInterface = function(def, onMsg, emit, debug) {\n  var inflight = {},\n      events = null,\n      emitter = null,\n      reqId = 0,\n      args = arguments;\n\n  eachProp(def, function(prop, name) {\n    switch(prop.type) {\n      case 'property':\n        //TODO(willscott): how should asynchronous properties work?\n        break;\n      case 'method':\n        this[name] = function() {\n          // Note: inflight should be registered before message is passed\n          // in order to prepare for synchronous in-window pipes.\n          var deferred = fdom.proxy.Deferred();\n          inflight[reqId] = deferred;\n          emit({\n            to: id,\n            action: 'method',\n            type: name,\n            reqId: reqId,\n            value: fdom.proxy.conform(prop.value, arguments)\n          });\n          reqId += 1;\n          return deferred.promise();\n        };\n        break;\n      case 'event':\n        if(!events) {\n          handleEvents(this);\n          emitter = this.emit;\n          delete this.emit;\n          events = {};\n        }\n        events[name] = prop;\n        break;\n    }\n  }.bind(this));\n\n          reqId: null,  // Marks this as a reckless call.\n          text: streams.text,\n          binary: streams.binary\n        });\n        // Return type is void.\n      };\n      break;\n    case 'event':\n      if(!events) {\n        util.handleEvents(this);\n        emitter = this.emit;\n        delete this.emit;\n        events = {};\n      }\n      events[name] = prop;\n      break;\n    case 'constant':\n      Object.defineProperty(this, name, {\n        value: Consumer.recursiveFreezeObject(prop.value),\n        writable: false\n      });\n      break;\n    }\n  }.bind(this));\n\n  onMsg(this, function(type, msg) {\n    if (type === 'close') {\n */\nfdom.proxy.conform = function(template, value) {\n  switch(template) {\n    case 'string':\n      return String('') + value;\n    case 'number':\n      return Number(1) * value;\n    case 'bool':\n      return Boolean(value === true);\n    case 'object':\n      // TODO(willscott): Allow removal if sandboxing enforces this.\n      return JSON.parse(JSON.stringify(value));\n    case 'blob':\n      return value instanceof Blob ? value : new Blob([]);\n    case 'buffer':\n      return value instanceof ArrayBuffer ? value : new ArrayBuffer(0);\n    case 'data':\n      // TODO(willscott): should be opaque to non-creator.\n      return value;\n    case 'proxy':\n      if (Array.isArray(value)) {\n        return value;\n      } else {\n        // TODO: make proxy.\n        return value;\n      }\n  }\n  var val, i;\n  if (Array.isArray(template)) {\n                msg, debug));\n      }\n    }\n  }.bind(this));\n\n  args = Consumer.messageToPortable(\n      (def.constructor && def.constructor.value) ? def.constructor.value : [],\n      Array.prototype.slice.call(args, 4),\n      debug);\n\n  emit({\n    type: 'construct',\n    text: args.text,\n    binary: args.binary\n  });\n};\n\nmodule.exports = ApiInterface;\n", 'message': 'linting errors picked up by jshint\n', 'author_name': 'Will Scott', 'lang': 'js'}