/**
 *  class SafetyColons
 *
 *  For JS developers who are colonfobic, concatenating JS files using
 *  the module pattern usually leads to syntax errors.
 *
 *  The `SafetyColons` processor will insert missing semicolons to the
 *  end of the file.
 *
 *  This behavior can be disabled with:
 *
 *      environment.unregisterPostprocessor('application/javascript', SafetyColons);
 **/
'use strict';


// 3rd-party
var _ = require('underscore');


// internal
var Template = require('../template');


var SafetyColons = module.exports = function SafetyColons() {
  Template.apply(this, arguments);
};


require('util').inherits(SafetyColons, Template);


SafetyColons.prototype.prepare = function () {};


SafetyColons.prototype.evaluate = function (context, locals, fn) {
  try {
    var buff = new Buffer((this.data || '').trimRight().trimLeft());

    // ";".charCodeAt(0) === 59
    if (59 !== buff.get(buff.length - 1)) {
      this.data = this.data + ";\n";
    }

    fn(null, this.data);
  } catch (err) {
    fn(err);
  }
};

@@ -787,26 +787,15 @@
 var 
-buff = new Buffer(
+data = 
 (thi
@@ -834,52 +834,19 @@
 ft()
-)
 ;%0A%0A
-    // %22;%22.charCodeAt(0) === 59%0A
     if (
 59 !
@@ -845,28 +845,25 @@
 if (
-59
+';'
  !== 
-buff.get(buff
+data%5Bdata
 .len
@@ -869,17 +869,17 @@
 ngth - 1
-)
+%5D
 ) %7B%0A    
@@ -896,21 +896,16 @@
 a = 
-this.
 data + %22
 ;%5Cn%22
@@ -900,16 +900,18 @@
 data + %22
+%5Cn
 ;%5Cn%22;%0A  

Fix SafetyColons processor