{"size": 906, "ext": "js", "max_stars_repo_path": "lib/transform.js", "max_stars_repo_name": "demiazz/brandon", "max_stars_repo_stars_event_min_datetime": "2017-09-03T19:18:09.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-03T19:18:09.000Z", "max_issues_repo_path": "lib/transform.js", "max_issues_repo_name": "demiazz/brandon", "max_issues_repo_issues_event_min_datetime": "2017-09-03T18:17:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-08T10:12:35.000Z", "max_forks_repo_path": "lib/transform.js", "max_forks_repo_name": "demiazz/brandon", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 20.5909090909, "max_line_length": 65, "alphanum_fraction": 0.582781457}
const babel = require("babel-core");

const { browsersList } = require("./pkg");

function createBabelOptions(options = {}) {
  const result = {
    presets: [
      [
        "env",
        {
          modules: options.modules,
          targets: {
            browsers: browsersList,
            uglify: false
          },
          useBuiltIns: options.useBuiltIns ? "usage" : false
        }
      ]
    ],
    plugins: []
  };

  if (options.coverage) {
    result.plugins.push(["istanbul", { include: "src" }]);
  }

  return result;
}

function minify(code, options = {}) {
  return babel.transform(code, {
    presets: ["minify"],
    sourceFileName: options.from,
    sourceMaps: true,
    sourceMapTarget: options.to
  });
}

function transform(code, options = {}) {
  return babel.transform(code, createBabelOptions(options)).code;
}

module.exports = { createBabelOptions, minify, transform };
