Less boilerplate JS to create functors

Replace:

function a(b) {
  function a(b) {
    this.x = function() { return 'x'; }
  }
  return new a(b);
}

with:

function a(b) {
  return {
    x: function() { return 'x'; }
  };
}
Fix indentation