@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
21 lines • 752 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUserName = void 0;
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";
};
exports.getUserName = getUserName;
//# sourceMappingURL=getUserName.js.map