code: function(p, opt) {
  
              var segments = this.segments;
              var numSegments = segments.length;
              if (numSegments === 0) return null; // if segments is an empty array
  
              opt = opt || {};
              var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
              var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;
              // not using localOpt
  
              var closestPointT;
              var minSquaredDistance = Infinity;
              for (var i = 0; i < numSegments; i++) {
  
                  var segment = segments[i];
                  var subdivisions = segmentSubdivisions[i];
  
                  if (segment.isVisible) {
                      var segmentClosestPointT = segment.closestPointT(p, { precision: precision, subdivisions: subdivisions });
                      var segmentClosestPoint = segment.pointAtT(segmentClosestPointT);
                      var squaredDistance = (new Line(segmentClosestPoint, p)).squaredLength();
  
                      if (squaredDistance < minSquaredDistance) {
                          closestPointT = { segmentIndex: i, value: segmentClosestPointT };
                          minSquaredDistance = squaredDistance;
                      }
                  }
              }
  
              if (closestPointT) return closestPointT;
  
              // if no visible segment, return end of last segment
              return { segmentIndex: numSegments - 1, value: 1 };
          }
docs: Private function.