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

@teplostanski/header-map

v0.3.4

Published

Parse HTTP headers into an AST and lowercase maps

Readme

header-map

min+gzip

Parse HTTP headers into a small AST and lowercase maps.

Built as a low-level precursor to device-signal work: normalize whatever the runtime gives you (Record, Fetch Headers, or a raw header block) before reading CDN hints like cf-device-type or CloudFront-Is-*-Viewer.

Pure functions. No ambient request state.

Install

pnpm add @teplostanski/header-map

Quick start

import {
  parseHeaders,
  getHeader,
  toHeaderMap,
  pickHeaders,
} from '@teplostanski/header-map'

// From a plain object (Node / edge)
const parsed = parseHeaders(req.headers)

parsed.fields
// [{ name: 'CF-Device-Type', canonical: 'cf-device-type', value: 'mobile' }, ...]

parsed.map['cf-device-type'] // 'mobile'  (last value wins)
parsed.multi['accept']       // all values in order

getHeader(req.headers, 'CloudFront-Is-Mobile-Viewer')

// Shape undevice-style consumers expect
toHeaderMap(req.headers)
// { 'cf-device-type': 'mobile', 'user-agent': '...', ... }

pickHeaders(req.headers, [
  'cf-device-type',
  'cloudfront-is-mobile-viewer',
  'cloudfront-is-tablet-viewer',
  'cloudfront-is-desktop-viewer',
])

Raw header block

import { parseHeaders } from '@teplostanski/header-map'

const parsed = parseHeaders(`
HTTP/1.1 200 OK
Content-Type: text/html
cf-device-type: tablet

`.trimStart())

API

| Export | Role | |--------|------| | parseHeaders(input) | Main entry → { fields, multi, map } | | parseRawHeaders(raw) | Raw block → HeaderField[] | | getHeader(input, name) | Case-insensitive single value | | getHeaderAll(input, name) | All values for a name | | hasHeader(input, name) | Presence check | | toHeaderMap(input) | Record<string, string> (lowercase keys) | | pickHeaders(input, names) | Subset map |

input may be a string, a Record, a Fetch Headers, an iterable of [name, value] pairs, or an already parsed result.

Non-goals

  • Device / bot detection (see undevice)
  • Full HTTP message parsing (body, trailers as a stream)
  • Cookie jar semantics

License

MIT — see LICENSE.