<commit_before>import React from 'react'

import UserName from './user-name'
import {preventDefault} from '../utils'

const renderLike = (user) => (
  <li className="p-timeline-user-like" key={user.id}>
    <UserName user={user}/>
    <span>,&#32;</span>
  </li>
)

const renderLastLike = (user, omittedLikes = 0, showMoreLikes = null) => (
  <li className="p-timeline-user-like" key={user.id}>
    <UserName user={user}/>
    <span>
    { omittedLikes > 0 ? (
      <span>
        &nbsp;and&nbsp;
        <a onClick={preventDefault(showMoreLikes)}>
          {omittedLikes} other people
        </a>
      </span>
    ) : false }
    &nbsp;liked this
    </span>
  </li>
)

export default ({likes, showMoreLikes, post}) => {
  const hasLikes = likes.length > 0
  const _showMoreLikes = () => showMoreLikes(post.id)
  const likes_exclude_last = likes.slice(0, likes.length - 1).map(renderLike)
  const last = hasLikes && likes[likes.length - 1]
  const rendered_last = last ? renderLastLike(last, post.omittedLikes, _showMoreLikes) : false

  const rendered_likes = rendered_last ? [...likes_exclude_last, rendered_last] : likes_exclude_last

  return (hasLikes ? (
    <div className="likes">
      <i className="fa fa-heart icon"></i>
      <ul className="p-timeline-user-likes">
        {rendered_likes}
      </ul>
    </div>
  ) : <div/>)
}
<commit_msg>Implement proper "and" in the list of likes<commit_after>import React from 'react'

import UserName from './user-name'
import {preventDefault} from '../utils'

const renderLike = (item, i, items) => (
  <li key={item.id}>
    {item.id !== 'more-likes' ? (
      <UserName user={item}/>
    ) : (
      <a onClick={preventDefault(item.showMoreLikes)}>{item.omittedLikes} other people</a>
    )}

    {i < items.length - 2 ? (
      <span>, </span>
    ) : i === items.length - 2 ? (
      <span> and </span>
    ) : (
      <span> liked this</span>
    )}
  </li>
)

export default ({likes, showMoreLikes, post}) => {
  if (!likes.length) {
    return <div/>
  }

  const likeList = likes

  if (post.omittedLikes) {
    likeList.push({
      id: 'more-likes',
      omittedLikes: post.omittedLikes,
      showMoreLikes: () => showMoreLikes(post.id)
    })
  }

  const renderedLikes = likeList.map(renderLike)

  return (
    <div className="likes">
      <i className="fa fa-heart icon"></i>
      <ul>{renderedLikes}</ul>
    </div>
  )
}

{'fraction_non_alphanumeric': 0.16631929970821174, 'fraction_numerical': 0.004168403501458941, 'mean_word_length': 2.902439024390244, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4486564', 'n_tokens_mistral': 863, 'n_tokens_neox': 843, 'n_words': 182}