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

@vettvangur/vanilla

v0.0.62

Published

Vettvangur | Vanilla JS Utility Library

Readme

@vettvangur/vanilla

Tree-shakeable utility library used across Vettvangur projects. Functions are grouped by concern and re-exported under sub-paths so consumers only pull in what they need.

Install

pnpm add @vettvangur/vanilla

Imports

import { fetcher, dictionary } from '@vettvangur/vanilla'

import { clickOutside, preloadTimeout } from '@vettvangur/vanilla/dom'
import { capitalize, getCulture } from '@vettvangur/vanilla/string'
import { fetcher, flatten, regexr } from '@vettvangur/vanilla/data'
import { loadEnvFiles, getUmbracoData } from '@vettvangur/vanilla/server'

| Sub-path | Surface | | --- | --- | | @vettvangur/vanilla | Everything (use sub-paths to keep bundles small). | | @vettvangur/vanilla/dom | clickOutside, preloadTimeout — both SSR-safe and return disposers. | | @vettvangur/vanilla/string | capitalize, dictionary, getCulture, getTranslation, isEmpty. | | @vettvangur/vanilla/data | fetcher, flatten, regexr. | | @vettvangur/vanilla/server | Node-only: loadEnvFiles, getUmbracoData. |

Selected APIs

  • fetcher({ url, options?, throwOnError = false }) — minimal fetch wrapper. Returns { data, error } by default; pass throwOnError: true to make it throw instead. No console.error — failures are quiet so build pipelines can decide.
  • dictionary(key, data, culture = 'is-IS') — translation lookup. Uses a WeakMap index to make repeat lookups against the same data array O(1).
  • getCulture(path) — extracts a BCP-47-ish culture prefix from a URL path: /is/...'is', /en-US/...'en-us'.
  • flatten(obj) — flattens nested objects to dash-joined keys ({ a: { b: 'x' } } → { 'a-b': 'x' }). Throws TypeError on non-object non-null input.
  • clickOutside(callback) — listens for clicks outside .co-trigger elements and the Escape key. Returns a disposer that removes both listeners.
  • preloadTimeout() — toggles loaded / preload--hidden body classes on a 100/400ms cadence. Returns a disposer that clears both timers.
  • loadEnvFiles(showMessage = true) — server-only loader that hydrates process.env from .env / .env.local etc.
  • getUmbracoData({ route, fetchType, options, fetchOptions }) — fetch from Umbraco's Content Delivery API, with loadEnvFiles invoked automatically.

SSR / disposers

DOM helpers (clickOutside, preloadTimeout) early-return a no-op disposer when document is undefined, so they're safe to import from server bundles. Always capture and call the returned disposer on unmount or route change.

const dispose = clickOutside(() => closeMenu())
// later:
dispose()