/** 计算某个用户的未读消息数量 */
function computeUnreadNum(messages) {
  var cnt = 0;
  for (var i = 0; i < messages.length; i++) if (!messages[i].read) cnt++;
  return cnt;
}

/** 某个用户的消息是否全部已读 */
function isRead(messages) {
  for (var i = 0; i < messages.length; i++) if (!messages[i].read) return false;
  return true;
}

module.exports = {
  computeUnreadNum: computeUnreadNum,
  isRead: isRead,
};
