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

uddf2js

v1.0.0

Published

Convert UDDF to an easy to use JS format and handle unit conversions

Readme

uddf2js

CI

Parse UDDF XML dive logs to JavaScript objects with optional unit conversion.

Features

  • Parses UDDF (Universal Dive Data Format) XML files
  • Returns raw SI values by default, with optional metric/imperial conversion
  • Always returns arrays for repetitiongroup, dive, and samples.waypoint
  • Validates inputs and throws explicit errors for invalid XML/unit inputs
  • Robust against missing sections

Installation

npm install uddf2js

Usage (conversion optional)

const { parseUDDF } = require('uddf2js');
const fs = require('fs');

const xmlData = fs.readFileSync('mydive.uddf', 'utf8');

// Convert to metric
parseUDDF(xmlData, 'metric').then(result => {
  console.log(result.unit); // 'metric'
  const waypoint = result.data.uddf.profiledata.repetitiongroup[0].dive[0].samples.waypoint[0];
  console.log(waypoint.depth); // meters
});

// No conversion: raw SI as stored in UDDF
parseUDDF(xmlData).then(result => {
  console.log(result.unit); // 'si'
  const waypoint = result.data.uddf.profiledata.repetitiongroup[0].dive[0].samples.waypoint[0];
  console.log(waypoint.depth); // often string from XML, e.g. '10'
});

Waypoint Array Guarantee

samples.waypoint is always an array, even when only one waypoint exists in the XML.

const singleWaypointXml = `<?xml version="1.0" encoding="utf-8"?>
<uddf>
  <profiledata>
    <repetitiongroup>
      <dive>
        <samples>
          <waypoint><depth>10</depth></waypoint>
        </samples>
      </dive>
    </repetitiongroup>
  </profiledata>
</uddf>`;

const result = await parseUDDF(singleWaypointXml);
console.log(Array.isArray(result.data.uddf.profiledata.repetitiongroup[0].dive[0].samples.waypoint)); // true

Unit Options (when conversion is requested)

  • 'si' (default): raw SI values from UDDF (no conversion pass)
  • 'metric': Celsius, liters, meters, bar
    • seconds are not converted to minutes
  • 'imperial': Fahrenheit, cubic feet, feet, PSI
    • seconds are converted to minutes, but if it's between 1 and 59 seconds, it will be a string like '0:ss'

API

parseUDDF(xmlData, unit)

  • xmlData: String containing UDDF XML
  • unit: 'si' | 'metric' | 'imperial' (optional)
    • omit or pass 'si': no conversion pass
    • pass 'metric' or 'imperial': convert supported numeric fields
  • Returns: Promise resolving to { unit, data }

Errors

  • Throws TypeError when xmlData is missing/empty.
  • Throws RangeError when unit is not one of 'si' | 'metric' | 'imperial'.
  • Throws Error prefixed with Failed to parse UDDF XML: for parse failures.

Quality Gates

  • npm run lint: ESLint static checks (0 warnings allowed)
  • npm run typecheck: strict TypeScript checks
  • npm test: unit/integration tests
  • npm run security: production dependency vulnerability check
  • npm run verify:version: requires a package.json version bump when publish-impacting files change (CI PR gate)
  • Git pre-commit hook: runs lint-staged, typecheck, and tests before commits

License

MIT