"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-registry-client/index.js" (7 Feb 2017, 2361 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 // utilities for working with the js-registry site.
    2 
    3 module.exports = RegClient
    4 
    5 var join = require('path').join
    6 var fs = require('graceful-fs')
    7 
    8 var npmlog
    9 try {
   10   npmlog = require('npmlog')
   11 } catch (er) {
   12   npmlog = {
   13     error: noop,
   14     warn: noop,
   15     info: noop,
   16     verbose: noop,
   17     silly: noop,
   18     http: noop,
   19     pause: noop,
   20     resume: noop
   21   }
   22 }
   23 
   24 function noop () {}
   25 
   26 function RegClient (config) {
   27   this.config = Object.create(config || {})
   28 
   29   this.config.proxy = this.config.proxy || {}
   30   if (!this.config.proxy.https && this.config.proxy.http) {
   31     this.config.proxy.https = this.config.proxy.http
   32   }
   33 
   34   this.config.ssl = this.config.ssl || {}
   35   if (this.config.ssl.strict === undefined) this.config.ssl.strict = true
   36 
   37   this.config.retry = this.config.retry || {}
   38   if (typeof this.config.retry.retries !== 'number') this.config.retry.retries = 2
   39   if (typeof this.config.retry.factor !== 'number') this.config.retry.factor = 10
   40   if (typeof this.config.retry.minTimeout !== 'number') this.config.retry.minTimeout = 10000
   41   if (typeof this.config.retry.maxTimeout !== 'number') this.config.retry.maxTimeout = 60000
   42   if (typeof this.config.maxSockets !== 'number') this.config.maxSockets = 50
   43 
   44   this.config.userAgent = this.config.userAgent || 'node/' + process.version
   45   this.config.defaultTag = this.config.defaultTag || 'latest'
   46 
   47   this.log = this.config.log || npmlog
   48   delete this.config.log
   49 
   50   var client = this
   51   fs.readdirSync(join(__dirname, 'lib')).forEach(function (f) {
   52     var entry = join(__dirname, 'lib', f)
   53 
   54     // lib/group-name/operation.js -> client.groupName.operation
   55     var stat = fs.statSync(entry)
   56     if (stat.isDirectory()) {
   57       var groupName = f.replace(/-([a-z])/, dashToCamel)
   58       fs.readdirSync(entry).forEach(function (f) {
   59         if (!f.match(/\.js$/)) return
   60 
   61         if (!client[groupName]) {
   62           // keep client.groupName.operation from stomping client.operation
   63           client[groupName] = Object.create(client)
   64         }
   65         var name = f.replace(/\.js$/, '').replace(/-([a-z])/, dashToCamel)
   66         client[groupName][name] = require(join(entry, f))
   67       })
   68       return
   69     }
   70 
   71     if (!f.match(/\.js$/)) return
   72     var name = f.replace(/\.js$/, '').replace(/-([a-z])/, dashToCamel)
   73     client[name] = require(entry)
   74   })
   75 }
   76 
   77 function dashToCamel (_, l) {
   78   return l.toUpperCase()
   79 }