UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

17 lines 617 B
export const getUserName = (user, priority = 'username') => { if (priority === 'username' && user.username) return user.username; if (priority === 'name' && user.name) return user.name; // Fallback to the other field if priority is not available if (user.username) return user.username; if (user.name) return user.name; // Generate a fallback value based on user ID if (user.id) return "user-" + user?.id?.split("-")[0].split("").reverse().join(""); // Final fallback return "Invalid User Details"; }; //# sourceMappingURL=getUserName.js.map