Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created March 30, 2022 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/393fe888dadb25cd11461a01b2b39325 to your computer and use it in GitHub Desktop.
Save brunosabot/393fe888dadb25cd11461a01b2b39325 to your computer and use it in GitHub Desktop.
const defaultUser = { role: "user" };
const database = {
// ...
1234: { name: "Bruno", password: "0123456789abcdef", salt: "1a2b3c" }, // ...
};
function getUserFromDatabase(id) {
return database[id];
}
const { password, salt, ...user } = {
...defaultUser,
...getUserFromDatabase(1234),
};
console.log(user); // {role: "user", name: "Bruno"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment