Skip to content

Instantly share code, notes, and snippets.

@fangbinwei
Created October 25, 2020 08:06
Show Gist options
  • Save fangbinwei/ab2be92189da9e5c8b52bfa24e6187d6 to your computer and use it in GitHub Desktop.
Save fangbinwei/ab2be92189da9e5c8b52bfa24e6187d6 to your computer and use it in GitHub Desktop.
test registry
// 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',
}
async function ping(registry) {
await request.get(`${registry}/vue-cli-version-marker/latest`)
return registry
}
async function main() {
let faster = await Promise.race([
ping(registries.yarn),
ping(registries.taobao),
])
console.log(faster)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment