{"version":3,"file":"invite.cjs","names":[],"sources":["../src/invite.ts"],"sourcesContent":["/**\n * Calculates the integer log10 of a positive index for padding calculations.\n *\n * @param index - Index number (defaults to `0`).\n *\n * @returns Truncated log10 value.\n */\nconst log10 = (index = 0) => {\n  if (index === 0) return 0;\n  const log = Math.trunc(Math.log10(index));\n  return log;\n};\n\n/**\n * Formats a zero-padded index string based on current index and max value.\n *\n * @param index - Current index number (default 0).\n * @param max - Maximum index number (default 0).\n * @returns Padded index string.\n *\n * @see {@linkcode log10}\n */\nexport const buildIndex = (index = 0, max = 0) => {\n  if (index < 0 || max < 0) {\n    throw new Error(`index (${index}) and max (${max}) must be positive integers`);\n  }\n\n  if (index > max) {\n    throw new Error(`index (${index}) must be less than or equal to max (${max})`);\n  }\n\n  const logIndex = log10(index);\n  const logMax = log10(max);\n  const length = logMax - logIndex;\n  const zeros = '0'.repeat(length);\n  return `${zeros}${index}`;\n};\n\n/**\n * Builds a formatted test invite string with indexed prefix.\n *\n * @param invite - Invite description string.\n * @param index - Current test index (default 0).\n * @param max - Maximum index count (default 0).\n * @returns Formatted test title string.\n *\n * @see {@linkcode buildIndex}\n */\nexport const buildInvite = (invite: string, index = 0, max = 0) => {\n  const _index = buildIndex(index, max);\n  return `#${_index} => ${invite}`;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAM,SAAS,QAAQ,MAAM;CAC3B,IAAI,UAAU,GAAG,OAAO;CAExB,OADY,KAAK,MAAM,KAAK,MAAM,KAAK,CAC9B;AACX;;;;;;;;;;AAWA,MAAa,cAAc,QAAQ,GAAG,MAAM,MAAM;CAChD,IAAI,QAAQ,KAAK,MAAM,GACrB,MAAM,IAAI,MAAM,UAAU,MAAM,aAAa,IAAI,4BAA4B;CAG/E,IAAI,QAAQ,KACV,MAAM,IAAI,MAAM,UAAU,MAAM,uCAAuC,IAAI,EAAE;CAG/E,MAAM,WAAW,MAAM,KAAK;CAE5B,MAAM,SADS,MAAM,GACD,IAAI;CAExB,OAAO,GADO,IAAI,OAAO,MACX,IAAI;AACpB;;;;;;;;;;;AAYA,MAAa,eAAe,QAAgB,QAAQ,GAAG,MAAM,MAAM;CAEjE,OAAO,IADQ,WAAW,OAAO,GACjB,EAAE,MAAM;AAC1B"}