platform-helpers/object-helper.js

const lodash = require('lodash');

/**
 *
 * @static
 * @requires lodash
 */
class ObjectHelper {
  /**
   *
   * @param {*} obj
   * @returns {Object}
   */
  static sortKeysByName = (obj) => {
    const sortedObj = {};
    Object.keys(obj).sort().forEach(function (key) {
      sortedObj[key] = lodash.cloneDeep(obj[key]);
    });
    return sortedObj;
  };

  /**
   *
   * @param {*} obj
   * @returns {boolean}
   */
  static isNullOrUnderfined = (obj) => {
    return obj === null || obj === undefined;
  };

  /**
   *
   * @param {*} obj
   * @returns {boolean}
   */
  static isNullOrUnderfinedOrEmpty = (obj) => {
    return obj === null || obj === undefined || (obj.length && obj.length === 0);
  };
}
module.exports = ObjectHelper;