UNPKG

@obstinado/gpx-builder

Version:
33 lines (27 loc) 518 B
'use strict'; class Segment { /** * @see http://www.topografix.com/gpx/1/1/#type_trksegType */ constructor(trkpt, extensions = null) { this.trkpt = trkpt; this.extensions = extensions || null; } setPoints(trkpt) { this.trkpt = trkpt; return this; } toObject() { const { trkpt, extensions } = this; return { trkpt: trkpt.map(point => point.toObject()), ...(extensions ? { extensions } : {}) }; } } module.exports = Segment;