"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

/**
 * Created by baoyinghai on 1/7/17.
 */
var isEmpty = exports.isEmpty = function isEmpty(value) {
  return value === '' || value === undefined || value === null;
};

var filterEmptyValue = exports.filterEmptyValue = function filterEmptyValue(value, backValue) {
  if (isEmpty(value)) {
    return backValue;
  }
  return value;
};

/* eslint-disable */
var clone = exports.clone = function clone(item) {
  if (!item) {
    return item;
  } // null, undefined values check
  var types = [Number, String, Boolean],
      result;
  // normalizing primitives if someone did new String('aaa'), or new Number('444');
  types.forEach(function (type) {
    if (item instanceof type) {
      result = type(item);
    }
  });

  if (typeof result == "undefined") {
    if (Object.prototype.toString.call(item) === "[object Array]") {
      result = [];
      item.forEach(function (child, index, array) {
        result[index] = clone(child);
      });
    } else if ((typeof item === "undefined" ? "undefined" : _typeof(item)) == "object") {
      // testing that this is DOM
      if (item.nodeType && typeof item.cloneNode == "function") {
        var result = item.cloneNode(true);
      } else if (!item.prototype) {
        // check that this is a literal
        if (item instanceof Date) {
          result = new Date(item);
        } else {
          // it is an object literal
          result = {};
          for (var i in item) {
            result[i] = clone(item[i]);
          }
        }
      } else {
        // depending what you would like here,
        // just keep the reference, or create new object
        if (false && item.constructor) {
          // would not advice to do that, reason? Read below
          result = new item.constructor();
        } else {
          result = item;
        }
      }
    } else {
      result = item;
    }
  }

  return result;
};