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

@blyou/reurl

v0.0.2

Published

A tiny zero-dependency URL parser.

Readme

reurl

超轻量的 URL 解析器:仅做必要的字符串切分与拼接,不做任何编码 / 解码 / 转义,不做规范化,不解析相对路径。与浏览器原生 URL / URLSearchParams 的 API 对齐,但运行时代码体积极小(构建产物约 1 KB gzip)。

特性

  • 🪶 极小体积:仅做必要的字符串切分与拼接,零依赖
  • 🔤 原样保留:中文、空格、%20 等字符一律不处理,查询串不经 percent 编解码
  • 🌐 支持 IPv6[2001:db8::1]:8080 这类主机正确拆分 host / hostname / port
  • 🧩 TypeScript 类型对齐:导出 ReURLReSearchParams,签名对齐原生接口

安装

pnpm i @blyou/reurl

使用

ReURL

import { ReURL } from '@blyou/reurl'

const u = new ReURL('https://example.com:8080/a/b?x=1&y=2#frag')

u.protocol // 'https:'
u.host // 'example.com:8080'
u.hostname // 'example.com'
u.port // '8080'
u.pathname // '/a/b'
u.search // '?x=1&y=2'
u.hash // '#frag'
u.origin // 'https://example.com:8080'
u.href // 'https://example.com:8080/a/b?x=1&y=2#frag'

所有 getter 都有对应的 setter,修改任一字段都会即时反映到 href

u.hostname = 'b.com' // host → 'b.com:8080'
u.port = '9090' // host → 'b.com:9090'
u.pathname = '/new' // href 同步更新

userinfo(username / password)

const u2 = new ReURL('https://user:[email protected]/')

u2.username // 'user'
u2.password // 'pass'
u2.password = 'new' // href → 'https://user:[email protected]/'
u2.username = ''
u2.password = '' // href → 'https://a.com/'(userinfo 整体移除)

searchParams 双向联动

const u = new ReURL('https://a.com/p?a=1&b=2')
const sp = u.searchParams // 同一对象会被缓存

sp.append('c', '3')
u.href // 'https://a.com/p?a=1&b=2&c=3'

u.search = 'k=v'
sp.get('k') // 'v'

ReSearchParams

查询串仅按 & / = 切分与拼接,不做编解码。

import { ReSearchParams } from '@blyou/reurl'

const sp = new ReSearchParams('?a=1&a=2&b=2')

sp.get('a') // '1'
sp.getAll('a') // ['1', '2']
sp.has('b') // true
sp.append('c', '3')
sp.set('b', '9') // 先删后插,不保留键的原始位置
sp.delete('a')
sp.sort() // 按键稳定排序
sp.toString() // 'b=9&c=3'

// 迭代器
for (const [key, value] of sp) {
  /* ... */
}
sp.keys()
sp.values()
sp.entries()

支持字符串 / 二维数组 / 对象 / ReSearchParams 多种构造方式:

new ReSearchParams([
  ['a', '1'],
  ['b', '2'],
])
new ReSearchParams({ a: '1', b: '2' })
new ReSearchParams(new ReSearchParams('a=1'))

与原生 API 的有意差异

为了在最小体积下工作,reurl 刻意省略了一些原生行为:

| 项目 | 原生行为 | reurl 行为 | | -------------------- | ---------------------------- | ---------------------------------------------- | | 非分层协议 | data: / mailto: 等可解析 | 不支持,直接抛出 TypeError | | 相对路径 | new URL('/p', base) 可解析 | 不支持 base 参数(相对路径视为不可解析) | | searchParams.set() | 保留键的原始位置 | 先删后插,位置移到末尾 | | userinfo | 拆分且 percent 编解码 | 拆分 username / password,但原样保留不编解码 |

开发

pnpm install     # 安装依赖
pnpm test        # 运行单元测试
pnpm typecheck   # 类型检查
pnpm lint        # 代码检查
pnpm build       # 构建产物到 dist/

License

MIT