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

@wang-yige/request

v0.0.2

Published

A warpper for axios, add some useful features like retry, cache, etc.

Readme

@wang-yige/request

A warpper for axios, add some useful features like retry, cache, etc.

Usage

import { APIRequest } from '@wang-yige/request';

const Root = new APIRequest('https://jsonplaceholder.typicode.com');

const api = (i: number) => {
	return Root.get('/todos/' + i);
};

api(0); // result promise with abort method, and it alias for cancel method.

Config

const Root = new APIRequest('/', {
    /**
	 * Then User-Agent header config, default is void.
	 * Used in node environment.
	 */
	userAgent?: string,
	/**
	 * The domains that can be retried, if set it,
	 * the retry count will be the max of the `domains`'s length and `retryCount`.
	 */
	domains?: string[],
	/**
	 * Max number to sync request.
	 * - default `5`
	 */
	maximum?: number,
	/**
	 * Max number to trigger request by current url in a second,
	 * if it is zero or negative, it will not check.
	 * - default `50`
	 */
	triggerLimit?: number,
});

Root.get('/todos/0', {
    /**
	 * The same url request is only single at a time.
	 * Not include the params.
	 * - default `true`
	 */
	single?: boolean,
	/**
	 * The type for single request.
	 * - default is `SingleType.QUEUE`
	 */
	singleType?: SingleType,
	/**
	 * Cache the Get request response.
	 * - default `false`
	 */
	cache?: boolean,
	/**
	 * Cache time in miliseconds.
	 * If time is negative or zero, it will not be cached.
	 */
	cacheTime?: number,
	/**
	 * Retry the request if failed.
	 * - default `false`
	 */
	retry?: boolean,
	/**
	 * Retry count.
	 * - default `5`
	 */
	retryCount?: number,
	/**
	 * Delay time for retry in miliseconds.
	 * - default `1000`
	 */
	retryDelay?: number,
	/**
	 * The axios error codes to retry.
	 * - default `['ECONNABORTED', 'ERR_NETWORK, 'ETIMEDOUT', 'ECONNREFUSED']`
	 * `'ECONNREFUSED'` is only available in nodejs.
	 */
	retryErrorCode?: string | string[],
	/**
	 * If `retryErrorCode` not include `ERR_BAD_RESPONSE`,
	 * this config will be matched when response `err.code` equals `'ERR_BAD_RESPONSE'`.
	 * - default codes are `500`, `404`, `502`
	 */
	retryResponseCode?: number | number[],
	/**
	 * If `retryErrorCode` not include `ERR_BAD_REQUEST`,
	 * this config will be matched when response `err.code` equals `'ERR_BAD_REQUEST'`.
	 * - default code is `404`
	 */
	retryRequestCode?: number | number[],
	/**
	 * Whether use domains to retry.
	 * - default `true`
	 */
	useDomains?: boolean,
});