Skip to content
/ dnrm Public

deno 实现的 nrm,每次切换源都在 100ms 内,速度超级快 | deno implementation of nrm, each switch source within 100ms, super fast

License

Notifications You must be signed in to change notification settings

markthree/dnrm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e6501df · Oct 27, 2024
Oct 4, 2024
Jun 29, 2023
Oct 27, 2024
Jun 12, 2023
Jul 25, 2023
May 2, 2023
Jul 19, 2024
Jul 19, 2024
Sep 13, 2023
Aug 24, 2024
Jan 25, 2024
Aug 24, 2024
May 11, 2023
Feb 28, 2024

Repository files navigation

dnrm

deno 实现的 nrm,每次切换源都在 100ms 内,速度超级快


README 🦉

简体中文 | English


Bench

npm 镜像源工具速度对比


Usage

install

1. 模块安装

deno install --allow-read --allow-sys --allow-write --allow-env --allow-net -rfn dnrm https://deno.land/x/dnrm/mod.ts

如果你装了 node,却没有安装过 deno 👇

npx deno-npx install --allow-read --allow-write --allow-env --allow-net -rfn dnrm https://deno.land/x/dnrm/mod.ts

在一些不想装 deno 的临时场景下 👇

# 注意: 这种使用方式仍然很慢,因为加载 deno 垫片需要时间
npm i deno-nrm -g

2. 本地安装

  1. 下载该项目到本地

  2. 在项目根目录下执行命令

deno task install

cli

# 查看当前源
dnrm

# 切换 taobao 源
dnrm use taobao

# 查看所有源
dnrm ls

# 测试所有源
dnrm test

# 设置源在本地
dnrm use taobao --local

# 查看帮助
dnrm -h

# 查看版本号
dnrm -V

优化原理

  1. 热路径查询
  2. deno 的冷启动比 node 更快
  3. 自动区分使用场景,按需解析参数,按需加载低频模块,按需设置配置文件
  4. 针对 registry 配置使用正则快速获取和替换配置,不使用任何耗时的解析器,不需要序列化和反序列化
  5. 直接针对配置文件进行配置替换,而不是调用子进程执行 npm config set registry=...,因为 npm 内部分支太多,这是卡的主要原因

License

Made with markthree

Published under MIT License.

About

deno 实现的 nrm,每次切换源都在 100ms 内,速度超级快 | deno implementation of nrm, each switch source within 100ms, super fast

Topics

Resources

License

Stars

Watchers

Forks