V2EX magicdawn
 magicdawn's recent timeline updates
magicdawn

magicdawn

V2EX member #63811, joined on 2014-05-28 23:47:26 +08:00
magicdawn's recent replies
刚充好 USDT ,7 块的就没了。。。
搞笑又扎心
@uni #9 为什么不去了解一下背景呢?大 npm 包被影视站利用,成本你出么?

如果你嫌弃就不要用,没有收费为何要承担被你喷的困境。

是的你没有了解背景的义务,但同时你也没有喷的权利。
npmmirror v.s tencent mirror ,坐标湖北武汉, 结果:

=== Final Result (sorted by tarball avg) ===

npmmirror
metadata avg: 229.4 ms
metadata p50: 253.9 ms
metadata p90: 409.2 ms
tarball avg: 435.1 ms
tarball p50: 266.1 ms
tarball p90: 906.1 ms


tencent
metadata avg: 777.0 ms
metadata p50: 700.7 ms
metadata p90: 1336.7 ms
tarball avg: 508.6 ms
tarball p50: 440.9 ms
tarball p90: 938.3 ms

脚本 via ChatGPT
```js
#!/usr/bin/env node
import { performance } from 'node:perf_hooks'

const registries = [
{
name: 'npmmirror',
base: 'https://registry.npmmirror.com',
},
{
name: 'tencent',
base: 'http://mirrors.tencent.com/npm',
},
]

// 多包(覆盖不同大小 & 热门程度)
const PACKAGES = [
{ name: 'react', version: '18.2.0' },
{ name: 'lodash', version: '4.17.21' },
{ name: 'typescript', version: '5.4.5' },
{ name: 'axios', version: '1.6.7' },
]

// 多轮(建议 ≥10 )
const RUNS = 10

// 并发数(模拟 npm )
const COnCURRENCY= 4

async function fetchWithTiming(url) {
const start = performance.now()
const res = await fetch(url)
await res.arrayBuffer()
return performance.now() - start
}

// 简单并发控制
async function runPool(tasks, limit) {
const results = []
let i = 0

async function worker() {
while (i < tasks.length) {
const idx = i++
results[idx] = await tasks[idx]()
}
}

await Promise.all(Array.from({ length: limit }, worker))
return results
}

async function testRegistry(registry) {
const metadataTimes = []
const tarballTimes = []

for (let run = 0; run < RUNS; run++) {
const tasks = []

for (const pkg of PACKAGES) {
const metadataUrl = `${registry.base}/${pkg.name}`
const tarballUrl = `${registry.base}/${pkg.name}/-/${pkg.name}-${pkg.version}.tgz`

tasks.push(async () => {
const t = await fetchWithTiming(metadataUrl)
metadataTimes.push(t)
})

tasks.push(async () => {
const t = await fetchWithTiming(tarballUrl)
tarballTimes.push(t)
})
}

await runPool(tasks, CONCURRENCY)
console.log(`[${registry.name}] run ${run + 1}/${RUNS} done`)
}

function statsarr) {
const sorted = [...arr].sort((a, b) => a - b)
const avg = arr.reduce((a, b) => a + b, 0) / arr.length
const p50 = sorted[Math.floor(sorted.length * 0.5)]
const p90 = sorted[Math.floor(sorted.length * 0.9)]
return { avg, p50, p90 }
}

return {
name: registry.name,
metadata: stats(metadataTimes),
tarball: stats(tarballTimes),
}
}

async function main() {
const results = []

for (const r of registries) {
console.log(`\nTesting ${r.name}...`)
const res = await testRegistry(r)
results.push(res)
}

console.log('\n=== Final Result (sorted by tarball avg) ===')

results.sort((a, b) => a.tarball.avg - b.tarball.avg)

for (const r of results) {
console.log(`
${r.name}
metadata avg: ${r.metadata.avg.toFixed(1)} ms
metadata p50: ${r.metadata.p50.toFixed(1)} ms
metadata p90: ${r.metadata.p90.toFixed(1)} ms
tarball avg: ${r.tarball.avg.toFixed(1)} ms
tarball p50: ${r.tarball.p50.toFixed(1)} ms
tarball p90: ${r.tarball.p90.toFixed(1)} ms
`)
}
}

main()
```


这个包水平低下,严重浪费开发者磁盘,建议停用
https://www.npmjs.com/package/effect-solutions?activeTab=code
这是个公益站,恶心不用就是。没有收你一分钱哦~
因为我觉得很好,必须站出来说句好
因为 npmmirror 我的常用命令 `corepack use pnpm@latest && ncu-safe && pi && p dedupe && p prune` 快了不少

export COREPACK_NPM_REGISTRY=https://registry.npmmirror.com


```sh
where ncu-safe
ncu-safe: aliased to ncu -t minor -u

where pi
pi: aliased to pnpm install

where p
p: aliased to pnpm
```
确实烦,但是一个包 325MB 就不得不反思为什么 npm 包要这么大?
npm 应该用来分发代码, assets 请自建分发,参考 puppeteer 下载浏览器实例.

> 325793115 / 1000 / 1000
325.793115
发 ncr 的没毛病,OP 描述有问题。
ncr 是防止访问 google.com 重定向到 google.com.hk ,ncr = no country redirection.
OP 的标题让人想到这个。

OP 想说的是 safari 浏览器搜索引擎选择谷歌时,safari 内置的是 google.cn ,这是个中间页问你要不要到 google.com.hk 上搜索,想要看到结果必须再点一下链接。
这个锅只能 safari / Apple 背,ipad 上搜索引擎这几个预设选项,没有自定义,还不修正 google.cn 的行为。
About     Help     Advertise     Blog     API     FAQ     Solana     1000 Online   Highest 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 23ms UTC 19:20 PVG 03:20 LAX 12:20 JFK 15:20
Do have faith in what you're doing.
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86