@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
23 lines • 902 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUserName = void 0;
var getUserName = function (user, priority) {
var _a;
if (priority === void 0) { 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-" + ((_a = user === null || user === void 0 ? void 0 : user.id) === null || _a === void 0 ? void 0 : _a.split("-")[0].split("").reverse().join(""));
// Final fallback
return "Invalid User Details";
};
exports.getUserName = getUserName;
//# sourceMappingURL=getUserName.js.map