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

@pgds/utils

v1.1.10

Published

Provides common utils functions to be used within the pgds platform

Readme

pgds-utils

This utils package can be used for various purposes. It is a collection of utility functions that can be used in any project withing the PGDS platform.

Usage

Install pgds-utils as an npm module and save it to your package.json file as a development dependency:

npm install @pdgs/utils

Unit conversion

Converts a value between the given units or by type and measurement system.

Functions

import { getDisplayValue, convertValueByUnitAndMeasurementSystem, getDisplayUnit } from "@pgds/utils/unitConversion";

/**
 * Converts a value from one measurement system to another based on the unit.
 *
 * @param value value to convert
 * @param unit unit of the value
 * @param from measurement system of the value
 * @param to measurement system to convert to
 * @returns converted value based on the unit and measurement system
 */
convertValueByUnitAndMeasurementSystem(value: number, unit: SupportedUnit, from: MeasurementSystem, to: MeasurementSystem): number;

/**
 * @param value in the metric system
 * @param unit unit in metric system
 * @param to measurement system to convert to
 * @returns  formatted string with rounded value and unit label
 */
getDisplayValue(value: number,unit: SupportedUnit | string, to: MeasurementSystem): string;

/**
 * Returns the unit label based on the unit and measurement system.
 *
 * E.g.
 * ```
 * const unit = getDisplayUnit(SupportedUnit.Celsius, MeasurementSystem.Imperial);
 * console.log(unit); // "°F"
 *
 * const unit = getDisplayUnit(SupportedUnit.Celsius, MeasurementSystem.Metric);
 * console.log(unit); // "°C"
 *
 * const unit = getDisplayUnit("Bar", MeasurementSystem.Metric);
 * console.log(unit); // "Bar"
 * ```
 * @param unit can be SupportedUnit or custom string
 * @param measurementSystem
 * @returns the display label for the unit, if supported, otherwise returns the unit as is.
 */
getDisplayUnit(unit: SupportedUnit | string, measurementSystem: MeasurementSystem): string;

Calculations

Calculates derived values based on the state and product (derived value) capabilities. Available calculations are:

  • AbsoluteHumidity
  • MixingRatio
  • DewPoint
  • SpecificHumidity
  • Wme

Functions

import { calculateDerivedValue } from "@pgds/utils/calculations";

calculateDerivedValue(state: any, capability: any): string;

Constants

import {
  MeasurementSystem,
  SupportedDerivedValues,
  SupportedUnit,
} from "@pgds/utils/constants";

/**
 * Measurement systems used in the platform
 */
enum MeasurementSystem;

/**
 * Supported derived values that can be calculated
 */
enum SupportedDerivedValues;

/**
 * Supported units that can be converted and displayed
 */
enum SupportedUnit;

Logging

Utils for logging in a consistent manner. Will pick up the request id from the request context (by the provided useReqStore function from @pgds/api-interface) if available.

// app.ts
import { setupLogger } from "@pgds/utils/logging";
import { useReqStore } from "@pgds/api-interface";

setupLogger("things-api", { useReqStore });

// Anywhere in a service
import { logger } from "@pgds/utils/logging";

logger.info("Hello world", { hello: "world" });

Output will be:

2023-10-01T12:00:00.000Z  INFO  things-api:  Hello world  { hello: "world" } (req_id=1234567890)

configs

  • LOG_LEVEL - see https://github.com/trentm/node-bunyan?tab=readme-ov-file#levels. Default is info, meaning it will log everything from info and above (i.e. info, warn, error, fatal).

Dependencies

You need to run node version 22 or higher.

Publishing

Prerequisites:

  • You have to be part of the @hiotlabs organization on npm
  • You have to be logged in to npm

Then, in root, run:

// Check out any untracked/ignored files (e.g. previously built files) ⚠ Do not do this unless you have committed any changes you want to keep ⚠
yarn clean

// Install dependencies
yarn install

// Build
yarn build

// Make sure tests pass
yarn test

// Publish
npm publish --access public

// Or pack (for testing)
npm pack

Adding new directories to the project (@pgds/utils)

  • Create folder
  • Add index.ts file in the folder
    • This file will be responsible for exporting functions.
  • Add one entry for .js, .js.map and .d.ts for the folder to package.json's files array, e.g. utils/**/*.js, utils/**/*.js.map and utils/**/*.d.ts
  "files": [
    "**/*.d.ts",
    "./index.js",
    "lib/**/*.js",
    "lib/**/*.js.map",
    "lib/**/*.d.ts",
    "errors/**/*.js",
    "errors/**/*.js.map",
    "errors/**/*.d.ts",
    "constants/**/*.js",
    "constants/**/*.js.map",
    "constants/**/*.d.ts",
    "utils/**/*.js",
    "utils/**/*.js.map",
    "utils/**/*.d.ts"
  ],