Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/auth/src/core/util/event_id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
* limitations under the License.
*/

/**
* Generates a unique event identifier with a customizable prefix and length.
*
* This function creates a random alphanumeric string by repeatedly generating
* random numbers and concatenating their string representations. The resulting
* event ID consists of the provided prefix followed by a randomly generated
* string of the specified number of digits.
*
* @param prefix - The string to prepend to the generated random number sequence. Defaults to an empty string.
* @param digits - The number of random digits to generate for the event ID. Defaults to 10.
* @returns A string containing the prefix followed by the randomly generated digits.
*
* @example
* ```typescript
* _generateEventId('evt_', 8); // Returns something like: 'evt_12345678'
* _generateEventId(); // Returns something like: '1234567890'
* ```
*/

export function _generateEventId(prefix = '', digits = 10): string {
let random = '';
for (let i = 0; i < digits; i++) {
Expand Down