npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mhaberler/track-parser

v0.1.0

Published

Parse GPX, KML, KMZ, GeoJSON, and IGC files into a GPS track with times.

Readme

@mhaberler/track-parser

Turn a GPX, KML, KMZ, GeoJSON, or IGC file into a named GPS line. Each point has a latitude, a longitude, a height, and a time when the file has one.

import { parseTrackBytes } from "@mhaberler/track-parser";

const { tracks, warnings } = await parseTrackBytes(bytes, "flight.gpx");

tracks is a list of { name, sourceName, coords }. A point is { lat, lon, z, t? }. z is metres above mean sea level, or null when the file has no height. t is Unix milliseconds. It is set when the file has a per-point time, or when the parser can rebuild one.

warnings is a list of German sentences for the calling UI. An empty tracks list means nothing drawable was found; the reason is in warnings.

Timed tracks

These keep a time on every point, or the parser can rebuild one.

  • GPX keeps each <time>.
  • KML and KMZ with gx:Track or <when> keep those timestamps. A KMZ is unzipped first; doc.kml wins when several KML files are inside. Hot Air stores the timed path as gx:Track and repeats it as untimed helper lines; the helper lines are dropped.
  • GeoJSON keeps coordTimes, times, or coordinateProperties.times.
  • IGC uses the B-record timestamps. Height is GPS altitude when it is present, otherwise pressure altitude. Invalid (V) fixes are dropped.
  • Ultramagic FlightPack has no point times. The document description has a start clock and a sampling period. The parser treats that clock as local time at the first point and steps forward by the period.
  • Air Navigation Pro has no point times. Departure and arrival placemark names are the endpoint instants. The parser stamps the track evenly between them and percent-decodes the track name.

Hopeless for times

Flytec Balloon KML is a LineString with altitude and no per-point time. The only clocks are minute labels on placemarks (Takeoff: 6:13, Landing: 7:35, Duration: 01:21 h, and at 7:00 on a marker). Those labels are UTC minutes. Takeoff is earlier than the first logged sample, the sampling period is absent, and the interval is not constant, so the points cannot be given faithful times. The matching IGC file has the real timestamps. Use that.

A GPX, KML, or GeoJSON line that simply has no timestamps stays untimed. The geometry is still returned.

Two fixes at the same latitude and longitude are collapsed. The later height and time are kept when the first fix omitted them. A real hover (same place, later time) stays. On a Flytec KML the landing hover collapses, because those points share a position and have no time to tell them apart.

Install

bun add @mhaberler/track-parser

Until the package is on npm, a sibling checkout works:

"@mhaberler/track-parser": "file:../track-parser"

Build the dist entry before that link is used: bun run build.

Publish

npm ships dist and this readme. dist is not in git. npm publish runs prepublishOnly, which tests and builds first. publishConfig.access is public, so the scoped name needs no extra flag.

Log in as the owner of @mhaberler, bump version in package.json, then:

npm publish --dry-run
npm publish

Develop

bun install
bun test
bun run example

bun run example serves examples/leaflet on port 5175: one file input and one polyline. Leaflet is an example dependency, not a dependency of the parser.