Creates a unique identifier. If an ID is provided, it returns that ID;
otherwise, it generates a new ULID (Universally Unique Lexicographically Sortable Identifier).
Parameters
Optionalid: string
Optional existing ID to return. If not provided, a new ULID will be generated.
Returns string
The provided ID or a newly generated ULID.
Example
constnewId = createId(); // Returns a new ULID, e.g., "01ARZ3NDEKTSV4RRFFQ69G5FAV" constexistingId = createId("custom-id"); // Returns "custom-id"
Creates a unique identifier. If an ID is provided, it returns that ID; otherwise, it generates a new ULID (Universally Unique Lexicographically Sortable Identifier).