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

@netjoy/dlhelper

v1.0.2

Published

一个简化前端下载功能的 js 辅助库,支持链接后台下载、代理下载、Blob数据下载,针对代理下载灵活使用

Readme

一、简介

  • 一个简化前端下载功能的 js 辅助库,支持链接后台下载、代理下载、Blob 数据下载,针对代理下载灵活使用。

二、使用

  • 安装

    $ npm i @netjoy/dlhelper
  • 引入

    import * as dl from "@netjoy/dlhelper";
  • 案例:后台下载

    dl.dlFetch(
      "https://test-public.juhaokanya.com/prod/aac5812fe2f6f3e1efeb6a86c8eb2867.png"
    )
      .then(() => {
        console.log("下载成功");
      })
      .catch((err) => {
        console.log("下载失败");
      });
  • 案例Blob 数据下载

    // 转成 Blob 对象
    const blob = new Blob(["字符串"]);
    // 进行下载,默认是 txt 文件,可通过传入文件名进行修改下载的文件类型
    dl.dlBlob(blob);
    dl.dlBlob(blob, "test.txt");
  • 案例:代理下载

    • main.js 配置代理标识与代理地址(可选

      // 引入
      import * as dl from '@netjoy/dlhelper'
      // 配置代理
      dl.setProxy({
        // 代理标识: [代理地址, 代理地址]
        // 这么配置,当使用 dl.dlProxy() 传入 url 时,可传入 '/download/test.png'、'https://www.baidu1.com/test.png'、'https://www.baidu2.com/test.png', 全链接的会自动匹配代理地址,匹配成功替换成对应的代理标识
        // 后面的数组参数主要是为了存放正式地址、测试地址、预发布地址等
        '/download/': ['https://www.baidu2.com/', ...],
        '/download': ['https://www.baidu1.com', ...],
        '/test/': [],
        ...
      })
    • 本地代理配置(项目配置文件中添加)

      // 开发配置
      devServer: {
        ...
        proxy: {
          // 代理配置
          '/download/': {
            target: 'https://www.baidu2.com/',
            ws: false,
            changeOrigin: true,
            pathRewrite: {
              '^/download/': ''
            }
          }
        }
      }
    • 服务器代理配置(服务器 server 中添加,正测试都需要)

      server {
        ...
        location /download/ {
          proxy_pass https://www.baidu2.com/;
        }
      }
    • 项目中使用

      // 使用这个必须配置 main.js
      // 会跟配置好的代理进行校验
      dl.dlProxy("/download/test.png");
      dl.dlProxy("/download/test.png", "aaa.png");
      dl.dlProxy("https://www.baidu1.com/test.png");
      
      // 使用这个 main.js 配置可选
      // 如果不想在 main.js 中配置 dl.setProxy(),可以在知道这是配好的代理下载链接时,直接通过代理链接下载(如:/download/test.png,不能是全链接,全链接没法匹配替换)
      // 注意:dl.dlClick() 只能下载代理文件链接、同域名文件链接,像 'https://www.baidu1.com/test.png' 这种就是非代理链接了,上面支持是因为内部会进行匹配替换成代理标识
      dl.dlClick("/download/test.png");