{"version":3,"file":"index.mjs","sources":["../../src/TypeChecker.mjs","../../src/IterableObject.mjs","../../src/AbstractBaseIterator.mjs","../../src/IteratorResponse.mjs","../../src/RangeIterator.mjs","../../src/RangeNumber.mjs","../../src/index.mjs","../../src/DateTime.mjs","../../src/Random.mjs"],"sourcesContent":["/* file: TypeChecker.mjs */\n\n/**\n * The TypeChecker class provides static methods\n * for checking data types in JavaScript.\n */\nexport default class TypeChecker {\n\n  /**\n   * Checks if the value is null.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is null,\n   *                      otherwise false.\n   */\n  static isNull(value) {\n    return value === null\n  }\n\n  /**\n   * Checks if the value is undefined.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is undefined,\n   *                      otherwise false.\n   */\n  static isUndefined(value) {\n    return value === undefined\n  }\n\n  /**\n   * Checks if the value is null or undefined.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is null or undefined,\n   *                      otherwise false.\n   */\n  static isNone(value) {\n    return value == null\n  }\n\n  /**\n   * Checks if the value is a boolean.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is a boolean,\n   *                      otherwise false.\n   */\n  static isBool(value) {\n    return typeof value === 'boolean'\n  }\n\n  /**\n   * Checks if the value is an object.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is an object,\n   *                      otherwise false.\n   */\n  static isObject(value) {\n    return value !== null\n      && typeof value === 'object'\n  }\n\n  /**\n   * Checks if the value is an array.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is an array,\n   *                      otherwise false.\n   */\n  static isArray(value) {\n    return Array.isArray(value)\n  }\n\n  /**\n   * Checks if the value is a string.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is a string,\n   *                      otherwise false.\n   */\n  static isString(value) {\n    return typeof value === 'string'\n      || value instanceof String\n  }\n\n  /**\n   * Checks if the string is empty.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the string is empty,\n   *                      otherwise false.\n   */\n  static isEmptyString(value) {\n    return TypeChecker.isString(value)\n      && value.length === 0\n  }\n\n  /**\n   * Checks if the string consists only of whitespace.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the string is empty or\n   *                      consists only of whitespace, otherwise false.\n   */\n  static isWhiteSpaceString(value) {\n    return TypeChecker.isString(value)\n      && value.trim().length === 0\n  }\n\n  /**\n   * Checks if the value is a number.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is a number,\n   *                      otherwise false.\n   */\n  static isNumber(value) {\n    return (typeof value === 'number'\n      || TypeChecker.isString(value))\n        && !isNaN(parseFloat(value))\n  }\n\n  /**\n   * Checks if the value is a function.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is a function,\n   *                      otherwise false.\n   */\n  static isFunction(value) {\n    return typeof value === 'function'\n  }\n\n  /**\n   * Checks if the value is iterable.\n   * @param {*} value - The value to check.\n   * @returns {boolean} - Returns true if the value is iterable,\n   *                      otherwise false.\n   */\n  static isIterable(value) {\n    return value != null\n      && TypeChecker.isFunction(value[Symbol.iterator])\n  }\n\n}\n","/* file: IterableObject.mjs */\n\n/**\n * Represents an iterable object.\n */\nexport default class IterableObject {\n\n  /**\n   * Creates an instance of IterableObject.\n   * @param {Function} iterator - The iterator function.\n   * @param {...*} args - Arguments to be passed to the iterator.\n   */\n  constructor(iterator, ...args) {\n    this[Symbol.iterator] = () => new iterator(...args)\n  }\n\n}\n","/* file: AbstractBaseIterator.mjs */\n\n/**\n * Abstract base class for iterators.\n */\nexport default class AbstractBaseIterator {}\n","/* file: IteratorResponse.mjs */\n\n/**\n * Represents the response of an iterator.\n */\nexport default class IteratorResponse {\n\n  /**\n   * Creates an instance of IteratorResponse.\n   * @param {*} value - The value to be returned by the iterator.\n   */\n  constructor(value) {\n    this.value = value\n    this.done = value == null\n  }\n\n}\n","/* file: RangeIterator.mjs */\n\nimport AbstractBaseIterator from './AbstractBaseIterator.mjs'\nimport IteratorResponse from './IteratorResponse.mjs'\n\n/**\n * Iterator for generating a range of numbers.\n */\nexport default class RangeIterator extends AbstractBaseIterator {\n\n  /**\n   * Creates an instance of RangeIterator.\n   * @param {number} from - The starting number of the range.\n   * @param {number} to - The ending number of the range.\n   * @param {number} step - The step value for the range.\n   */\n  constructor(from, to, step) {\n\n    super()\n\n    // Scale factor to maintain precision\n    const scaleFactor = Math.pow(10, this.#getDecimalPlaces(step))\n    from = Math.round(from * scaleFactor)\n    to = Math.round(to * scaleFactor)\n    step = Math.round(step * scaleFactor)\n\n    this.next = () => {\n      if (\n        step > 0 && from > to\n        || step < 0 && from < to\n      ) {\n        return new IteratorResponse()\n      }\n      const response = new IteratorResponse(from / scaleFactor)\n      from += step\n      return response\n    }\n  }\n\n  /**\n   * Gets the number of decimal places in a number.\n   * @param {number} num - The number to check.\n   * @returns {number} The number of decimal places.\n   */\n  #getDecimalPlaces(num) {\n    const str = num.toString()\n    const decimalIndex = str.indexOf('.')\n    return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1\n  }\n}\n","/* file: RangeNumber.mjs */\n\nimport IterableObject from './IterableObject.mjs'\nimport RangeIterator from './RangeIterator.mjs'\n\n/**\n * Class for creating a range of numbers.\n */\nexport default class RangeNumber {\n\n  /**\n   * Creates an instance of RangeNumber.\n   * @param {number} from - The starting number of the range.\n   * @param {number} to - The ending number of the range.\n   * @param {number} [step=1] - The step value for the range.\n   */\n  constructor(from, to, step = 1) {\n    this.#validateArguments(from, to, step);\n    return new IterableObject(RangeIterator, from, to, step)\n  }\n\n  /**\n   * Validates the arguments for the range.\n   * @param {number} from - The starting number of the range.\n   * @param {number} to - The ending number of the range.\n   * @param {number} step - The step value for the range.\n   * @throws {TypeError} If the arguments are not valid.\n   */\n  #validateArguments(from, to, step) {\n    if (\n      isNaN(parseFloat(from)) ||\n      isNaN(parseFloat(to)) ||\n      isNaN(parseFloat(step))\n    ) {\n      throw new TypeError('range arguments must be numeric values')\n    }\n    if (from < to && step <= 0) {\n      throw new TypeError(\"'step' must be a positive value if 'from' is less than 'to'\")\n    }\n    if (from > to && step >= 0) {\n      throw new TypeError(\"'step' must be a negative value if 'from' is greater than 'to'\")\n    }\n  }\n}\n","/* file: utils.mjs */\n\n/* imports */\nimport TypeChecker from './TypeChecker.mjs'\nimport DateTime from './DateTime.mjs'\nimport Random from './Random.mjs'\nimport RangeNumber from './RangeNumber.mjs'\n\n/* TypeChecker */\nexport const isNull             = TypeChecker.isNull\nexport const isUndefined        = TypeChecker.isUndefined\nexport const isNone             = TypeChecker.isNone\nexport const isBool             = TypeChecker.isBool\nexport const isObject           = TypeChecker.isObject\nexport const isArray            = TypeChecker.isArray\nexport const isString           = TypeChecker.isString\nexport const isEmptyString      = TypeChecker.isEmptyString\nexport const isWhiteSpaceString = TypeChecker.isWhiteSpaceString\nexport const isNumber           = TypeChecker.isNumber\nexport const isFunction         = TypeChecker.isFunction\nexport const isIterable         = TypeChecker.isIterable\n\n/* DateTime */\nexport const dateTime = DateTime.getDateTime\n\n/* Random */\nexport const random = Random.getRandom\n\n/* RangeNumber */\nexport function range(from, to, step) {\n  return new RangeNumber(from, to, step)\n}\n","/* file: DateTime.mjs */\n\n/**\n * DateTime class for working with date and time.\n */\nexport default class DateTime {\n\n  /**\n   * Gets a string representation of the date and time in the specified format.\n   *\n   * @param {Date|string} [date=new Date()] - The date to format.\n   * If a string is provided, it will be interpreted as the format.\n   * @param {string} [fmt='%y-%m-%d %h:%i:%s'] - The format in which the date will be returned.\n   * Available specifiers:\n   * - %y: year (4 digits)\n   * - %m: month (2 digits)\n   * - %d: day (2 digits)\n   * - %h: hours (2 digits)\n   * - %i: minutes (2 digits)\n   * - %s: seconds (2 digits)\n   *\n   * @returns {string} A string representing the date and time in the specified format.\n   *\n   * @example\n   * // Returns the current date and time in the format 'YYYY-MM-DD HH:mm:ss'\n   * DateTime.getDateTime();\n   *\n   * @example\n   * // Returns the date in the format 'DD-MM-YYYY'\n   * DateTime.getDateTime(new Date(), '%d-%m-%Y');\n   */\n  static getDateTime(\n    date = new Date(),\n    fmt = '%y-%m-%d %h:%i:%s'\n  ) {\n\n    const normalize = (n) => n.toString().padStart(2, '0')\n\n    if (\n      arguments.length === 1\n        && typeof date === 'string'\n    ) {\n      fmt = date\n      date = new Date()\n    }\n\n    const y = date.getFullYear()\n    const m = normalize(date.getMonth() + 1)\n    const d = normalize(date.getDate())\n    const h = normalize(date.getHours())\n    const i = normalize(date.getMinutes())\n    const s = normalize(date.getSeconds())\n\n    return fmt\n      .replaceAll(/%y/g, y)\n      .replaceAll(/%m/g, m)\n      .replaceAll(/%d/g, d)\n      .replaceAll(/%h/g, h)\n      .replaceAll(/%i/g, i)\n      .replaceAll(/%s/g, s)\n  }\n\n}\n","/* file: Random.mjs */\n\n/**\n * A utility class for generating random numbers.\n */\nexport default class Random {\n\n  /**\n   * Generates a random integer between minimum and maximum values.\n   *\n   * @param {number} min - The minimum value (inclusive).\n   * @param {number} max - The maximum value (inclusive).\n   * @returns {number} A random integer between min and max.\n   *\n   * @example\n   * // Returns a random integer between 1 and 10\n   * const randomNumber = Random.getRandom(1, 10)\n   *\n   * @example\n   * // Returns a random integer between 0 and 100\n   * const anotherRandomNumber = Random.getRandom(0, 100)\n   */\n  static getRandom(min, max) {\n    return min + Math.trunc(\n      Math.random() * (max - min + 1))\n  }\n\n  /**\n   * Generates a seedable random number generator.\n   *\n   * @todo Implement the seedable random number generator.\n   */\n  static getSeedableRandom() {\n    // @todo\n  }\n\n}\n"],"names":["TypeChecker","isNull","value","isUndefined","undefined","isNone","isBool","isObject","isArray","Array","isString","String","isEmptyString","length","isWhiteSpaceString","trim","isNumber","isNaN","parseFloat","isFunction","isIterable","Symbol","iterator","IterableObject","constructor","args","this","AbstractBaseIterator","IteratorResponse","done","RangeIterator","from","to","step","super","scaleFactor","Math","pow","getDecimalPlaces","round","next","response","num","str","toString","decimalIndex","indexOf","RangeNumber","validateArguments","TypeError","dateTime","getDateTime","date","Date","fmt","normalize","n","padStart","arguments","y","getFullYear","m","getMonth","d","getDate","h","getHours","i","getMinutes","s","getSeconds","replaceAll","random","getRandom","min","max","trunc","getSeedableRandom","range"],"mappings":"AAMe,MAAMA,EAQnB,aAAOC,CAAOC,GACZ,OAAiB,OAAVA,CACX,CAQE,kBAAOC,CAAYD,GACjB,YAAiBE,IAAVF,CACX,CAQE,aAAOG,CAAOH,GACZ,OAAgB,MAATA,CACX,CAQE,aAAOI,CAAOJ,GACZ,MAAwB,kBAAVA,CAClB,CAQE,eAAOK,CAASL,GACd,OAAiB,OAAVA,GACe,iBAAVA,CAChB,CAQE,cAAOM,CAAQN,GACb,OAAOO,MAAMD,QAAQN,EACzB,CAQE,eAAOQ,CAASR,GACd,MAAwB,iBAAVA,GACTA,aAAiBS,MAC1B,CAQE,oBAAOC,CAAcV,GACnB,OAAOF,EAAYU,SAASR,IACN,IAAjBA,EAAMW,MACf,CAQE,yBAAOC,CAAmBZ,GACxB,OAAOF,EAAYU,SAASR,IACC,IAAxBA,EAAMa,OAAOF,MACtB,CAQE,eAAOG,CAASd,GACd,OAAyB,iBAAVA,GACVF,EAAYU,SAASR,MAClBe,MAAMC,WAAWhB,GAC7B,CAQE,iBAAOiB,CAAWjB,GAChB,MAAwB,mBAAVA,CAClB,CAQE,iBAAOkB,CAAWlB,GAChB,OAAgB,MAATA,GACFF,EAAYmB,WAAWjB,EAAMmB,OAAOC,UAC7C,EChIe,MAAMC,EAOnB,WAAAC,CAAYF,KAAaG,GACvBC,KAAKL,OAAOC,UAAY,IAAM,IAAIA,KAAYG,EAClD,ECTe,MAAME,GCAN,MAAMC,EAMnB,WAAAJ,CAAYtB,GACVwB,KAAKxB,MAAQA,EACbwB,KAAKG,KAAgB,MAAT3B,CAChB,ECNe,MAAM4B,UAAsBH,EAQzC,WAAAH,CAAYO,EAAMC,EAAIC,GAEpBC,QAGA,MAAMC,EAAcC,KAAKC,IAAI,GAAIX,MAAKY,EAAkBL,IACxDF,EAAOK,KAAKG,MAAMR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