@ssts/id
Version:
Create unique random string IDs
28 lines (26 loc) • 942 B
text/typescript
/**
* Generates a random id and returns it.
* @param {number[]} lengthArray - Default is [8, 4, 4, 4, 12]
* @param {string} characters - Default is "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
* @returns {string} id
* @throws TypeError if the lengthArray is not an array
* @throws RangeError if the lengthArray length is 0
* @throws TypeError if one of the lengthArray items is NaN
* @throws RangeError if one of the lengthArray numbers is less than 1
* @throws TypeError if the characters is not a string
* @throws RangeError if the characters length is 0
*
* @example
* import seniorID from "@ssts/id";
* const randomId = seniorID();
*
* console.log(randomId);
* // Log example: 'F5vvaP9D-4e5q-CTow-eUsx-P91RH0pph5Gy'
*/
declare const seniorID: (lengthArray?: number[], characters?: string) => string;
declare global {
interface Window {
ssts: any;
}
}
export { seniorID as default };