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

@codesign-eu/utils

v1.1.0

Published

Utility helpers for spatial, date/time, astronomy, and Maidenhead (QTH) grid operations used by Codesign applications.

Readme

@codesign-eu/utils

Shared TypeScript utilities for Codesign applications.

The library currently focuses on three areas:

  • date and time helpers
  • spatial / coordinate formatting helpers
  • Maidenhead (QTH) grid conversion helpers

Installation

npm install @codesign-eu/utils

Usage

import { dateTimeService, spatialService, GridLocationService, type LatLngBoundsLike } from '@codesign-eu/utils'

const day = dateTimeService.formatDay(new Date('2026-04-28T12:30:00Z'))
const parsed = dateTimeService.parseDate('20260428')

const pointLabel = spatialService.coordinatesGeoJsonToString({
  type: 'Point',
  coordinates: [21.0122, 52.2297],
})

const locator = GridLocationService.latLngToGrid(52.2297, 21.0122, 6)
const center = GridLocationService.gridToLatLng('KO02mf')

const bounds: LatLngBoundsLike = {
  getNorth: () => 54,
  getEast: () => 22,
  getSouth: () => 52,
  getWest: () => 20,
}

const viewportLocators = GridLocationService.locatorFeaturesForBounds(bounds, 4)
const locatorEnvelope = GridLocationService.gridToBounds('KO02kk')
const boundsQuery = spatialService.leafletBoundsToString(bounds)

console.log(day, parsed, pointLabel, locator, center, viewportLocators[0]?.reference, locatorEnvelope, boundsQuery)

Public API

dateTimeService

Helpers for formatting and comparing dates:

  • formatDay(date)
  • timestampToString(date, showSeconds?)
  • parseDate('YYYYMMDD')
  • daysBetweenToday(date)
  • timeAgo(date)
  • dateIsFromTheFuture(date)

spatialService

Helpers for coordinate formatting and nested coordinate structures:

  • LatLngBoundsLike
  • swapLatLng(coordinates)
  • leafletBoundsToString(boundsLike)
  • getPointFromPolygon(coordinates)
  • coordinatesGeoJsonToString(point)
  • coordinatesGeoJsonToDegreesString(point)

LatLngBoundsLike is the exported lightweight bounds contract for leafletBoundsToString.

leafletBoundsToString stays compatible with Leaflet bounds objects, but the library does not require Leaflet as a consumer dependency.

GridLocationService

Helpers for Maidenhead (QTH) locator work.

Parsing and validation:

  • isValidLocator(value) - true for a well-formed 2/4/6/8-character locator; case-insensitive, surrounding whitespace ignored
  • normalizeLocator(value) - canonical form (' ko02KK ' becomes 'KO02kk'), or null
  • getLocatorPrecision(value) - 2 | 4 | 6 | 8, or null

Conversions:

  • latLngToGrid(lat, lng, precision?) - defaults to precision 6
  • gridToLatLng(locator) - centre of the cell
  • gridToBounds(locator) - [west, south, east, north], computed without turf
  • gridToPolygon(locator) - the cell as a GeoJSON polygon
  • getGridStep(precision) - cell size in degrees

Hierarchy:

  • getLocatorParent(locator) - one precision level up, null for a 2-character field
  • getLocatorChildren(locator) - one precision level down (100, 576 and 100 respectively), empty for an 8-character locator

Viewports:

  • locatorGridsForBounds(bounds, precision) - references overlapping the bounds, aligned to the Maidenhead grid
  • countLocatorGridsForBounds(bounds, precision) - how many references the call above would return, without building them
  • locatorFeaturesForBounds(bounds, precision) - reference, centre and polygon, ready to render
  • locatorGridsForGeoJSON(feature, precision) - references that actually intersect the geometry, not just its bounding box

Supported precisions: 2, 4, 6, 8.

Functions that take a locator throw Invalid QTH locator format when the value is not one. Functions that take a precision throw Unsupported Maidenhead precision.

Two things worth knowing before rendering a grid:

  • Cell counts grow fast. An 8-character grid divides the world into 43 200 x 43 200 cells, so check countLocatorGridsForBounds before asking for the references.
  • Bounds that wrap across the antimeridian are not split. They widen to the whole longitude range.

@codesign-eu/utils/maidenhead

The locator arithmetic is also published as a subpath entry with no runtime dependencies, for consumers that need locator maths without the geometry helpers - a Node service turning a locator into a database envelope, for example:

import { gridToBounds } from '@codesign-eu/utils/maidenhead'

const [west, south, east, north] = gridToBounds('KO02kk')

The subpath exports everything listed above except gridToPolygon, locatorFeaturesForBounds and locatorGridsForGeoJSON, which need turf.

Development

npm install
npm run check

Useful commands:

npm run test
npm run build
npm run typecheck
npm run lint

Release Helpers

npm run version:patch
npm run version:minor
npm run version:major

Publishing uses prepack, so the package is rebuilt before npm publish.