code: function(index) {
  
              var segments = this.segments;
              var numSegments = segments.length;
              if (numSegments === 0) throw new Error('Path has no segments.');
  
              if (index < 0) index = numSegments + index; // convert negative indices to positive
              if (index >= numSegments || index < 0) throw new Error('Index out of range.');
  
              return segments[index];
          }
docs: Accepts negative indices. Throws an error if path has no segments. Throws an error if index is out of range.