"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-registry-client/lib/whoami.js" (8 Mar 2017, 665 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 = whoami
    2 
    3 var url = require('url')
    4 var assert = require('assert')
    5 
    6 function whoami (uri, params, cb) {
    7   assert(typeof uri === 'string', 'must pass registry URI to whoami')
    8   assert(params && typeof params === 'object', 'must pass params to whoami')
    9   assert(typeof cb === 'function', 'must pass callback to whoami')
   10 
   11   var auth = params.auth
   12   assert(auth && typeof auth === 'object', 'must pass auth to whoami')
   13 
   14   if (auth.username) return process.nextTick(cb.bind(this, null, auth.username))
   15 
   16   this.request(url.resolve(uri, '-/whoami'), { auth: auth }, function (er, userdata) {
   17     if (er) return cb(er)
   18 
   19     cb(null, userdata.username)
   20   })
   21 }