'use strict';

/**
 * convert snake_case to camelCase
 *
 * @param str snake_case string to convert camelCase
 * @todo I am regex newbie, any man fix this with more fancy way?
 */

function isObject(any) {
  return typeof any === 'object';
}
/**
 * check any varaible is an javascript plain object
 *
 * [isPlainObject.js](https://github.com/lodash/lodash/blob/master/isPlainObject.js)
 * @param value
 */
function isPlainObject(value) {
  if (!value || !isObject(value)) {
    return false;
  }
  if (Object.getPrototypeOf(value) === null) {
    return true;
  }
  var proto = value;
  while (Object.getPrototypeOf(proto) !== null) {
    proto = Object.getPrototypeOf(proto);
  }
  return Object.getPrototypeOf(value) === proto;
}
function _extends() {
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }, _extends.apply(null, arguments);
}

var isType = {
  number: function number(candidate) {
    return typeof candidate === 'number' && !isNaN(candidate);
  },
  string: function string(candidate) {
    return typeof candidate === 'string';
  },
  integerString: function integerString(candidate) {
    return is.notEmptyString(candidate) && is.number(Number(candidate)) && /^-?\d+$/.test(candidate);
  },
  numberString: function numberString(candidate) {
    return is.notEmptyString(candidate) && is.number(Number(candidate)) && /^-?\d+(\.\d+)?$/.test(candidate);
  },
  "null": function _null(candidate) {
    return candidate === null;
  },
  undefined: /*#__PURE__*/function (_undefined) {
    function undefined$1(_x) {
      return _undefined.apply(this, arguments);
    }
    undefined$1.toString = function () {
      return _undefined.toString();
    };
    return undefined$1;
  }(function (candidate) {
    return candidate === undefined;
  }),
  nullOrUndefined: function nullOrUndefined(candidate) {
    return candidate === undefined || candidate === null;
  },
  falsy: function falsy(candidate) {
    return !candidate;
  },
  truthy: function truthy(candidate) {
    return !!candidate;
  },
  "function": function _function(candidate) {
    return typeof candidate === 'function';
  },
  object: function object(candidate) {
    return typeof candidate === 'object' && candidate !== null;
  },
  plainObject: function plainObject(candidate) {
    return isPlainObject(candidate);
  },
  array: function array(candidate) {
    return Array.isArray(candidate);
  },
  "boolean": function boolean(candidate) {
    return typeof candidate === 'boolean';
  },
  promise: function promise(p) {
    if (p !== null && typeof p === 'object' && typeof p.then === 'function' && typeof p["catch"] === 'function') {
      return true;
    }
    return false;
  }
};
var isCheck = {
  notEmptyString: function notEmptyString(candidate) {
    return isType.string(candidate) && candidate.length > 0;
  },
  emptyString: function emptyString(candidate) {
    return isType.string(candidate) && candidate.length === 0;
  },
  emptyArray: function emptyArray(candidate) {
    return isType.array(candidate) && candidate.length === 0;
  },
  notEmptyArray: function notEmptyArray(candidate) {
    return isType.array(candidate) && candidate.length > 0;
  }
};
var is = /*#__PURE__*/_extends({}, isType, isCheck);

function generateArray(size) {
  return [].concat(new Array(size).keys());
}

function padZero(number, len) {
  if (!is.number(number)) {
    return '';
  }
  return (number + '').padStart(len, '0');
}

exports.generateArray = generateArray;
exports.is = is;
exports.isPlainObject = isPlainObject;
exports.padZero = padZero;
