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

@prexjs/utils

v1.0.0

Published

Core utility functions for Prex and Express applications including ETag generation, trust proxy compilation, query parsing, and MIME normalization.

Readme

@prexjs/utils

Core utility functions for Prex and Express applications including ETag generation, trust proxy compilation, query parsing, and MIME normalization.

npm version npm downloads License: MIT TypeScript

@prexjs/utils provides shared helper functions and internal compilation utilities used across @prexjs/prex, @prexjs/application, @prexjs/request, and @prexjs/response.

Features

  • ETag Generators: Strong and weak ETag hashing (etag, wetag, compileETag).
  • Proxy Trust Compilation: Compiles IP addresses, subnets, hop counts, or trust predicates using @prexjs/proxy-address.
  • Query String Compilers: Supports simple (node:querystring) and extended (qs) query string parsers.
  • Header & MIME Helpers: Normalizes content types, inspects media type accept parameters, and sets character encodings.
  • HTTP Methods List: Complete list of supported HTTP methods recognized by Node.js.

Installation

Install using your preferred package manager:

# npm
npm install @prexjs/utils

# pnpm
pnpm add @prexjs/utils

# Yarn
yarn add @prexjs/utils

# Bun
bun add @prexjs/utils

Quick start

import {
  compileTrust,
  compileQueryParser,
  compileETag,
  setCharset,
} from '@prexjs/utils';

// Compile proxy trust helper
const trust = compileTrust('loopback, 10.0.0.0/8');
console.log(trust('127.0.0.1', 0)); // true

// Compile query parser
const parseQuery = compileQueryParser('extended');
console.log(parseQuery('user[name]=Alice&user[role]=admin'));

// Set charset on Content-Type
const contentType = setCharset('text/html', 'utf-8');
console.log(contentType); // 'text/html; charset=utf-8'

API

compileTrust(val)

Compiles a proxy trust setting into a predicate function (addr: string, i: number) => boolean. Accepts booleans, numbers (hop count), IP addresses, CIDR ranges, or custom functions.

compileETag(val)

Returns an ETag generator function. Accepts 'strong', 'weak', booleans, or custom functions.

compileQueryParser(val)

Returns a query string parsing function. Accepts 'simple', 'extended', booleans, or custom functions.

setCharset(type, charset)

Appends or replaces the charset parameter on an existing MIME type string.

normalizeType(type) / normalizeTypes(types)

Normalizes shorthand extensions (e.g. 'json') to full MIME type descriptors (e.g. 'application/json').

Compatibility

  • Node.js >= 18.0.0
  • Supports both ESM and CommonJS
  • TypeScript 5.0+

Related Packages

License

MIT