Created
April 28, 2016 10:06
-
-
Save thesabbir/1d05ad1170ab875d4cb1d33b245cd5d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filterFriends(friends, id, status) { | |
const nextStatus = status === 'available' ? 'unavailable' : 'available'; | |
const online = []; | |
const offlineFriends = friends.filter((friend) => { | |
if (friend.contact_uuid !== id && friend.status !== status) { | |
friend.status = nextStatus; | |
return true; | |
} | |
friend.status = status; | |
online.push(friend); | |
return false; | |
}); | |
return { | |
online, | |
offlineFriends, | |
available: online.length | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment