text: "use strict";
  
  var _typeof2 = require("babel-runtime/helpers/typeof");
  
  var _typeof3 = _interopRequireDefault(_typeof2);
  
  var _stringify = require("babel-runtime/core-js/json/stringify");
  
  var _stringify2 = _interopRequireDefault(_stringify);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  Object.defineProperty(exports, "__esModule", { value: true });
  var syncerror_1 = require("./syncerror");
  /**
   * Deep-clone an object. Note that this does not work on object containing
   * functions.
   * @param {object} obj - the object to deep-clone
   * @returns {object}
   */
  function deepClone(obj) {
      return JSON.parse((0, _stringify2.default)(obj));
  }
  exports.deepClone = deepClone;
  function validateTtl(ttl, optional) {
      if (optional && ttl === undefined) {
          return;
      }
      var ttlType = typeof ttl === "undefined" ? "undefined" : (0, _typeof3.default)(ttl);
      if (ttlType !== 'number' || !isNonNegativeInteger(ttl)) {
          var providedValue = ttlType === 'object' ? 'object' : "'" + ttl + "' of type '" + ttlType + "'";
          throw new syncerror_1.default("Invalid TTL, expected a positive integer of type number, was " + providedValue, 400, 54011);
      }
  }
  function validateId(id) {
      if (id === undefined) {
          return;
      }
      var idType = typeof id === "undefined" ? "undefined" : (0, _typeof3.default)(id);
      if (idType !== 'string') {
          throw new Error("Invalid ID type, expected a string, got '" + idType + "'");
      }
  }
  exports.validateId = validateId;
  function validateOptionalTtl(ttl) {
      validateTtl(ttl, true);
  }
  exports.validateOptionalTtl = validateOptionalTtl;
  function validateMandatoryTtl(ttl) {
      validateTtl(ttl, false);
  }
  exports.validateMandatoryTtl = validateMandatoryTtl;
  function validatePageSize(pageSize) {
      var validPageSize = pageSize === undefined || isPositiveInteger(pageSize);
      if (!validPageSize) {
          throw new syncerror_1.default("Invalid pageSize parameter. Expected a positive integer, was '" + pageSize + "'.", 400, 54455);
      }
  }
  exports.validatePageSize = validatePageSize;
  function isInteger(number) {
      return !isNaN(parseInt(number)) && isFinite(number);
  }
  function isPositiveInteger(number) {
      return isInteger(number) && number > 0;
  }
  function isNonNegativeInteger(number) {
      return isInteger(number) && number >= 0;
  }