{"version":3,"sources":["../src/index.ts","../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport * from './id';\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { assert } from '@necto/assert';\nimport { ALPHABET } from '@necto/constants';\nimport { randomBytes } from '@necto/crypto';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(\n  length = 21,\n  charset: string[] = Array.from([\n    ...ALPHABET.LOWERCASE,\n    ...ALPHABET.CAPITALIZED\n  ])\n): string {\n  assert(length > 0, 'Length must be a positive integer.');\n\n  const randomValues: Uint8Array = randomBytes(length);\n  return Array.from(randomValues as Iterable<number>)\n    .map((value: number): string => charset[value % charset.length])\n    .join('');\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GCQA,IAAAI,EAAuB,yBACvBC,EAAyB,4BACzBC,EAA4B,yBAQrB,SAASC,EACdC,EAAS,GACTC,EAAoB,MAAM,KAAK,CAC7B,GAAG,WAAS,UACZ,GAAG,WAAS,WACd,CAAC,EACO,IACR,UAAOD,EAAS,EAAG,oCAAoC,EAEvD,IAAME,KAA2B,eAAYF,CAAM,EACnD,OAAO,MAAM,KAAKE,CAAgC,EAC/C,IAAKC,GAA0BF,EAAQE,EAAQF,EAAQ,MAAM,CAAC,EAC9D,KAAK,EAAE,CACZ","names":["index_exports","__export","id","__toCommonJS","import_assert","import_constants","import_crypto","id","length","charset","randomValues","value"]}