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

http-scheduler

v0.1.3

Published

HTTP requests by priority

Readme

HTTP Scheduler

产生背景

一个动态页面的数据可能由N个接口提供,因为浏览器同域的并发限制(通常为4~6个), 这时候就需要考虑哪些请求是必须的,哪些是可延缓的,然后按优先级依次请求, 从而避免优先级高的请求被滞后导致页面主要信息加载不及时的问题。 这时候,如果有一个复杂的页面,考虑和维护这个请求的优先级会浪费大量梳理时间, 那么设计一个规范统一的请求调度类做这件事,会带来更好的开发体验。

设计思路

解决问题的核心思路是使用优先队列,每个域名请求对应一个队列元素,然后按权出队。

应用场景

优先级控制

  1. 在HTTP1.1任然流行的今天,浏览器对同域名的http并发请求有限制,如果页面要同时发送多个请求,你可能需要保证请求发送的顺序,总有一些请求优先级比较高。一般情况下可以通过代码的执行顺序来控制,但是当代码复杂时,要保证顺序并不容易,使用 http-scheduler 则无需关注代码执行顺序,只需给每个请求定义优先级大小即可。

请求撤销

  1. 连续多次点击 搜索 按钮,可取消之前未完成的请求,只保留最后一次搜索的结果。 备注:通常情况下我们可以通过 节流 或者 防抖 解决这个问题,但是在极端情况下,仍然可能发生问题。比如:在超出节流防抖预设的时间点击两次按钮,第一次发出的请求称为A,第二次请求称为B,如果B的结果返回得比A早,最终呈现的数据会是A请求的结果,实际应该是B。以上情况还有别的解决方法,但是使用http-scheduler 库解决像使用节流防抖一样简便。具体例子看......
  2. 当两个 页面 频繁切换时,可取消上一个页面未完成的请求。

快速入门