text: /**
   * This module contains reusable code fragments that are utilitarian or provide minor user interface
   * snippet building that is generally too simplistic for Vue components, thus a pure Javascript
   * approach was implemented.
   */
  
  "use strict";
  
  const $common = function() {
  };
  
  /**
   * Changes the first letter to uppercase and the remaining letters to lowercase.
   *
   * @param {string} string the String to capitalize
   */
  $common.capitalize = function capitalize(string) {
    if (string && string.length > 2) {
      return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
    }
    return string;
  };
  
  /**
   * Given a UNIX timestamp, this function will return a formatted date.
   * i.e. 15 Jan 2017
   */
  $common.formatTimestamp = function formatTimestamp(timestamp, includeTime) {
    let date = new Date(timestamp);
    let months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
    function pad(num) { return num < 10 ? "0" + num : num; }
    if (includeTime) {
      return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear() + " at " + pad(date.getHours()) + ":" + pad(date.getMinutes()) + ":" + pad(date.getSeconds());
    } else {
      return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear();
    }
  };
  
  /**
   * Helper function that returns the variable if it is not null, undefined, NaN,
   * an empty string (""), 0, or false. Otherwise, returns the default value.
   */
  $common.valueWithDefault = function valueWithDefault(variable, defaultValue) {
    if (variable) {
      return variable;
    } else {
      return defaultValue;
    }
  };
  
  /**
   * Converts a string representation of common boolean values and returns a boolean value.
   */
  $common.toBoolean = function(string) {
    if (!string) {
      return false;
    }
    switch(string.toLowerCase().trim()) {
      case "true": case "yes": case "1": return true;
      case "false": case "no": case "0": case null: return false;
      default: return Boolean(string);
    }
  };
  
  $common.trimToNull = function(value) {
    if (typeof value === 'undefined') {
      return null;
    } else if (typeof value === 'string' && value.trim() === "") {
      return null;
    }
    return value;
  };
  
  module.exports = {
    capitalize: $common.capitalize,
    formatTimestamp: $common.formatTimestamp,
    valueWithDefault: $common.valueWithDefault,
    toBoolean: $common.toBoolean,
    trimToNull: $common.trimToNull
  };
  