index.js
function rayVsCircle(ray, circle) {
  var rayStart = new Vec2(ray.start);

  if (circleContainsPoint(circle.position, circle.radius, ray.start)) {
    return rayStart;
  }

  var intersections = rayLineVsCircle(ray, circle);

  if (intersections.length) {
    return rayStart.nearest(intersections.filter(within(ray)));
  } else {
    return null;
  }
}
function rayVsCircle(ray, circle) {
  var rayStart = new Vec2(ray.start);

  if (circleContainsPoint(circle.position, circle.radius, ray.start)) {
    return rayStart;
  }

  var intersections = rayLineVsCircle(ray, circle);

  if (intersections.length) {
    return rayStart.nearest(intersections.filter(within(ray)));
  } else {
    return null;
  }
}
@param {object} ray - Object that looks like
{
start: {x: number, y: number},
end: {x: number, y: number}
}

@param {object} circle - Object that looks like
{
position: {x: number, y: number},
radius: number
}

@return {object} point (x/y) where ray hits circle or null if ray doesn't hit