How to use undici - 2 common examples

To help you get started, we’ve selected a few undici examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mafintosh / ims / install.js View on Github external
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',
github jkyberneees / fast-proxy / lib / request.js View on Github external
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()
    }
  }

undici

An HTTP/1.1 client, written from scratch for Node.js

MIT
Latest version published 3 days ago

Package Health Score

98 / 100
Full package analysis

Popular undici functions