"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-registry-client/lib/dist-tags/fetch.js" (8 Mar 2017, 981 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 }