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

@petite-pluie/fetchx

v0.1.2

Published

A modern HTTP client library based on fetch API with axios-like interface

Readme

FetchX

基于 fetch 的 axios 风格 HTTP 客户端,零依赖,TypeScript 优先。

npm version license

特性

  • axios 风格 APIapi.get() / api.post() / api.put() / api.delete() / api.patch() / api.head() / api.request()
  • 零依赖 — 基于浏览器原生 fetch,无第三方运行时依赖
  • TypeScript 优先 — 完整类型定义,泛型响应
  • 拦截器 — 请求/响应拦截器链,异步执行,支持添加/移除/清空,错误恢复
  • 超时与取消 — 内置超时控制,AbortController
  • 响应控制validateStatus 自定义成功判定,responseType 强制解析类型
  • 去重请求 — 基于 URL + 参数自动取消重复请求
  • 请求重试 — 指数退避算法,可配置重试次数和条件
  • 请求缓存 — 基于 key + TTL 的内存缓存,支持 LRU 淘汰
  • 并发控制 — 限制同时发起的请求数量
  • 进度监听 — 上传/下载进度回调
  • 防抖/节流debounceRequest / throttleRequest 工具函数
  • 流式请求 — SSE / NDJSON / 原始 Uint8Array 流,for await...of 消费
  • 响应流访问responseType: 'stream' 获取原始 ReadableStream
  • 自动解析 — 根据 Content-Type 自动解析 json/text/blob/form-data
  • 错误分类FetchXError 基类 + NetworkError / TimeoutError / CancelError / HTTPError 子类,类型守卫鉴别
  • 插件架构api.use(plugin) 插件系统,request/response/error/stream 生命周期钩子,优先级排序
  • 嵌套参数 — 查询参数支持嵌套对象(filter[status]=active)和自定义 paramsSerializer
  • 配置脱敏sanitizeConfig 开关,自动剥离敏感请求头

安装

pnpm add @petite-pluie/fetchx
npm install @petite-pluie/fetchx
yarn add @petite-pluie/fetchx

快速开始

import createFetchX from '@petite-pluie/fetchx';

const api = createFetchX({
  baseURL: 'https://api.example.com',
  timeout: 10000,
});

// GET 请求
const users = await api.get('/users');

// GET 带查询参数
const page = await api.get('/users', { params: { page: 1, limit: 10 } });

// POST 请求(自动 JSON 序列化)
const newUser = await api.post('/users', {
  name: 'John',
  email: '[email protected]',
});

// PUT 请求
const updated = await api.put('/users/1', { name: 'John Updated' });

// PATCH 请求
const patched = await api.patch('/users/1', { status: 'active' });

// DELETE 请求
await api.delete('/users/1');

// HEAD 请求
await api.head('/users');

TypeScript

interface User {
  id: number;
  name: string;
  email: string;
}

// 指定响应类型
const { data: user } = await api.get<User>('/users/1');
// user: User

const { data: users } = await api.get<User[]>('/users');
// users: User[]

// 访问响应元数据
const result = await api.get<User>('/users/1');
console.log(result.status, result.headers, result.config);

详细文档

License

MIT