UNPKG

payload-authjs

Version:
18 lines (17 loc) 580 B
/** * Get user attributes from a user object based on the fields * * @param user User object * @param fields Fields to get from the user object * @returns Object with specified fields from the user object */ export const getUserAttributes = (user, fields)=>{ return fields.reduce((acc, field)=>{ if ("name" in field) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const val = user[field.name]; acc[field.name] = val; } return acc; }, {}); }; //# sourceMappingURL=getUserAttributes.js.map