]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/lib/dist-tags/fetch.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-registry-client / lib / dist-tags / fetch.js
1 module.exports = fetch
2
3 var assert = require('assert')
4 var url = require('url')
5
6 var npa = require('npm-package-arg')
7
8 function fetch (uri, params, cb) {
9   assert(typeof uri === 'string', 'must pass registry URI to distTags.fetch')
10   assert(
11     params && typeof params === 'object',
12     'must pass params to distTags.fetch'
13   )
14   assert(typeof cb === 'function', 'muss pass callback to distTags.fetch')
15
16   assert(
17     typeof params.package === 'string',
18     'must pass package name to distTags.fetch'
19   )
20   assert(
21     params.auth && typeof params.auth === 'object',
22     'must pass auth to distTags.fetch'
23   )
24
25   var p = npa(params.package)
26   var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
27   var rest = '-/package/' + pkg + '/dist-tags'
28
29   var options = {
30     method: 'GET',
31     auth: params.auth
32   }
33   this.request(url.resolve(uri, rest), options, function (er, data) {
34     if (data && typeof data === 'object') delete data._etag
35     cb(er, data)
36   })
37 }