{"version":3,"file":"index.cjs","sources":[""],"sourcesContent":["import { getRandomIntFromInterval } from \"../../num/getRandomIntFromInterval/index.ts\";\r\n\r\nexport type TGetIdArgs = Parameters<typeof getId>;\r\n\r\nexport type TGetIdReturn = ReturnType<typeof getId>;\r\n\r\n/**\r\n * Gets unique string ID.\r\n * @param length{number=} length of ID\r\n * @returns {string}\r\n * @throws {TypeError} getId: length must be a positive finite integer\r\n * @example\r\n * // How to generate unique string ID?\r\n * const uniqueId = getId(100);\n * console.log(uniqueId.length); // 100\n * @example\n * // Generate an id for linking a form label to its input\n * const inputId = `email-${getId(8)}`;\n * label.htmlFor = inputId;\n * input.id = inputId;\n */\nexport const getId = (length: number = getRandomIntFromInterval(8, 16)): string => {\n  if (typeof length !== \"number\" || !Number.isFinite(length) || length <= 0 || Math.floor(length) !== length) {\r\n    throw new TypeError(\"getId: length must be a positive finite integer\");\r\n  }\r\n\r\n  const alphabet = \"0123456789abcdefghijklmnopqrstuvwxyz\";\n  return Array.from(\n    { length },\n    () => alphabet[getRandomIntFromInterval(0, alphabet.length - 1)]\n  ).join(\"\");\n};\n"],"names":["getId","length","getRandomIntFromInterval","Number","isFinite","Math","floor","TypeError","alphabet","Array","from","join"],"mappings":"2HAqBO,MAAMA,MAAQ,CAACC,OAAiBC,MAAAA,yBAAyB,EAAG,OACjE,UAAWD,SAAW,WAAaE,OAAOC,SAASH,SAAWA,QAAU,GAAKI,KAAKC,MAAML,UAAYA,OAClG,MAAM,IAAIM,UAAU,mDAGtB,MAAMC,SAAW,uCACjB,OAAOC,MAAMC,KACX,CAAET,eACF,IAAMO,SAASN,+BAAyB,EAAGM,SAASP,OAAS,KAC7DU,KAAK"}