function strokeEndsFlatten(ratio, removeOffPts = false, { maxStroke = 10, angleTol = 20 } = {}) {
  return glyph => glyph.map(contour => {
    /** @type { number[] } */
    const ends = detectEnds(contour, { maxStroke, angleTol });
    const endTargets = ends.map(end => targetPoints(contour, end));
    const targets = [];
    ends.forEach((end, i) => {
      const [ tp2, tp3, tp4, tp5 ] = endTargets[i];
      targets[end] = tp2; 
      targets[mod(end+1, contour.length)] = tp3;
      targets[mod(end+2, contour.length)] = tp4;
      targets[mod(end+3, contour.length)] = tp5;
    });
    const result = []
    contour.forEach((pt, i) => {
      if (targets[i] === undefined) { result.push(pt); return; }
      const p = tuple(pt);
      const pr = add(mul(1-ratio, p), mul(ratio, targets[i]));
      if (removeOffPts && !pt.on) return;
      result.push({ x: pr[0], y: pr[1], on: pt.on });
    });
    return result;
  });
}
Flatten the stroke ends of the hooks and side-falling strokes
@param { number } ratio 
@param { removeOffPts } boolean
@param { { maxStroke: number, angleTol: number } } config
@returns { PostFilter }