3 var assert = require('assert')
4 var url = require('url')
6 var npa = require('npm-package-arg')
8 function fetch (uri, params, cb) {
9 assert(typeof uri === 'string', 'must pass registry URI to distTags.fetch')
11 params && typeof params === 'object',
12 'must pass params to distTags.fetch'
14 assert(typeof cb === 'function', 'muss pass callback to distTags.fetch')
17 typeof params.package === 'string',
18 'must pass package name to distTags.fetch'
21 params.auth && typeof params.auth === 'object',
22 'must pass auth to distTags.fetch'
25 var p = npa(params.package)
26 var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
27 var rest = '-/package/' + pkg + '/dist-tags'
33 this.request(url.resolve(uri, rest), options, function (er, data) {
34 if (data && typeof data === 'object') delete data._etag