// Generated by CoffeeScript 1.3.3

/*
NOTES:
Instanceof is often broken and doesn't return the right value
For instance it does not work in node virtual machines
*/


(function() {
  var balUtilTypes;

  balUtilTypes = {
    toString: function(value) {
      return Object.prototype.toString.call(value);
    },
    getType: function(value) {
      var result, type, _i, _len, _ref;
      result = 'object';
      _ref = ['Array', 'RegExp', 'Date', 'Function', 'Boolean', 'Number', 'Error', 'String', 'Null', 'Undefined'];
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        type = _ref[_i];
        if (balUtilTypes['is' + type](value)) {
          result = type.toLowerCase();
          break;
        }
      }
      return result;
    },
    isPlainObject: function(value) {
      return balUtilTypes.isObject(value) && value.__proto__ === Object.prototype;
    },
    isObject: function(value) {
      return value && typeof value === 'object';
    },
    isError: function(value) {
      return value instanceof Error;
    },
    isDate: function(value) {
      return balUtilTypes.toString(value) === '[object Date]';
    },
    isArguments: function(value) {
      return balUtilTypes.toString(value) === '[object Arguments]';
    },
    isFunction: function(value) {
      return balUtilTypes.toString(value) === '[object Function]';
    },
    isRegExp: function(value) {
      return balUtilTypes.toString(value) === '[object RegExp]';
    },
    isArray: function(value) {
      if (Array.isArray != null) {
        return Array.isArray(value);
      } else {
        return balUtilTypes.toString(value) === '[object Array]';
      }
    },
    isNumber: function(value) {
      return typeof value === 'number' || balUtilTypes.toString(value) === '[object Number]';
    },
    isString: function(value) {
      return typeof value === 'string' || balUtilTypes.toString(value) === '[object String]';
    },
    isBoolean: function(value) {
      return value === true || value === false || balUtilTypes.toString(value) === '[object Boolean]';
    },
    isNull: function(value) {
      return value === null;
    },
    isUndefined: function(value) {
      return typeof value === 'undefined';
    },
    isEmpty: function(value) {
      return value != null;
    }
  };

  if (typeof module !== "undefined" && module !== null) {
    module.exports = balUtilTypes;
  } else {
    this.balUtilTypes = balUtilTypes;
  }

}).call(this);
