UNPKG

@ehsaneha/utils

Version:

Utility functions and types

18 lines (17 loc) 859 B
/** * Generates a random string ID of a specified length using a provided set of characters. * * @function makeId * @param {number} [length=10] - Desired length of the generated ID (default is 10). * @param {string} [chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"] - Set of characters to use for generating the ID (default includes uppercase, lowercase letters, and digits). * @returns {string} - A randomly generated string ID. * * @example * makeId(); // Generates a random ID with default length (10) and character set. * makeId({ length: 5 }); // Generates a random ID of length 5. * makeId({ length: 8, chars: "ABCDEF012345" }); // Generates a random ID of length 8 using custom characters. */ export declare function makeId({ length, chars, }?: { length?: number; chars?: string; }): string;