Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,15 @@ class Character extends Metadatable(EventEmitter) {
* @fires Character#unfollowed
*/
unfollow() {
this.following.removeFollower(this);
/**
* @event Character#unfollowed
* @param {Character} following
*/
this.emit('unfollowed', this.following);
this.following = null;
if (this.following) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a proponent of early return. So instead of wrapping the entire function body in an if, you can instead just do

if (!this.following) {
  return
}

this.following.removeFollower(this);
/**
* @event Character#unfollowed
* @param {Character} following
*/
this.emit('unfollowed', this.following);
this.following = null;
}
}

/**
Expand Down