Created
October 25, 2020 08:06
-
-
Save fangbinwei/ab2be92189da9e5c8b52bfa24e6187d6 to your computer and use it in GitHub Desktop.
test registry
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', | |
} | |
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