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

@freckle/query-params

v3.0.2

Published

Query params utilities

Readme

@freckle/query-params

Utilities for constructing and using query parameters.

Install

pnpm add @freckle/query-params

This package is ESM-only.

Usage

urlWithQueryParams(baseUrl, queryParams)

Appends a query string to baseUrl. null and undefined values are dropped, arrays are joined with ,, and Moment values become epoch milliseconds. When nothing is left to append, baseUrl is returned unchanged.

import {urlWithQueryParams} from '@freckle/query-params'

urlWithQueryParams('/api/students', {grade: 3, active: true})
// '/api/students?grade=3&active=true'

urlWithQueryParams('/api/students', {grade: null, ids: [1, 2, 3]})
// '/api/students?ids=1,2,3'

urlWithQueryParams('/api/students', {})
// '/api/students'

Values of any other type throw:

urlWithQueryParams('/api/students', {a: {b: 1}})
// Error: Invalid type of query param object for key a

createAPIQueryParams(queryParams)

The query string on its own, without a base URL or ?. Returns null when every value was dropped, which is what makes the urlWithQueryParams empty case work.

import {createAPIQueryParams} from '@freckle/query-params'

createAPIQueryParams({a: 1, b: 'x'}) // 'a=1&b=x'
createAPIQueryParams({}) // null

toQueryParamObj(name, filters)

Expands a filter object into name[operator] keys, for APIs that take range filters. Supported operators are in, notin, gt, gte, lt and lte.

import {toQueryParamObj, urlWithQueryParams} from '@freckle/query-params'

toQueryParamObj('score', {gte: 0.5, lt: 0.9})
// {'score[gte]': 0.5, 'score[lt]': 0.9}

urlWithQueryParams('/api/students', toQueryParamObj('score', {gte: 0.5}))
// '/api/students?score[gte]=0.5'

Values are not URL-encoded

Keys and values are interpolated as-is. Anything with a reserved character in it changes meaning rather than being escaped:

urlWithQueryParams('/api', {q: 'a&b=c'}) // '/api?q=a&b=c'  -> server reads two params
urlWithQueryParams('/api', {q: 'a#b'}) // '/api?q=a#b'    -> '#b' becomes a fragment
urlWithQueryParams('/api', {name: 'John Smith'}) // '/api?name=John Smith'

Pass values that are already safe — ids, numbers, booleans, timestamps, enum strings — or encode them yourself before passing them in. Free-form text is not safe to pass directly.

Development

  • Package manager: pnpm (Node version pinned in .nvmrc)
  • pnpm build — tsc -p tsconfig.build.json, emits to dist/
  • pnpm test — Vitest
  • pnpm coverage — Vitest with coverage, gated at 70% (lines/branches/functions/statements)
  • pnpm typecheck — tsc --noEmit, includes test files
  • pnpm lint — ESLint
  • pnpm format / pnpm format-check — Prettier
  • pnpm knip — unused files/dependencies/exports
  • CI runs all of the above on every PR, plus a check that dist/ is up to date

Release

See RELEASE.md.


LICENSE