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

@mini-dev/request

v0.4.0

Published

cross-miniprogram request helper — platform-agnostic core engine

Readme

@mini-dev/request

跨微信 / 支付宝 / 抖音小程序 HTTP 请求库的平台无关核心(TypeScript)。

通常无需直接安装本包——它会作为平台包(@mini-dev/request-wx / -my / -tt)的依赖自动引入。下面介绍的是「augment-only 核心用法」,面向需要绕开便捷层归一、直接用 canonical 字段组装中间件链的消费方。

提供的能力:

  • createMethod(name, { engine, interceptors, cacheSize, retryDelay }) —— 把一个原生网络方法包成增强方法实例(洋葱中间件链 + 独享缓存 + retry 外层)。
  • 中间件:abort / cache / timeout / retry(由 ext 激活,全省略即纯透传)。
  • RequestError(code: TIMEOUT / CANCELLED / UNSUPPORTED)、Response、ChunkThrough。
  • AbortController / AbortControllerPolyfill / AbortSignal(按 globalThis.AbortController → 库自带 polyfill 兜底解析)。
  • normalizeRequestOptions / createConvenienceRequest(便捷层归一与实例构造,平台包默认单例即基于此)。

安装

npm i @mini-dev/request      # 通常由平台包自动引入,手动安装仅 augment-only 场景需要

快速开始(augment-only)

核心 不归一:入参用 canonical 字段名(如 headers 而非某平台原生 header),engine 负责把它映射到原生。库控制统一装在保留字段 ext,与原生参数命名空间隔离。

const { createMethod, RequestError } = require('@mini-dev/request');
// engine 需由平台包提供,例如:
// const { createWxEngine } = require('@mini-dev/request-wx');

const request = createMethod('request', {
    engine: createWxEngine,          // 平台 engine 工厂(首次调用懒调)
    interceptors: []                 // 该方法默认的洋葱拦截器
});

request({
    url: 'http://x/y',
    headers: { token: 't' },          // canonical 请求头(复数),engine 映射为原生 header
    ext: { timeout: 3000, retry: 2, maxAge: 60000 }
}).then((res) => {
    // res 是 Response:res.data / res.headers / res.statusCode 原样透传
}).catch((err) => {
    if (err instanceof RequestError) { /* 库源错误,看 err.code */ }
    else { /* 原生错误原样透传,形如 { errMsg } */ }
});

ext.interceptors 可单次追加洋葱拦截器(Interceptor 签名 (ctx, next) => Promise<void>,koa-compose 风格);原生回调 success / fail / complete 也支持(传入则返回 undefined,与原生一致)。

完整文档

本包是 minidev-request monorepo 的核心。完整设计、API、迁移指南与示例见仓库 README。

License

ISC