Name

sn_em_arm.EvtMgmtAlertMgmtToolBox

Description

No description available

Script

var EvtMgmtAlertMgmtToolBox = Class.create();
EvtMgmtAlertMgmtToolBox.prototype = {

  type: 'EvtMgmtAlertMgmtToolBox',

  initialize: function() {},

  /**
   * Returns true if the given argument d is considered empty
   * - The argument will be considered empty when it's one of: NaN, null, undefined, empty string (''), empty array ([]), empty object ({}) 
   * - This function doesn't consider boolean values or the number 0 as empty
   * @param d
   * @returns {boolean}
   */
  isEmpty: function(d) {
      if (this.isArray(d)) {
          return this.isEmptyArray(d);
      } else if (this.isObject(d)) {
          return this.isEmptyObject(d);
      }
      return this.isNaN(d) || this.isNull(d) || ((typeof d !== 'number') && this.isNotBoolean(d) && !d); // last condition tests empty string or undefined, but not 0 nor booleans because !0 and !false are true
  },

  /**
   * Returns true if the given argument d is NOT considered empty
   * - The argument will be considered empty when isEmpty returns false. Read isEmpty docblock for details.
   * @param d
   * @returns {boolean}
   */
  isNotEmpty: function(d) {
      return !this.isEmpty(d);
  },

  /**
   * Returns true if a given argument is an array, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isArray: function(d) {
      return Array.isArray(d);
  },

  /**
   * Returns true if a given argument is a boolean, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isBoolean: function(d) {
      return typeof d === 'boolean';
  },

  /**
   * Returns true if a given argument is not a boolean, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isNotBoolean: function(d) {
      return !this.isBoolean(d);
  },

  /**
   * Returns true if a given argument is an object, otherwise returns false
   * - This function assumes we're not interested in finding if null is a valid object
   * - This function filters out arrays and doesn't take them into account as objects
   * - To test specifically against an array, use the built-in function: "Array.isArray(d)" or the "isArray" function in this script include
   * - To test specifically against null, use the comparison d === null, or the other "isNull" function in this script include
   * @param d
   * @returns {boolean}
   */
  isObject: function(d) {
      // test against d because the type of null is object
      // test constructor because "new Boolean()" or "new String()" are also objects
      // the isNotNull(d) check is required, otherwise null is returned
      // the !isUndefined(d) check is required, otherwise undefined is returned
      return this.isNotNull(d) && !this.isUndefined(d) && (typeof(d) === 'object') && !this.isArray(d) && (d.constructor === Object);
  },

  /**
   * Returns true if a given argument is undefined, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isUndefined: function(d) {
      return typeof d === 'undefined';
  },

  /**
   * Returns true if a given argument is NaN, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isNaN: function(d) {
      return (typeof d === 'number') && isNaN(d);
  },

  /**
   * Returns true if a given argument is not NaN, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isNotNaN: function(d) {
      return !this.isNaN(d);
  },

  /**
   * Returns true if a given argument is null, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isNull: function(d) {
      return d === null;
  },

  /**
   * Returns true if a given argument is not null, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isNotNull: function(d) {
      return !this.isNull(d);
  },

  /**
   * Returns true if a given argument is an object or an array, otherwise returns false
   * @param d
   * @returns {boolean}
   */
  isObjectOrArray: function(d) {
      return this.isObject(d) || this.isArray(d);
  },

  /**
   * Returns true if a given array is empty, otherwise returns false
   * @param array
   * @returns {boolean}
   */
  isEmptyArray: function(a) {
      if (!this.isArray(a)) {
          throw this.type + ' - isEmptyArray(): Argument "a" must be an array.';
      }
      return a.length === 0;
  },

  /**
   * Returns true if a given array is not empty, otherwise returns false
   * @param array
   * @returns {boolean}
   */
  isNotEmptyArray: function(a) {
      if (!this.isArray(a)) {
          throw this.type + ' - isNotEmptyArray(): Argument "a" must be an array.';
      }
      return !this.isEmptyArray(a);
  },

  /**
   * Returns true if a given object is empty, otherwise returns false
   * - Filters out function properties and doesn't take them into account
   * - A short circuit version and the performant alternative to [Object.keys(o).length === 0]
   * @param object
   * @returns {boolean}
   */
  isEmptyObject: function(o) {
      if (!this.isObject(o)) {
          throw this.type + ' - isEmptyObject(): Argument "o" must be an object.';
      }
      var isEmpty = true;
      for (var p in o) {
          if (o.hasOwnProperty(p) && (typeof o[p] !== 'function')) {
              isEmpty = false;
              break;
          }
      }
      return isEmpty;
  },

  /**
   * Returns true if a given object has keys (1 or more)
   * @param object
   * @returns {boolean}
   */
  isNotEmptyObject: function(o) {
      if (!this.isObject(o)) {
          throw this.type + ' - isNotEmptyObject(): Argument "o" must be an object.';
      }
      return !this.isEmptyObject(o);
  },
};

Sys ID

3f418f22b74b20107c038229ce11a93a

Offical Documentation

Official Docs: