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

@gml/truewind

v2.0.3

Published

Modern ES6+ library for apparent to true wind calculation in sailing applications.

Readme

TrueWind

npm version License: MIT

A modern ES6+ library for converting apparent wind to true wind in sailing applications. This library performs accurate nautical calculations including wind speed/angle conversions, leeway corrections, and current calculations.

Features

  • 🌊 Accurate Wind Calculations: Convert apparent wind to true wind with precision
  • Modern ES6+ Syntax: Uses modern JavaScript features and ES modules
  • 📐 Attitude Corrections: Compensates for boat pitch and roll
  • 🧭 Leeway Calculations: Accounts for boat drift due to wind pressure
  • 📏 Height Corrections: Adjusts wind speed from sensor height to standard 10m reference
  • 🔧 TypeScript Support: Full TypeScript definitions included
  • 🧪 Well Tested: Comprehensive test suite with Vitest
  • 📦 Tree Shakeable: ES modules for optimal bundling

Installation

npm install @gml/truewind

Usage

ES6 Modules (Recommended)

import TrueWind from '@gml/truewind';

const result = TrueWind.getTrue({
  aws: 5.1, // Apparent wind speed (m/s)
  awa: 34, // Apparent wind angle (deg, -180 to 180)
  bspd: 3.0, // Boat speed as measured (m/s)
  sog: 2.9, // Speed over ground (m/s)
  cog: 14, // Course over ground (deg true)
  heading: 8, // Boat heading (deg magnetic, including deviation)
  variation: 5, // Magnetic variation (deg)
  roll: -5, // Boat heeling (deg, - to port, + to starboard) [optional]
  pitch: -2, // Boat pitch (deg, - bow up, + bow down) [optional]
  K: 10, // Leeway coefficient [optional]
  sensorHeight: 26, // Height of wind sensor (meters) [optional]
  heightCorrectionMethod: 'log' // Height correction method ('log' or 'power') [optional]
});

console.log(result);

CommonJS (Legacy)

// Default import (recommended)
const TrueWind = require('@gml/truewind').default;

// Or named import
const { TrueWind } = require('@gml/truewind');

// Same usage as above

TypeScript

import TrueWind, { TrueWindInput, TrueWindResult } from '@gml/truewind';

const input: TrueWindInput = {
  aws: 5.1, // m/s
  awa: 34,
  bspd: 3.0, // m/s
  heading: 8
  // ... other parameters
};

const result: TrueWindResult = TrueWind.getTrue(input);

Output

The getTrue method returns an object with the following properties:

{
  awa: 34.09,      // Apparent wind angle (corrected, degrees)
  aws: 5.15,       // Apparent wind speed (corrected, m/s)
  leeway: -1.44,   // Leeway angle (degrees)
  stw: 3.03,       // Speed through water (m/s)
  vmg: 1.09,       // Velocity made good (m/s)
  tws: 3.21,       // True wind speed (m/s, height-corrected to 10m if sensorHeight provided)
  twa: 67.42,      // True wind angle (degrees)
  twd: 80.42,      // True wind direction (degrees)
  soc: 0.65,       // Speed over current (m/s)
  doc: 116.85      // Direction over current (degrees)
}

API Reference

TrueWind.getTrue(input)

Calculate true wind from apparent wind and boat parameters.

Parameters:

  • input (Object): Input parameters (see TrueWindInput interface)

Returns:

  • Object with calculated wind data (see TrueWindResult interface)

Required Parameters:

  • aws: Apparent wind speed (m/s)
  • awa: Apparent wind angle (degrees, -180 to 180)
  • bspd: Boat speed over water (m/s)
  • heading: Boat heading (degrees magnetic)

Optional Parameters:

  • variation: Magnetic variation (default: 0)
  • sog: Speed over ground (m/s, falls back to bspd if not provided)
  • cog: Course over ground (falls back to heading if not provided)
  • roll: Roll angle for attitude correction
  • pitch: Pitch angle for attitude correction
  • K: Leeway coefficient
  • sensorHeight: Height of wind sensor in meters (for height correction)
  • heightCorrectionMethod: Height correction method - either 'log' (log-law with z0=0.005m) or 'power' (power-law with α=0.11)

TrueWind.getAttitudeCorrections(src)

Apply pitch and roll corrections to wind measurements.

Development

Setup

npm install

Available Scripts

npm test              # Run tests
npm run test:watch    # Run tests in watch mode
npm run test:coverage # Run tests with coverage
npm run lint          # Lint code
npm run lint:fix      # Fix linting issues
npm run format        # Format code with Prettier
npm run format:check  # Check code formatting
npm run build         # Build for distribution

Requirements

  • Node.js >=16.0.0

Mathematical Background

This library implements established nautical calculation methods from these sources:

Migration from v1.x

Version 2.0 introduces breaking changes:

  1. ES Modules: Now uses ES modules by default. Use the CommonJS build if needed.
  2. Node.js 16+: Minimum Node.js version increased to 16.0.0
  3. Error Handling: Throws proper Error objects instead of strings
  4. Modern Syntax: Uses modern JavaScript features (const/let, arrow functions, etc.)

License

MIT - see LICENSE file for details.

Credits

Special thanks to the original authors whose work made this library possible:

  • King Tide Sailing blog contributors
  • Sailboat Instruments blog contributors