-
-
Save KevSlashNull/7ac9f02ee7dc1fdff029f4ad7a886d3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// yarn add request | |
const request = { | |
get (uri, opts) { | |
// lazy require | |
const request = require('util').promisify(require('request')) | |
const reqOpts = { | |
method: 'GET', | |
timeout: 30000, | |
resolveWithFullResponse: true, | |
json: true, | |
uri, | |
...opts | |
} | |
return request(reqOpts) | |
} | |
} | |
const registries = { | |
npm: 'https://registry.npmjs.org', | |
yarn: 'https://registry.yarnpkg.com', | |
taobao: 'https://registry.npm.taobao.org', | |
pnpm: 'https://registry.npmjs.org', | |
} | |
const packages = ['vue-cli-version-marker', 'siegegg-api', 'express', 'request', 'ts-node', 'axios', 'bootstrap', 'jquery'] | |
async function ping(registry, pkg) { | |
console.time(registry) | |
await request.get(`${registry}/${pkg}/latest`) | |
console.timeEnd(registry) | |
return registry | |
} | |
async function main(pkg) { | |
console.log('Using', pkg); | |
let faster = await Promise.all([ | |
ping(registries.yarn, pkg), | |
ping(registries.taobao, pkg), | |
]) | |
} | |
(async () => { | |
for (let pkg of packages) { | |
await main(pkg); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment