arePointsInside = (points, polygon) => {
  if (points.length === 0) return 0 // nothing to check

  const vertices = polygon.vertices
  if (vertices.length < 3) return 0 // nothing can be inside an empty polygon

  if (measureArea(polygon) < 0) {
    polygon = flip(polygon) // CCW is required
  }

  const sum = points.reduce((acc, point) => acc + isPointInside(point, vertices), 0)
  return sum === points.length ? 1 : 0
}
Determine if the given points are inside the given polygon.

@param {Array} points - a list of points, where each point is an array with X and Y values
@param {poly2} polygon - a 2D polygon
@return {Integer} 1 if all points are inside, 0 if some or none are inside
@alias module:modeling/geometries/poly2.arePointsInside