Skip to content

Instantly share code, notes, and snippets.

@goiblas
Created June 8, 2022 07:08
Show Gist options
  • Save goiblas/05a9f33d4d77aba251092233db9065b0 to your computer and use it in GitHub Desktop.
Save goiblas/05a9f33d4d77aba251092233db9065b0 to your computer and use it in GitHub Desktop.
function aUser() {
let user = {
id: 1,
name: "Default",
lastname: "irrelevant",
email: "irrelevant",
phone: "irrelevant",
address: "irrelevant"
}
return {
withName(name) {
user.name = name
return this
},
withEmail(email) {
user.email = email
return this
},
build() {
return user
}
}
}
const user = aUser().withName("Jesús").withEmail("jesus@gmail.com").build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment