src/index.js
function getStreaks(contributions) {
  const start = contributions[0].date;
  const end = contributions.slice(-1)[0].date;
  const streak = {days: 0, start: null, end: null, unmeasurable: false};
  let currentStreak = Object.assign({}, streak);
  let longestStreak = Object.assign({}, streak);
  contributions.forEach(ret => {
    if (ret.count > 0) {
      currentStreak.days += 1;
      currentStreak.end = ret.date;
      if (!currentStreak.start) {
        currentStreak.start = ret.date;
      }
      if (currentStreak.days >= longestStreak.days) {
        longestStreak = Object.assign({}, currentStreak);
      }
    } else if (ret.date !== end) {
      currentStreak = Object.assign({}, streak);
    }
  });
  if (currentStreak.start === start && currentStreak.end === end) {
    currentStreak.unmeasurable = true;
    longestStreak.unmeasurable = true;
  }
  return {currentStreak, longestStreak};
}
function getStreaks(contributions) {
  const start = contributions[0].date;
  const end = contributions.slice(-1)[0].date;
  const streak = {days: 0, start: null, end: null, unmeasurable: false};
  let currentStreak = Object.assign({}, streak);
  let longestStreak = Object.assign({}, streak);
  contributions.forEach(ret => {
    if (ret.count > 0) {
      currentStreak.days += 1;
      currentStreak.end = ret.date;
      if (!currentStreak.start) {
        currentStreak.start = ret.date;
      }
      if (currentStreak.days >= longestStreak.days) {
        longestStreak = Object.assign({}, currentStreak);
      }
    } else if (ret.date !== end) {
      currentStreak = Object.assign({}, streak);
    }
  });
  if (currentStreak.start === start && currentStreak.end === end) {
    currentStreak.unmeasurable = true;
    longestStreak.unmeasurable = true;
  }
  return {currentStreak, longestStreak};
}
function getStreaks ( contributions ) { const start = contributions [ 0 ] . date ; const end = contributions . slice ( - 1 ) [ 0 ] . date ; const streak = { days : 0 , start : null , end : null , unmeasurable : false } ; let currentStreak = Object . assign ( { } , streak ) ; let longestStreak = Object . assign ( { } , streak ) ; contributions . forEach ( ret => { if ( ret . count > 0 ) { currentStreak . days += 1 ; currentStreak . end = ret . date ; if ( ! currentStreak . start ) { currentStreak . start = ret . date ; } if ( currentStreak . days >= longestStreak . days ) { longestStreak = Object . assign ( { } , currentStreak ) ; } } else if ( ret . date !== end ) { currentStreak = Object . assign ( { } , streak ) ; } } ) ; if ( currentStreak . start === start && currentStreak . end === end ) { currentStreak . unmeasurable = true ; longestStreak . unmeasurable = true ; } return { currentStreak , longestStreak } ; }
Parse data to streak

@param {Array<{date: string, count: number}>} contributions - List of contributions
@return {{currentStreak: Streak, longestStreak: Streak}}
Parse data to streak