Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const IMS = require('./')
const trim = require('diffy/trim+newline')
const minimist = require('minimist')
var tick = 1
var rendered = 0
setInterval(() => tick++, 250).unref()
// we have some bug in the seed'er so whitelist
// against these peers until we fix it
const whitelist = [
'88.99.3.86',
'159.65.107.57'
]
const pool = new Pool('https://registry.npmjs.org', {
// magic numbers on what works good on my OS
// if those high number of connections are not needed
// they won't be used
connections: 128,
pipelining: 2
})
const argv = minimist(process.argv.slice(2), {
alias: {
global: 'g',
save: 's',
'save-dev': 'S',
key: 'k',
production: 'p',
help: 'h',
update: 'u',
if (!opts.base) throw new Error('Option base is required when http2 is true')
} else {
agents = {
'http:': new http.Agent(agentOption(opts)),
'https:': new https.Agent(agentOption(opts))
}
}
if (isHttp2) {
http2 = getHttp2()
return { request: handleHttp2Req, close }
} else if (isUndici) {
if (typeof opts.undici !== 'object') {
opts.undici = {}
}
pool = new undici.Pool(baseUrl, opts.undici)
return { request: handleUndici, close }
} else {
return { request: handleHttp1Req, close }
}
function close () {
if (isUndici) {
pool.destroy()
} else if (!isHttp2) {
agents['http:'].destroy()
agents['https:'].destroy()
} else if (h2client) {
h2client.destroy()
}
}