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

@yy-web/request

v2.1.0

Published

yyweb request

Readme

@yy-web/request

NPM version

Features

  • Plug-in mode
  • Chain call
  • restful specification
  • Flexible configuration
  • Transport-agnostic: works with a native fetch client or an axios instance
  • Built-in caching with in-flight de-duplication for identical cached GETs
  • Concurrency limiting via maxConcurrentNum

Install

npm i @yy-web/request

axios is an optional peer dependency. Install it only if you pass an axios instance as the transport. The native fetch client needs no extra dependency.

With native fetch

// request.ts
import request, { createFetchClient, setRequest } from '@yy-web/request'

const client = createFetchClient({
  baseURL: '/api',
})

const yyRequest = request(client)
setRequest(yyRequest)

export default yyRequest

createFetchClient supports baseURL, headers, timeout and request/response/error interceptors. The chainable API below is identical regardless of transport.

With axios

// request.ts
import request, { setRequest } from '@yy-web/request'
import axios from 'axios'

const service = axios.create({
  baseURL: '/api',
})

const yyRequest = request(service)
setRequest(yyRequest)

export default yyRequest

Feature

  • get action
import { getRequest } from '@yy-web/request' // get instance
import request from './request.ts'

// simple
request.setPath('xxxx').get(params)

// cache get
request.setPath('xxxx').get(true)
request.setPath('xxxx').get(params, true)

When caching is enabled, identical cached GETs fired concurrently are de-duplicated into a single network request: the first call performs the request and the rest resolve (or reject) with its outcome.

Inspect built-in cache with @yy-web/request-tools

@yy-web/request-tools can inspect the default in-memory cache provided by @yy-web/request. It currently supports only the built-in cache helpers (getStore / setStore / hasStore), not custom store implementations.

pnpm add @yy-web/request-tools
import {
  clearRequestCache,
  getRequestCacheSnapshot,
  RequestCacheInspector,
  subscribeRequestCache,
} from '@yy-web/request-tools'
  • getRequestCacheSnapshot() reads all current cache entries.

  • subscribeRequestCache(listener) listens for cache set and clear events.

  • clearRequestCache() clears the built-in cache.

  • RequestCacheInspector is a floating Vue component for quick debugging.

  • other

import { getRequest } from '@yy-web/request' // get instance
import request from './request.ts'

request.setPath('xxxx').post(data)
request.setPath('xxxx').put()
request.setPath('xxxx').upload()
request.setPath('xxxx').del()

result carry

const id = 1
request.setPath('xxxx/{id}').carry(id) // -> request.setPath('xxxx/1')
  • downfile
import request, { fileInterceptorsResponseConfig, setRequest } from '@yy-web/request'
import axios from 'axios'

const service = axios.create({
  baseURL: '/api',
})

service.interceptors.response.use((response: any) => {
  const { isFile, value } = fileInterceptorsResponseConfig(response)
  if (isFile)
    return value

  return response.data
})

interface RequestStoreConfig {
  getStore?: (key: string) => any
  hasStore?: (key: string) => boolean
  setStore?: (key: string, data: any) => void
  cancelRepeat?: boolean // cancel repeated in-flight requests to the same path
  maxConcurrentNum?: number // max simultaneous requests, others queue (default: 99)
}

const yyRequest = request(service, { getStore, hasStore, setStore, cancelRepeat: true })

const store = {}
function getStore(key: string) {
  return store[key]
}

function hasStore(key: string) {
  return key in store
}

function setStore(key: string, data: any) {
  store[key] = data
}
setRequest(yyRequest)

request.setPath('xxxx').downLoad(data)

type

interface IRequest {
  setPath: (url: string, loading?: boolean) => IRequest
  setConfig: (config: IAxiosRequestConfig) => IRequest
  forceCancelRepeat: () => IRequest
  carry: (key: string | number) => IRequest
  get: <T, Callback = false>(params?: boolean | object, cache?: boolean, dataCallback?: (data: T) => Callback) => Promise<Callback extends false ? T : Callback>
  post: <T>(data?: object | FormData) => Promise<T>
  put: <T>(data?: object) => Promise<T>
  del: <T>(params?: object) => Promise<T>
  upload: <T>(file: File, data?: object) => Promise<T>
  downLoad: (params?: object, methods?: 'post' | 'get', fileName?: string) => Promise<void>
  clear: () => void
}

License

MIT