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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ta-interaktiv/utils

v0.3.1

Published

A collection of utility functions often used in our projects.

Readme

@ta-interaktiv/utils

A collection of utility functions often used in our projects.

Functions

useGlobalState<T>(key: string, initialValue: T | (() => T))

A React hook that mimics useState but stores state globally on the window object. This allows state to be shared across different micro-frontends or components.

Parameters:

  • key (string): A unique key to identify this piece of state in the global store
  • initialValue (T | (() => T)): The initial value for the state if not already set globally

Returns: [T, (newValue: T | ((prevValue: T) => T)) => void] - A stateful value and a function to update it

Example:

import { useGlobalState } from "@ta-interaktiv/utils";

const [globalCount, setGlobalCount] = useGlobalState('count', 0);

getStickyHeaderHeight()

Get the height of the sticky header of DISCO.

Returns: number - The height of the sticky header if it is sticky, 0 otherwise

Example:

import { getStickyHeaderHeight } from "@ta-interaktiv/utils";

const headerHeight = getStickyHeaderHeight();

scrollIntoView(element: HTMLElement, bottom?: boolean)

Scroll into view with adjustment to the sticky navigation bar.

Parameters:

  • element (HTMLElement): Element to scroll to
  • bottom (boolean, optional): If true, align the bottom of the element to the bottom of the window

Example:

import { scrollIntoView } from "@ta-interaktiv/utils";

const targetElement = document.getElementById('target');
if (targetElement) {
  scrollIntoView(targetElement, false);
}

formatNumber(number: number | string)

Format a number to a string with thousands separators. Uses comma as decimal separator and apostrophe as thousands separator for numbers above 10,000.

Parameters:

  • number (number | string): Number to format

Returns: string - Formatted number string

Example:

import { formatNumber } from "@ta-interaktiv/utils";

formatNumber(12345.67); // Returns "12'345,67"
formatNumber(123); // Returns "123"

getArticleId(overrideUrl?: string)

Get the article id from the URL by extracting the number from the last segment after the last hyphen.

Parameters:

  • overrideUrl (string, optional): Optional URL to override the current URL

Returns: number | undefined - The article ID or undefined if not found

Example:

import { getArticleId } from "@ta-interaktiv/utils";

// For URL: https://example.com/article-title-12345
getArticleId(); // Returns 12345

// With custom URL
getArticleId('https://example.com/another-article-67890'); // Returns 67890