// Generated by CoffeeScript 1.7.0
(function() {
  var Adapter, MinifyJS, W, _,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  Adapter = require('../adapter_base');

  W = require('when');

  _ = require('lodash');

  MinifyJS = (function(_super) {
    var compile;

    __extends(MinifyJS, _super);

    function MinifyJS(compiler) {
      this.compiler = compiler;
      this.name = 'minify-js';
      this.extensions = ['js'];
      this.output = 'js';
    }

    MinifyJS.prototype._render = function(str, options) {
      return compile((function(_this) {
        return function() {
          return _this.compiler.minify(str, _.extend(options, {
            fromString: true
          })).code;
        };
      })(this));
    };

    compile = function(fn) {
      var err, res;
      try {
        res = fn();
      } catch (_error) {
        err = _error;
        return W.reject(err);
      }
      return W.resolve(res);
    };

    return MinifyJS;

  })(Adapter);

  module.exports = MinifyJS;

}).call(this);
