var _ = require('underscore');
var Base = require('./base');
var CartoError = require('../error');

// Event constants
var CONTENT_CHANGED = 'contentChanged';

/**
 * A CartoCSS/TurboCarto style that can be applied to a {@link carto.layer.Layer}.
 * @param {string} cartocss CartoCSS
 * @example
 * var style = new carto.style.CartoCSS(`
 *   #layer {
 *     marker-fill: #FABADA;
 *     marker-width: 10;
 *   }
 * `);
 * @constructor
 * @extends carto.style.Base
 * @memberof carto.style
 * @api
 */
function CartoCSS (cartoCSS) {
  _checkContent(cartoCSS);
  this._content = cartoCSS;
}

CartoCSS.prototype = Object.create(Base.prototype);

/**
 * Get the current CartoCSS/TurboCarto style as a string.
 * 
 * @return {string} - The TurboCarto style for this CartoCSS object
 * @api
 */
CartoCSS.prototype.getContent = function () {
  return this._content;
};

/**
 * Get the current CartoCSS/TurboCarto style as a string.
 * 
 * @return {string} - The TurboCarto style for this CartoCSS object
 * @api
 */
CartoCSS.prototype.getStyle = function () {
  return this.getContent();
};

/**
 * Set the CartoCSS/Turbocarto as a string.
 * 
 * @param {string} newContent - A string containing the new cartocss/turbocarto style
 * @return {Promise<string>} A promise that will be resolved once the cartocss/turbocarto is updated
 * @fires 
 * @api
 */
CartoCSS.prototype.setContent = function (newContent) {
  var self = this;
  _checkContent(newContent);
  this._content = newContent;
  // Notify layers that the style has been changed so they can update their internalModels.
  this.trigger('$changed', this);
  if (!this._engine) {
    return _onContentChanged.call(this, newContent);
  }

  return this._engine.reload().then(function () {
    return _onContentChanged.call(self, newContent);
  }).catch(function (windshaftError) {
    return Promise.reject(new CartoError(windshaftError));
  });
};

// Once the reload cycle is completed trigger a contentChanged event.
function _onContentChanged (newContent) {
  this.trigger(CONTENT_CHANGED, this._content);
  return Promise.resolve(this._content);
}

function _checkContent (content) {
  if (!content) {
    throw new TypeError('cartoCSS is required.');
  }

  if (!_.isString(content)) {
    throw new Error('cartoCSS must be a string.');
  }
}

module.exports = CartoCSS;

@@ -260,23 +260,24 @@
 tring%7D c
-artocss
+ontent A
  CartoCS
@@ -277,16 +277,24 @@
 CartoCSS
+ string 
 %0A * @exa
@@ -524,23 +524,22 @@
 toCSS (c
-artoCSS
+ontent
 ) %7B%0A  _c
@@ -551,23 +551,22 @@
 ontent(c
-artoCSS
+ontent
 );%0A  thi
@@ -579,23 +579,22 @@
 tent = c
-artoCSS
+ontent
 ;%0A%7D%0A%0ACar

Rename parameter