var parser = require('build/parse');
var transpiler = require('build/index');

module.exports = function transpiler(input, options, cb) {
  var callback, opts, promise, out;
  if (typeof options === 'function') {
    callback = options;
  } else if (typeof options === 'undefined') {
    opts = {};
  } else {
    opts = options;
    callback = cb;
  }

  if (opts.tree) {
    try {
      out = parser(input);
      promise = new Promise.resolve(out);
    } catch (error) {
      promise = Promise.reject(error);
    }
  } else {
    try {
      out = transpiler(input);
      promise = new Promise.resolve(out);
    } catch (error) {
      promise = Promise.reject(error);
    }
  }

  if (typeof callback === 'function') {
    promise
      .then(function(output) { callback(null, output); })
      .catch(callback);
    return null;
  }
  return promise;
};

@@ -11,24 +11,26 @@
  = require('
+./
 build/parse'
@@ -58,16 +58,18 @@
 equire('
+./
 build/in
@@ -414,36 +414,32 @@
 %0A      promise =
- new
  Promise.resolve

fix small errors