lib/tools/index.js
function (text, options) {
    "use strict";

    var marginX     = options.marginX !== undefined ? options.marginX : 2;
    var marginY     = options.marginY !== undefined ? options.marginY : 1;
    var margin      = new Array(marginX+1).join(" ");
    var indent      = options.indent !== undefined ? options.indent :  "  ";
    var maxLength   = 0;
    var linesOfText = text.split('\n');

    var pattern = options.pattern || {
      T: "/", B: "/", TR: "//", BR: "//", TL: "//", BL: "//", R: "//", L: "//"
    };

    linesOfText.forEach(function (line) {
      maxLength = Math.max(maxLength, line.length);
    });

    var top    = pattern.TL + new Array(2 * marginX + maxLength + 1).join(pattern.T) + pattern.TR;
    var empty  = pattern.L  + new Array(2 * marginX + maxLength + 1).join(" ")       + pattern.R;
    var bottom = pattern.BL + new Array(2 * marginX + maxLength + 1).join(pattern.B) + pattern.BR;

    linesOfText = linesOfText.map(function (line) {
      while (line.length < maxLength) {
        line += " ";
      }
      return pattern.L + margin + line + margin + pattern.R;
    });

    // vertical margin
    for (var i=0; i<marginY; i++) {
      linesOfText.unshift(empty);
      linesOfText.push(empty);
    }

    // top and bottom lines
    linesOfText.unshift(top);
    linesOfText.push(bottom);

    return linesOfText.map(function (line) {
      return indent + line;
    }).join('\n');
  }
function (text, options) {
    "use strict";

    var marginX     = options.marginX !== undefined ? options.marginX : 2;
    var marginY     = options.marginY !== undefined ? options.marginY : 1;
    var margin      = new Array(marginX+1).join(" ");
    var indent      = options.indent !== undefined ? options.indent :  "  ";
    var maxLength   = 0;
    var linesOfText = text.split('\n');

    var pattern = options.pattern || {
      T: "/", B: "/", TR: "//", BR: "//", TL: "//", BL: "//", R: "//", L: "//"
    };

    linesOfText.forEach(function (line) {
      maxLength = Math.max(maxLength, line.length);
    });

    var top    = pattern.TL + new Array(2 * marginX + maxLength + 1).join(pattern.T) + pattern.TR;
    var empty  = pattern.L  + new Array(2 * marginX + maxLength + 1).join(" ")       + pattern.R;
    var bottom = pattern.BL + new Array(2 * marginX + maxLength + 1).join(pattern.B) + pattern.BR;

    linesOfText = linesOfText.map(function (line) {
      while (line.length < maxLength) {
        line += " ";
      }
      return pattern.L + margin + line + margin + pattern.R;
    });

    // vertical margin
    for (var i=0; i<marginY; i++) {
      linesOfText.unshift(empty);
      linesOfText.push(empty);
    }

    // top and bottom lines
    linesOfText.unshift(top);
    linesOfText.push(bottom);

    return linesOfText.map(function (line) {
      return indent + line;
    }).join('\n');
  }
function ( text , options ) { "use strict" ; var marginX = options . marginX !== undefined ? options . marginX : 2 ; var marginY = options . marginY !== undefined ? options . marginY : 1 ; var margin = new Array ( marginX + 1 ) . join ( " " ) ; var indent = options . indent !== undefined ? options . indent : "  " ; var maxLength = 0 ; var linesOfText = text . split ( '\n' ) ; var pattern = options . pattern || { T : "/" , B : "/" , TR : "//" , BR : "//" , TL : "//" , BL : "//" , R : "//" , L : "//" } ; linesOfText . forEach ( function ( line ) { maxLength = Math . max ( maxLength , line . length ) ; } ) ; var top = pattern . TL + new Array ( 2 * marginX + maxLength + 1 ) . join ( pattern . T ) + pattern . TR ; var empty = pattern . L + new Array ( 2 * marginX + maxLength + 1 ) . join ( " " ) + pattern . R ; var bottom = pattern . BL + new Array ( 2 * marginX + maxLength + 1 ) . join ( pattern . B ) + pattern . BR ; linesOfText = linesOfText . map ( function ( line ) { while ( line . length < maxLength ) { line += " " ; } return pattern . L + margin + line + margin + pattern . R ; } ) ; // vertical margin for ( var i = 0 ; i < marginY ; i ++ ) { linesOfText . unshift ( empty ) ; linesOfText . push ( empty ) ; } // top and bottom lines linesOfText . unshift ( top ) ; linesOfText . push ( bottom ) ; return linesOfText . map ( function ( line ) { return indent + line ; } ) . join ( '\n' ) ; }
Creates a nice banner containing the given text.

@param {object} options
Creates a nice banner containing the given text .